UNPKG

@runtimeverificationinc/tsk

Version:

TypeScript/JavaScript library for K Framework functionality

207 lines (206 loc) 7.93 kB
import type { FrozenRecord } from "../utils"; import { Color } from "./color"; import { KAst } from "./kast"; export type AttValue = any; export declare abstract class AttType<T> { abstract fromDict(obj: any): T; abstract toDict(value: T): any; abstract unparse(value: T): string | null; abstract parse(text: string): T; } export declare class NoneType extends AttType<null> { fromDict(obj: any): null; toDict(value: null): string; unparse(value: null): null; parse(text: string): null; } export declare class OptionalType<T> extends AttType<T | null> { private valueType; constructor(valueType: AttType<T>); fromDict(obj: any): T | null; toDict(value: T | null): any; unparse(value: T | null): string | null; parse(text: string): T | null; } export declare class AnyType extends AttType<any> { fromDict(obj: any): any; toDict(value: any): any; unparse(value: any): string; parse(text: string): any; private freeze; private unfreeze; } export declare class IntType extends AttType<number> { fromDict(obj: any): number; toDict(value: number): string; unparse(value: number): string; parse(text: string): number; } export declare class StrType extends AttType<string> { fromDict(obj: any): string; toDict(value: string): string; unparse(value: string): string; parse(text: string): string; } export declare class LocationType extends AttType<[number, number, number, number]> { private static readonly PARSE_REGEX; fromDict(obj: any): [number, number, number, number]; toDict(value: [number, number, number, number]): number[]; unparse(value: [number, number, number, number]): string; parse(text: string): [number, number, number, number]; } export declare class PathType extends AttType<string> { fromDict(obj: any): string; toDict(value: string): string; unparse(value: string): string; parse(text: string): string; } export declare class Format { readonly tokens: string[]; private static readonly PATTERN; constructor(tokens?: Iterable<string>); static parse(s: string): Format; unparse(): string; } export declare class FormatType extends AttType<Format> { fromDict(obj: any): Format; toDict(value: Format): string; unparse(value: Format): string; parse(text: string): Format; } export declare class ColorType extends AttType<Color> { fromDict(obj: any): Color; toDict(value: Color): string; unparse(value: Color): string; parse(text: string): Color; } export declare class ColorsType extends AttType<Color[]> { fromDict(obj: any): Color[]; toDict(value: Color[]): string; unparse(value: Color[]): string; parse(text: string): Color[]; } export declare class AttKey<T = any> { readonly name: string; readonly type: AttType<T>; constructor(name: string, type?: AttType<T>); call(value: T): AttEntry<T>; } export declare class AttEntry<T = any> { readonly key: AttKey<T>; readonly value: T; constructor(key: AttKey<T>, value: T); } export declare class Atts { static readonly ALIAS: AttKey<null>; static readonly ALIAS_REC: AttKey<null>; static readonly ANYWHERE: AttKey<null>; static readonly ASSOC: AttKey<null>; static readonly AVOID: AttKey<null>; static readonly BRACKET: AttKey<null>; static readonly BRACKET_LABEL: AttKey<any>; static readonly CIRCULARITY: AttKey<null>; static readonly CELL: AttKey<null>; static readonly CELL_COLLECTION: AttKey<null>; static readonly CELL_FRAGMENT: AttKey<any>; static readonly CELL_NAME: AttKey<string>; static readonly CELL_OPT_ABSENT: AttKey<any>; static readonly COLOR: AttKey<Color>; static readonly COLORS: AttKey<Color[]>; static readonly COMM: AttKey<null>; static readonly CONCAT: AttKey<any>; static readonly CONCRETE: AttKey<string | null>; static readonly CONSTRUCTOR: AttKey<null>; static readonly DEPENDS: AttKey<any>; static readonly DIGEST: AttKey<any>; static readonly ELEMENT: AttKey<any>; static readonly EXIT: AttKey<any>; static readonly FORMAT: AttKey<Format>; static readonly FRESH_GENERATOR: AttKey<null>; static readonly FUNCTION: AttKey<null>; static readonly FUNCTIONAL: AttKey<null>; static readonly GROUP: AttKey<string>; static readonly HAS_DOMAIN_VALUES: AttKey<null>; static readonly HOOK: AttKey<any>; static readonly IDEM: AttKey<null>; static readonly IMPURE: AttKey<null>; static readonly INDEX: AttKey<number>; static readonly INITIALIZER: AttKey<null>; static readonly INJECTIVE: AttKey<null>; static readonly LABEL: AttKey<any>; static readonly LEFT: AttKey<any>; static readonly LOCATION: AttKey<[number, number, number, number]>; static readonly MACRO: AttKey<null>; static readonly MACRO_REC: AttKey<null>; static readonly MAINCELL: AttKey<null>; static readonly MULTIPLICITY: AttKey<any>; static readonly NO_EVALUATORS: AttKey<null>; static readonly OVERLOAD: AttKey<string>; static readonly OWISE: AttKey<null>; static readonly PREDICATE: AttKey<any>; static readonly PREFER: AttKey<null>; static readonly PRIORITY: AttKey<any>; static readonly PRIORITIES: AttKey<any>; static readonly PRIVATE: AttKey<null>; static readonly PRODUCTION: AttKey<any>; static readonly PROJECTION: AttKey<null>; static readonly RIGHT: AttKey<any>; static readonly RETURNS_UNIT: AttKey<null>; static readonly SIMPLIFICATION: AttKey<any>; static readonly SEQSTRICT: AttKey<any>; static readonly SORT: AttKey<any>; static readonly SOURCE: AttKey<string>; static readonly SMTLEMMA: AttKey<null>; static readonly STRICT: AttKey<any>; static readonly SYMBOL: AttKey<string>; static readonly SYNTAX_MODULE: AttKey<string>; static readonly SYMBOLIC: AttKey<string | null>; static readonly TERMINALS: AttKey<string>; static readonly TERMINATOR_SYMBOL: AttKey<any>; static readonly TOKEN: AttKey<null>; static readonly TOTAL: AttKey<null>; static readonly TRUSTED: AttKey<null>; static readonly TYPE: AttKey<any>; static readonly UNIT: AttKey<string>; static readonly UNIQUE_ID: AttKey<any>; static readonly UNPARSE_AVOID: AttKey<null>; static readonly UPDATE: AttKey<any>; static readonly USER_LIST: AttKey<any>; static readonly WRAP_ELEMENT: AttKey<any>; private static _keys; static keys(): FrozenRecord<AttKey>; } export declare class KAtt extends KAst implements Map<AttKey, any> { readonly atts: FrozenRecord<any>; private readonly keyLookup; constructor(entries?: Iterable<AttEntry>); [Symbol.toStringTag]: string; get size(): number; get(key: AttKey): any; has(key: AttKey): boolean; keys(): MapIterator<AttKey>; values(): MapIterator<any>; entries(): MapIterator<[AttKey, any]>; forEach(callbackfn: (value: any, key: AttKey, map: Map<AttKey, any>) => void, thisArg?: any): void; [Symbol.iterator](): MapIterator<[AttKey, any]>; set(key: AttKey, value: any): this; delete(key: AttKey): boolean; clear(): void; attEntries(): Generator<AttEntry>; static fromDict(d: Record<string, any>): KAtt; toDict(): Record<string, any>; static parse(d: Record<string, string>): KAtt; get pretty(): string; update(entries: Iterable<AttEntry>): KAtt; discard(keys: Set<AttKey> | AttKey[]): KAtt; dropSource(): KAtt; protected fieldEquals(other: KAst): boolean; } export declare const EMPTY_ATT: KAtt; export interface WithKAtt { readonly att: KAtt; letAtt(att: KAtt): WithKAtt; } export declare function mapAtt<T extends WithKAtt>(obj: T, f: (att: KAtt) => KAtt): T; export declare function updateAtts<T extends WithKAtt>(obj: T, entries: Iterable<AttEntry>): T; export declare function isWithKAtt(obj: any): obj is WithKAtt;