@informalsystems/quint
Version:
Core tool for the Quint specification language
149 lines (148 loc) • 5.13 kB
TypeScript
/**
* The commands for the quint CLI
*
* See the description at:
* https://github.com/informalsystems/quint/blob/main/doc/quint.md
*
* @author Igor Konnov, Gabriela Moreira, Shon Feder, Informal Systems, 2021-2025
*/
import { SourceMap } from './parsing/quintParserFrontend';
import { ErrorMessage } from './ErrorMessage';
import { Either } from '@sweet-monads/either';
import { EffectScheme } from './effects/base';
import { LookupTable } from './names/base';
import { OpQualifier, QuintEx, QuintModule } from './ir/quintIr';
import { TypeScheme } from './types/base';
import { DocumentationEntry } from './docs';
import { IdGenerator } from './idGenerator';
import { AnalysisOutput } from './quintAnalyzer';
import { Maybe } from '@sweet-monads/maybe';
import { NameResolver } from './names/resolver';
export type stage = 'loading' | 'parsing' | 'typechecking' | 'testing' | 'running' | 'compiling' | 'outputting target' | 'documentation';
/** The data from a ProcedureStage that may be output to --out */
interface OutputStage {
stage: stage;
modules?: QuintModule[];
table?: LookupTable;
types?: Map<bigint, TypeScheme>;
effects?: Map<bigint, EffectScheme>;
modes?: Map<bigint, OpQualifier>;
passed?: string[];
failed?: string[];
ignored?: string[];
status?: 'ok' | 'violation' | 'failure' | 'error';
trace?: QuintEx[];
seed?: bigint;
documentation?: Map<string, Map<string, DocumentationEntry>>;
errors?: ErrorMessage[];
warnings?: any[];
sourceCode?: Map<string, string>;
main?: string;
}
export interface ProcedureStage extends OutputStage {
args: any;
}
export interface LoadedStage extends ProcedureStage {
path: string;
sourceCode: Map<string, string>;
}
export interface ParsedStage extends LoadedStage {
modules: QuintModule[];
defaultModuleName: Maybe<string>;
sourceMap: SourceMap;
table: LookupTable;
resolver: NameResolver;
idGen: IdGenerator;
}
export interface TypecheckedStage extends ParsedStage {
types: Map<bigint, TypeScheme>;
effects: Map<bigint, EffectScheme>;
modes: Map<bigint, OpQualifier>;
}
export interface CompiledStage extends TypecheckedStage, AnalysisOutput {
mainModule: QuintModule;
}
export interface TestedStage extends LoadedStage {
passed: string[];
failed: string[];
ignored: string[];
}
export interface TracingStage extends LoadedStage {
trace?: QuintEx[];
}
export interface DocumentationStage extends LoadedStage {
documentation?: Map<string, Map<string, DocumentationEntry>>;
}
export interface ErrorData extends ProcedureStage {
errors: ErrorMessage[];
sourceCode: Map<string, string>;
}
export type ErrResult = {
msg: string;
stage: ErrorData;
};
export type CLIProcedure<Stage> = Either<ErrResult, Stage>;
/** Load a file into a string
*
* @param args the CLI arguments parsed by yargs */
export declare function load(args: any): Promise<CLIProcedure<LoadedStage>>;
/**
* Parse a Quint specification.
*
* @param loaded the procedure stage produced by `load`
*/
export declare function parse(loaded: LoadedStage): Promise<CLIProcedure<ParsedStage>>;
/**
* Check types and effects of a Quint specification.
*
* @param parsed the procedure stage produced by `parse`
*/
export declare function typecheck(parsed: ParsedStage): Promise<CLIProcedure<TypecheckedStage>>;
/**
* Run REPL.
*
* @param argv parameters as provided by yargs
*/
export declare function runRepl(argv: any): Promise<void>;
/**
* Run the tests. We imitate the output of mocha.
*
* @param typedStage the procedure stage produced by `typecheck`
*/
/**
* Main function to run tests.
*/
export declare function runTests(prev: TypecheckedStage): Promise<CLIProcedure<TestedStage>>;
/**
* Run the simulator.
*
* @param prev the procedure stage produced by `typecheck`
*/
export declare function runSimulator(prev: TypecheckedStage): Promise<CLIProcedure<TracingStage>>;
/** Compile to a flattened module, that includes the special q::* declarations
*
* @param typechecked the output of a preceding type checking stage
*/
export declare function compile(typechecked: TypecheckedStage): Promise<CLIProcedure<CompiledStage>>;
/**
* Verify a spec via Apalache.
*
* @param prev the procedure stage produced by `typecheck`
*/
export declare function verifySpec(prev: CompiledStage): Promise<CLIProcedure<TracingStage>>;
/** output a compiled spec in the format specified in the `compiled.args.target` to stdout
*
* @param compiled The result of a preceding compile stage
*/
export declare function outputCompilationTarget(compiled: CompiledStage): Promise<CLIProcedure<CompiledStage>>;
/** Write the OutputStage of the procedureStage as JSON, if --out is set
* Otherwise, report any stage errors to STDOUT
*/
export declare function outputResult(result: CLIProcedure<ProcedureStage>): void;
/**
* Produces documentation from docstrings in a Quint specification.
*
* @param loaded the procedure stage produced by `load`
*/
export declare function docs(loaded: LoadedStage): Promise<CLIProcedure<DocumentationStage>>;
export {};