@profile-psl/psl-parser 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,93 @@
1
+ import { Token } from "./tokenizer";
2
+ export declare enum SyntaxKind {
3
+ ASSIGNMENT = 0,
4
+ BINARY_OPERATOR = 1,
5
+ CATCH_STATEMENT = 2,
6
+ DO_STATEMENT = 3,
7
+ FOR_STATEMENT = 4,
8
+ IDENTIFIER = 5,
9
+ IF_STATEMENT = 6,
10
+ NUMERIC_LITERAL = 7,
11
+ POST_CONDITION = 8,
12
+ QUIT_STATEMENT = 9,
13
+ RETURN_STATEMENT = 10,
14
+ SET_STATEMENT = 11,
15
+ MULTIPLE_VARIABLE_SET = 12,
16
+ STRING_LITERAL = 13,
17
+ WHILE_STATEMENT = 14,
18
+ TYPE_STATEMENT = 15,
19
+ VARIABLE_DECLARATION = 16,
20
+ TYPE_IDENTIFIER = 17
21
+ }
22
+ export interface Node {
23
+ kind: SyntaxKind;
24
+ parent?: Node;
25
+ }
26
+ export interface BinaryOperator extends Node {
27
+ operator: Token[];
28
+ left?: Node;
29
+ right?: Node;
30
+ }
31
+ export interface MultiSet extends Node {
32
+ variables: Expression[];
33
+ }
34
+ export interface PostCondition extends Node {
35
+ colon: Token;
36
+ condition?: Expression;
37
+ expression?: Expression | MultiSet;
38
+ }
39
+ export type Expression = Value | BinaryOperator | PostCondition | MultiSet;
40
+ export interface Statement extends Node {
41
+ action: Token;
42
+ expressions: Expression[];
43
+ block?: Node;
44
+ }
45
+ export interface Value extends Node {
46
+ id: Token;
47
+ unaryOperator?: Token[];
48
+ }
49
+ export type NumericLiteral = Value;
50
+ export interface StringLiteral extends Value {
51
+ openQuote: Token;
52
+ closeQuote: Token;
53
+ }
54
+ export interface Identifier extends Value {
55
+ args?: Expression[];
56
+ openParen?: Token;
57
+ closeParen?: Token;
58
+ }
59
+ export interface DeclarationStatement extends Identifier {
60
+ type: TypeIdentifier;
61
+ staticToken?: Token;
62
+ newToken?: Token;
63
+ publicToken?: Token;
64
+ literalToken?: Token;
65
+ }
66
+ export type TypeIdentifier = Identifier;
67
+ export declare class StatementParser {
68
+ tokenizer: IterableIterator<Token>;
69
+ tokens: Token[];
70
+ previousToken: Token | undefined;
71
+ activeToken: Token | undefined;
72
+ constructor(arg: string | IterableIterator<Token> | Token[]);
73
+ parseLine(): Statement[];
74
+ parseStatement(): Statement;
75
+ parseTypeStatement(): Statement;
76
+ parseAssignment(getLeft: () => Expression | MultiSet | DeclarationStatement): Expression;
77
+ parseForStatement(): Statement;
78
+ parseSetExpression(): Expression;
79
+ parsePostCondition(): PostCondition;
80
+ parseSetVariables(): Expression;
81
+ parseExpression(ignoreEquals?: boolean, includeRet?: boolean): Expression;
82
+ parseColonSeparatedValues(rootNode: Expression): Expression;
83
+ parseOperatorSeparatedValues(rootNode: Expression, ignoreEquals?: boolean): Expression;
84
+ parseBinaryOperator(): BinaryOperator;
85
+ parseUnaryOperator(includeRet?: boolean): Token[];
86
+ parseValue(tree?: BinaryOperator, includeRet?: boolean): Value | Expression;
87
+ parseIdentifier(): Identifier | undefined;
88
+ parseStringLiteral(): StringLiteral;
89
+ parseArgs(): Expression[];
90
+ loadCommaSeparated<T>(getArg: () => T | T[] | undefined): T[];
91
+ private next;
92
+ }
93
+ export declare function forEachChild(node: Node, f: (n: Node) => boolean): void;