motoko
Version:
Compile and run Motoko smart contracts in Node.js or the browser.
51 lines • 1.73 kB
TypeScript
export type CompilerAST = CompilerAST[] | CompilerNode | string | null;
export type CompilerSpan = {
name: 'Pos';
args: [string, string, string];
};
/** Opaque expression object from the Motoko compiler - do not construct manually */
export type RawExp = unknown & {
readonly __brand: 'RawExp';
};
/** Opaque scope object from the Motoko compiler - do not construct manually */
export type RawScope = unknown & {
readonly __brand: 'RawScope';
};
export interface CompilerNode {
name: string;
args: CompilerAST[];
rawExp?: RawExp;
}
export type Span = [number, number];
export type AST = AST[] | Node | string | null;
export interface Source {
file: string;
start: Span;
end: Span;
}
export interface Node extends Partial<Source> {
parent?: Node | undefined;
name: string;
type?: string;
typeRep?: Node;
doc?: string;
declaration?: Source;
args?: AST[];
}
/**
* Retrieves the raw expression from a node (internal use only).
*/
export declare function getRawExp(node: Node): RawExp | undefined;
/**
* Attaches a raw scope to a root node (internal use only).
*/
export declare function setRootScope(node: Node, scope: RawScope): void;
/**
* Retrieves the raw scope directly from a node (internal use only).
*/
export declare function getScope(ast: AST): RawScope | undefined;
export declare function asNode(ast: AST | undefined): Node | undefined;
export declare function simplifyAST(ast: CompilerNode, parent?: Node | undefined): Node;
export declare function simplifyAST(ast: CompilerAST[], parent?: Node | undefined): AST[];
export declare function simplifyAST<T extends CompilerAST>(ast: T, parent?: Node | undefined): T;
//# sourceMappingURL=ast.d.ts.map