UNPKG

expression-language.js

Version:

An engine for javascript that can compile and evaluate expressions written in typescript

89 lines 1.97 kB
import Position from "./position"; export declare const enum TokenType { T_EOF = 0, T_STR = 1, T_NUM = 2, T_ID = 3, T_ADD = 4, T_SUB = 5, T_MUL = 6, T_DIV = 7, T_MOD = 8, T_AMP = 9, T_PIPE = 10, T_XOR = 11, T_SHL = 12, T_SHR = 13, T_INC = 14, T_DEC = 15, T_NOT = 16, T_NEQ = 17, T_STRICT_NEQ = 18, T_AND = 19, T_OR = 20, T_ASSIGN = 21, T_GT = 22, T_GE = 23, T_LT = 24, T_LE = 25, T_EQ = 26, T_STRICT_EQ = 27, T_LPAREN = 28, T_LBRACKET = 29, T_LBRACE = 30, T_RPAREN = 31, T_RBRACKET = 32, T_RBRACE = 33, T_COMMA = 34, T_COLON = 35, T_SEMICOLON = 36, T_DOT = 37, T_QUESTION = 38, T_KW_BEGIN = 39, T_KW_NOT = 40, T_KW_OR = 41, T_KW_AND = 42, T_KW_IN = 43, T_KW_IS = 44, T_KW_END = 45 } export declare const Tokens: { [key: number]: string; }; declare const enum OperatorAssociativity { Left = 1, Right = 2 } interface OperatorPrecedence { precedence: number; associativity?: OperatorAssociativity; } export declare const Keyword: { lookup: (identifier: string) => TokenType; isKeyword(type: TokenType): boolean; }; export declare class Token { readonly type: TokenType; readonly value: string; readonly position: Position; constructor(type: TokenType, value: string, position: Position); test(type: TokenType): boolean; testAny(...types: TokenType[]): boolean; isBinaryOperator(): boolean; getBinaryPrecedence(): OperatorPrecedence; } export declare class TokenStream { private index; private readonly tokens; constructor(); add(token: Token): void; current(): Token; next(): Token; look(number?: number): Token; count(): number; expect(type: TokenType, message?: string): Token; expectOneOf(...types: TokenType[]): Token; eof(): boolean; } export {}; //# sourceMappingURL=token.d.ts.map