time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

peggyHelpers.d.ts (6411B)


      1 import { LocationRange } from "peggy";
      2 export declare const infixFunctions: {
      3     "+": string;
      4     "-": string;
      5     "!=": string;
      6     ".-": string;
      7     ".*": string;
      8     "./": string;
      9     ".^": string;
     10     ".+": string;
     11     "*": string;
     12     "/": string;
     13     "&&": string;
     14     "^": string;
     15     "<": string;
     16     "<=": string;
     17     "==": string;
     18     ">": string;
     19     ">=": string;
     20     "||": string;
     21     to: string;
     22 };
     23 export type InfixOperator = keyof typeof infixFunctions;
     24 export declare const unaryFunctions: {
     25     "-": string;
     26     "!": string;
     27     ".-": string;
     28 };
     29 export type UnaryOperator = keyof typeof unaryFunctions;
     30 type Node = {
     31     location: LocationRange;
     32 };
     33 type N<T extends string, V extends object> = Node & {
     34     type: T;
     35 } & V;
     36 type NodeBlock = N<"Block", {
     37     statements: ASTNode[];
     38 }>;
     39 type NodeProgram = N<"Program", {
     40     imports: [NodeString, NodeIdentifier][];
     41     statements: ASTNode[];
     42     symbols: {
     43         [k in string]: ASTNode;
     44     };
     45 }>;
     46 type NodeArray = N<"Array", {
     47     elements: ASTNode[];
     48 }>;
     49 type NodeDict = N<"Dict", {
     50     elements: AnyNodeDictEntry[];
     51     symbols: {
     52         [k in number | string]: AnyNodeDictEntry;
     53     };
     54 }>;
     55 type NodeKeyValue = N<"KeyValue", {
     56     key: ASTNode;
     57     value: ASTNode;
     58 }>;
     59 type AnyNodeDictEntry = NodeKeyValue | NodeIdentifier;
     60 type NodeUnitValue = N<"UnitValue", {
     61     value: ASTNode;
     62     unit: string;
     63 }>;
     64 type NodeCall = N<"Call", {
     65     fn: ASTNode;
     66     args: ASTNode[];
     67 }>;
     68 type NodeInfixCall = N<"InfixCall", {
     69     op: InfixOperator;
     70     args: [ASTNode, ASTNode];
     71 }>;
     72 type NodeUnaryCall = N<"UnaryCall", {
     73     op: UnaryOperator;
     74     arg: ASTNode;
     75 }>;
     76 type NodePipe = N<"Pipe", {
     77     leftArg: ASTNode;
     78     fn: ASTNode;
     79     rightArgs: ASTNode[];
     80 }>;
     81 type NodeDotLookup = N<"DotLookup", {
     82     arg: ASTNode;
     83     key: string;
     84 }>;
     85 type NodeBracketLookup = N<"BracketLookup", {
     86     arg: ASTNode;
     87     key: ASTNode;
     88 }>;
     89 type NodeFloat = N<"Float", {
     90     integer: number;
     91     fractional: string | null;
     92     exponent: number | null;
     93 }>;
     94 type NodeIdentifierWithAnnotation = N<"IdentifierWithAnnotation", {
     95     variable: string;
     96     annotation: ASTNode;
     97 }>;
     98 type NodeIdentifier = N<"Identifier", {
     99     value: string;
    100 }>;
    101 type NodeLetStatement = N<"LetStatement", {
    102     variable: NodeIdentifier;
    103     value: ASTNode;
    104     exported: boolean;
    105 }>;
    106 type NodeLambda = N<"Lambda", {
    107     args: ASTNode[];
    108     body: ASTNode;
    109     name?: string;
    110 }>;
    111 type NamedNodeLambda = NodeLambda & Required<Pick<NodeLambda, "name">>;
    112 type NodeDefunStatement = N<"DefunStatement", {
    113     variable: NodeIdentifier;
    114     value: NamedNodeLambda;
    115     exported: boolean;
    116 }>;
    117 type NodeTernary = N<"Ternary", {
    118     condition: ASTNode;
    119     trueExpression: ASTNode;
    120     falseExpression: ASTNode;
    121     kind: "IfThenElse" | "C";
    122 }>;
    123 type NodeString = N<"String", {
    124     value: string;
    125 }>;
    126 type NodeBoolean = N<"Boolean", {
    127     value: boolean;
    128 }>;
    129 type NodeVoid = N<"Void", object>;
    130 export type ASTNode = NodeArray | NodeDict | NodeBlock | NodeProgram | NodeUnitValue | NodeCall | NodeInfixCall | NodeUnaryCall | NodePipe | NodeDotLookup | NodeBracketLookup | NodeFloat | NodeIdentifier | NodeIdentifierWithAnnotation | NodeLetStatement | NodeDefunStatement | NodeLambda | NodeTernary | NodeKeyValue | NodeString | NodeBoolean | NodeVoid;
    131 export declare function nodeCall(fn: ASTNode, args: ASTNode[], location: LocationRange): NodeCall;
    132 export declare function makeInfixChain(head: ASTNode, tail: [InfixOperator, ASTNode][], location: LocationRange): ASTNode;
    133 export declare function nodeInfixCall(op: InfixOperator, arg1: ASTNode, arg2: ASTNode, location: LocationRange): NodeInfixCall;
    134 export declare function nodeUnaryCall(op: UnaryOperator, arg: ASTNode, location: LocationRange): NodeUnaryCall;
    135 export declare function nodePipe(leftArg: ASTNode, fn: ASTNode, rightArgs: ASTNode[], location: LocationRange): NodePipe;
    136 export declare function nodeDotLookup(arg: ASTNode, key: string, location: LocationRange): NodeDotLookup;
    137 export declare function nodeBracketLookup(arg: ASTNode, key: ASTNode, location: LocationRange): NodeBracketLookup;
    138 export declare function nodeArray(elements: ASTNode[], location: LocationRange): NodeArray;
    139 export declare function nodeDict(elements: AnyNodeDictEntry[], location: LocationRange): NodeDict;
    140 export declare function nodeUnitValue(value: ASTNode, unit: string, location: LocationRange): NodeUnitValue;
    141 export declare function nodeBlock(statements: ASTNode[], location: LocationRange): NodeBlock;
    142 export declare function nodeProgram(imports: [NodeString, NodeIdentifier][], statements: ASTNode[], location: LocationRange): NodeProgram;
    143 export declare function nodeBoolean(value: boolean, location: LocationRange): NodeBoolean;
    144 export declare function nodeFloat(args: Omit<NodeFloat, "type" | "location">, location: LocationRange): NodeFloat;
    145 export declare function nodeIdentifier(value: string, location: LocationRange): NodeIdentifier;
    146 export declare function nodeIdentifierWithAnnotation(variable: string, annotation: ASTNode, location: LocationRange): NodeIdentifierWithAnnotation;
    147 export declare function nodeKeyValue(key: ASTNode, value: ASTNode, location: LocationRange): NodeKeyValue;
    148 export declare function nodeLambda(args: ASTNode[], body: ASTNode, location: LocationRange, name?: NodeIdentifier): NodeLambda;
    149 export declare function nodeLetStatement(variable: NodeIdentifier, value: ASTNode, exported: boolean, location: LocationRange): NodeLetStatement;
    150 export declare function nodeDefunStatement(variable: NodeIdentifier, value: NamedNodeLambda, exported: boolean, location: LocationRange): NodeDefunStatement;
    151 export declare function nodeString(value: string, location: LocationRange): NodeString;
    152 export declare function nodeTernary(condition: ASTNode, trueExpression: ASTNode, falseExpression: ASTNode, kind: NodeTernary["kind"], location: LocationRange): NodeTernary;
    153 export declare function nodeVoid(location: LocationRange): NodeVoid;
    154 export type ASTCommentNode = {
    155     type: "lineComment" | "blockComment";
    156     value: string;
    157     location: LocationRange;
    158 };
    159 export declare function lineComment(text: string, location: LocationRange): ASTCommentNode;
    160 export declare function blockComment(text: string, location: LocationRange): ASTCommentNode;
    161 export declare function parseEscapeSequence(char: string[], location: LocationRange, error: (e: any, l: LocationRange) => void): any;
    162 export {};
    163 //# sourceMappingURL=peggyHelpers.d.ts.map