@runtimeverificationinc/tsk
Version:
TypeScript/JavaScript library for K Framework functionality
428 lines (427 loc) • 15.3 kB
TypeScript
import type { FrozenRecord } from "../utils";
import { Format, KAtt, type WithKAtt } from "./att";
import { KInner, KLabel, KSort, KToken } from "./inner";
import { KAst } from "./kast";
declare const BOOL: KSort;
declare const TRUE: KToken;
export { BOOL, TRUE };
export declare abstract class KOuter extends KAst {
}
export declare abstract class KProductionItem extends KOuter {
/**
* Represents the elements used to declare components of productions in EBNF style.
*/
private static readonly NODES;
static fromDict(d: Record<string, any>): KProductionItem;
}
export declare class KRegexTerminal extends KProductionItem {
/**
* Represents a regular-expression terminal in EBNF production, to be matched against input text.
*/
readonly regex: string;
constructor(regex: string);
static _fromDict(d: Record<string, any>): KRegexTerminal;
toDict(): Record<string, any>;
let(options?: {
regex?: string;
}): KRegexTerminal;
protected fieldEquals(other: KAst): boolean;
}
export declare class KNonTerminal extends KProductionItem {
/**
* Represents a non-terminal of a given sort in EBNF productions, for defining arguments to production.
*/
readonly sort: KSort;
readonly name: string | null;
constructor(sort: KSort, name?: string | null);
static _fromDict(d: Record<string, any>): KNonTerminal;
toDict(): Record<string, any>;
let(options?: {
sort?: KSort;
name?: string | null;
}): KNonTerminal;
protected fieldEquals(other: KAst): boolean;
}
export declare class KTerminal extends KProductionItem {
/**
* Represents a string literal component of a production in EBNF grammar.
*/
readonly value: string;
constructor(value: string);
static _fromDict(d: Record<string, any>): KTerminal;
toDict(): Record<string, any>;
let(options?: {
value?: string;
}): KTerminal;
protected fieldEquals(other: KAst): boolean;
}
export declare abstract class KSentence extends KOuter implements WithKAtt {
/**
* Represents an individual declaration in a K module.
*/
private static readonly NODES;
abstract get att(): KAtt;
abstract letAtt(att: KAtt): KSentence;
static fromDict(d: Record<string, any>): KSentence;
get uniqueId(): string | null;
get source(): string | null;
get label(): string;
}
export declare class KProduction extends KSentence {
/**
* Represents a production in K's EBNF grammar definitions, as a sequence of ProductionItem.
*/
readonly sort: KSort;
readonly items: KProductionItem[];
readonly params: KSort[];
readonly klabel: KLabel | null;
readonly att: KAtt;
constructor(sort: string | KSort, items?: Iterable<KProductionItem>, params?: Iterable<string | KSort>, klabel?: string | KLabel | null, att?: KAtt);
static _fromDict(d: Record<string, any>): KProduction;
toDict(): Record<string, any>;
let(options?: {
sort?: string | KSort;
items?: Iterable<KProductionItem>;
params?: Iterable<string | KSort>;
klabel?: string | KLabel | null;
att?: KAtt;
}): KProduction;
letAtt(att: KAtt): KProduction;
get asSubsort(): [KSort, KSort] | null;
get nonTerminals(): KNonTerminal[];
get argumentSorts(): KSort[];
get isPrefix(): boolean;
get isRecord(): boolean;
get defaultFormat(): Format;
protected fieldEquals(other: KAst): boolean;
}
export declare class KSyntaxSort extends KSentence {
/**
* Represents a sort declaration, potentially parametric.
*/
readonly sort: KSort;
readonly params: KSort[];
readonly att: KAtt;
constructor(sort: KSort, params?: Iterable<string | KSort>, att?: KAtt);
static _fromDict(d: Record<string, any>): KSyntaxSort;
toDict(): Record<string, any>;
let(options?: {
sort?: KSort;
params?: Iterable<string | KSort>;
att?: KAtt;
}): KSyntaxSort;
letAtt(att: KAtt): KSyntaxSort;
protected fieldEquals(other: KAst): boolean;
}
export declare class KSortSynonym extends KSentence {
/**
* Represents a sort synonym, allowing declaring a new name for a given sort.
*/
readonly newSort: KSort;
readonly oldSort: KSort;
readonly att: KAtt;
constructor(newSort: KSort, oldSort: KSort, att?: KAtt);
static _fromDict(d: Record<string, any>): KSortSynonym;
toDict(): Record<string, any>;
let(options?: {
oldSort?: KSort;
newSort?: KSort;
att?: KAtt;
}): KSortSynonym;
letAtt(att: KAtt): KSortSynonym;
protected fieldEquals(other: KAst): boolean;
}
export declare class KSyntaxLexical extends KSentence {
/**
* Represents a named piece of lexical syntax, definable as a regular expression.
*/
readonly name: string;
readonly regex: string;
readonly att: KAtt;
constructor(name: string, regex: string, att?: KAtt);
static _fromDict(d: Record<string, any>): KSyntaxLexical;
toDict(): Record<string, any>;
let(options?: {
name?: string;
regex?: string;
att?: KAtt;
}): KSyntaxLexical;
letAtt(att: KAtt): KSyntaxLexical;
protected fieldEquals(other: KAst): boolean;
}
export declare enum KAssoc {
LEFT = "Left",
RIGHT = "Right",
NON_ASSOC = "NonAssoc"
}
export declare class KSyntaxAssociativity extends KSentence {
/**
* Represents a standalone declaration of operator associativity for tagged productions.
*/
readonly assoc: KAssoc;
readonly tags: Set<string>;
readonly att: KAtt;
constructor(assoc: KAssoc, tags?: Iterable<string>, att?: KAtt);
static _fromDict(d: Record<string, any>): KSyntaxAssociativity;
toDict(): Record<string, any>;
let(options?: {
assoc?: KAssoc;
tags?: Iterable<string>;
att?: KAtt;
}): KSyntaxAssociativity;
letAtt(att: KAtt): KSyntaxAssociativity;
protected fieldEquals(other: KAst): boolean;
}
export declare class KSyntaxPriority extends KSentence {
/**
* Represents a standalone declaration of syntax priorities, using productions tags.
*/
readonly priorities: Set<string>[];
readonly att: KAtt;
constructor(priorities?: Iterable<Iterable<string>>, att?: KAtt);
static _fromDict(d: Record<string, any>): KSyntaxPriority;
toDict(): Record<string, any>;
let(options?: {
priorities?: Iterable<Iterable<string>>;
att?: KAtt;
}): KSyntaxPriority;
letAtt(att: KAtt): KSyntaxPriority;
protected fieldEquals(other: KAst): boolean;
}
export declare class KBubble extends KSentence {
/**
* Represents an unparsed chunk of AST in user-defined syntax.
*/
readonly sentenceType: string;
readonly contents: string;
readonly att: KAtt;
constructor(sentenceType: string, contents: string, att?: KAtt);
static _fromDict(d: Record<string, any>): KBubble;
toDict(): Record<string, any>;
let(options?: {
sentenceType?: string;
contents?: string;
att?: KAtt;
}): KBubble;
letAtt(att: KAtt): KBubble;
protected fieldEquals(other: KAst): boolean;
}
export declare abstract class KRuleLike extends KSentence {
/**
* Represents something with rule-like structure (with body, requires, and ensures clauses).
*/
abstract readonly body: KInner;
abstract readonly requires: KInner;
abstract readonly ensures: KInner;
abstract let(options: {
body?: KInner;
requires?: KInner;
ensures?: KInner;
att?: KAtt;
}): KRuleLike;
}
export declare class KRule extends KRuleLike {
/**
* Represents a K rule definition, typically a conditional rewrite/transition.
*/
readonly body: KInner;
readonly requires: KInner;
readonly ensures: KInner;
readonly att: KAtt;
constructor(body: KInner, requires?: KInner, ensures?: KInner, att?: KAtt);
static _fromDict(d: Record<string, any>): KRule;
toDict(): Record<string, any>;
let(options?: {
body?: KInner;
requires?: KInner;
ensures?: KInner;
att?: KAtt;
}): KRule;
letAtt(att: KAtt): KRule;
get priority(): number;
protected fieldEquals(other: KAst): boolean;
}
export declare class KClaim extends KRuleLike {
/**
* Represents a K claim, typically a transition with pre/post-conditions.
*/
readonly body: KInner;
readonly requires: KInner;
readonly ensures: KInner;
readonly att: KAtt;
constructor(body: KInner, requires?: KInner, ensures?: KInner, att?: KAtt);
static _fromDict(d: Record<string, any>): KClaim;
toDict(): Record<string, any>;
let(options?: {
body?: KInner;
requires?: KInner;
ensures?: KInner;
att?: KAtt;
}): KClaim;
letAtt(att: KAtt): KClaim;
get isCircularity(): boolean;
get isTrusted(): boolean;
get dependencies(): string[];
protected fieldEquals(other: KAst): boolean;
}
export declare class KContext extends KSentence {
/**
* Represents a K evaluation context, used for isolating chunks of computation and focusing on them.
*/
readonly body: KInner;
readonly requires: KInner;
readonly att: KAtt;
constructor(body: KInner, requires?: KInner, att?: KAtt);
static _fromDict(d: Record<string, any>): KContext;
toDict(): Record<string, any>;
let(options?: {
body?: KInner;
requires?: KInner;
att?: KAtt;
}): KContext;
letAtt(att: KAtt): KContext;
protected fieldEquals(other: KAst): boolean;
}
export declare class KImport extends KOuter {
/**
* Represents a K module import, used for inheriting all the sentences of the imported module into this one.
*/
readonly name: string;
readonly public: boolean;
constructor(name: string, isPublic?: boolean);
static fromDict(d: Record<string, any>): KImport;
toDict(): Record<string, any>;
let(options?: {
name?: string;
public?: boolean;
}): KImport;
protected fieldEquals(other: KAst): boolean;
}
export declare class KFlatModule extends KOuter implements WithKAtt, Iterable<KSentence> {
/**
* Represents a K module, with a name, list of imports, and list of sentences.
*/
readonly name: string;
readonly sentences: KSentence[];
readonly imports: KImport[];
readonly att: KAtt;
constructor(name: string, sentences?: Iterable<KSentence>, imports?: Iterable<KImport>, att?: KAtt);
[Symbol.iterator](): Iterator<KSentence>;
get productions(): KProduction[];
get syntaxProductions(): KProduction[];
get functions(): KProduction[];
get constructors(): KProduction[];
get cellCollectionProductions(): KProduction[];
private static isFunction;
get syntaxSorts(): KSyntaxSort[];
get rules(): KRule[];
get claims(): KClaim[];
get sentenceByUniqueId(): Record<string, KSentence>;
mapSentences<T extends KSentence>(f: (sent: KSentence) => KSentence, ofType?: new (...args: any[]) => T): KFlatModule;
static fromDict(d: Record<string, any>): KFlatModule;
toDict(): Record<string, any>;
let(options?: {
name?: string;
sentences?: Iterable<KSentence>;
imports?: Iterable<KImport>;
att?: KAtt;
}): KFlatModule;
letAtt(att: KAtt): KFlatModule;
protected fieldEquals(other: KAst): boolean;
}
export declare class KFlatModuleList extends KOuter {
/**
* Represents a list of K modules, as returned by the prover parser for example, with a given module called out as the main module.
*/
readonly mainModule: string;
readonly modules: KFlatModule[];
constructor(mainModule: string, modules: Iterable<KFlatModule>);
static fromDict(d: Record<string, any>): KFlatModuleList;
toDict(): Record<string, any>;
let(options?: {
mainModule?: string;
modules?: Iterable<KFlatModule>;
}): KFlatModuleList;
protected fieldEquals(other: KAst): boolean;
}
export declare class KRequire extends KOuter {
/**
* Represents a K file import of another file.
*/
readonly require: string;
constructor(requirePath: string);
static fromDict(d: Record<string, any>): KRequire;
toDict(): Record<string, any>;
let(options?: {
require?: string;
}): KRequire;
protected fieldEquals(other: KAst): boolean;
}
export declare class KDefinition extends KOuter implements WithKAtt, Iterable<KFlatModule> {
/**
* Represents an entire K definition, with file imports and modules in place,
* and a given module called out as main module.
*/
readonly mainModuleName: string;
readonly allModules: KFlatModule[];
readonly requires: KRequire[];
readonly att: KAtt;
readonly mainModule: KFlatModule;
private _initConfig;
private _emptyConfig;
constructor(mainModuleName: string, allModules: Iterable<KFlatModule>, requires?: Iterable<KRequire>, att?: KAtt);
[Symbol.iterator](): Iterator<KFlatModule>;
static fromDict(d: Record<string, any>): KDefinition;
toDict(): Record<string, any>;
protected fieldEquals(other: KAst): boolean;
let(options?: {
mainModuleName?: string;
allModules?: Iterable<KFlatModule>;
requires?: Iterable<KRequire>;
att?: KAtt;
}): KDefinition;
letAtt(att: KAtt): KDefinition;
get allModuleNames(): string[];
get moduleNames(): string[];
get allModulesDict(): Record<string, KFlatModule>;
get modules(): KFlatModule[];
get productions(): KProduction[];
get syntaxProductions(): KProduction[];
get functions(): KProduction[];
get functionLabels(): string[];
get constructors(): KProduction[];
get cellCollectionProductions(): KProduction[];
get rules(): KRule[];
get aliasRules(): KRule[];
get macroRules(): KRule[];
get semanticRules(): KRule[];
get sentenceByUniqueId(): Record<string, KSentence>;
productionForCellSort(sort: KSort): KProduction;
module(name: string): KFlatModule;
get overloads(): FrozenRecord<Set<string>>;
get priorities(): FrozenRecord<Set<string>>;
get leftAssocs(): FrozenRecord<Set<string>>;
get rightAssocs(): FrozenRecord<Set<string>>;
private assocs;
get subsortTable(): FrozenRecord<Set<KSort>>;
subsorts(sort: KSort): Set<KSort>;
get brackets(): FrozenRecord<KProduction>;
get symbols(): FrozenRecord<KProduction>;
get syntaxSymbols(): FrozenRecord<KProduction>;
sort(kast: KInner): KSort | null;
sortStrict(kast: KInner): KSort;
resolveSorts(label: KLabel): [KSort, KSort[]];
leastCommonSupersort(sort1: KSort, sort2: KSort): KSort | null;
greatestCommonSubsort(sort1: KSort, sort2: KSort): KSort | null;
addKSequenceUnderKProductions(kast: KInner): KInner;
sortVars(kast: KInner, sort?: KSort): KInner;
addSortParams(kast: KInner): KInner;
addCellMapItems(kast: KInner): KInner;
removeCellMapItems(kast: KInner): KInner;
emptyConfig(sort: KSort): KInner;
private computeEmptyConfig;
instantiateCellVars(term: KInner): KInner;
initConfig(sort: KSort): KInner;
private computeInitConfig;
}
export declare function readKastDefinition(path: string): KDefinition;