1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import * as ast from "./ast";
|
9 | export declare type Expression = ast.Identifier | IntLiteral | StringLiteral | CharLiteral | ast.BoolLiteral | ast.NullLiteral | ArrayMemberExpression | StructMemberExpression | CallExpression | IndirectCallExpression | CastExpression | UnaryExpression | BinaryExpression | LogicalExpression | ConditionalExpression | AllocExpression | AllocArrayExpression | ResultExpression | LengthExpression | HasTagExpression | AssignmentExpression | UpdateExpression | AssertExpression | ErrorExpression;
|
10 | export interface IntLiteral extends ast.Syn {
|
11 | readonly tag: "IntLiteral";
|
12 | readonly raw: string;
|
13 | }
|
14 | export interface StringLiteral extends ast.Syn {
|
15 | readonly tag: "StringLiteral";
|
16 | readonly raw: string[];
|
17 | }
|
18 | export interface CharLiteral extends ast.Syn {
|
19 | readonly tag: "CharLiteral";
|
20 | readonly raw: string;
|
21 | }
|
22 | export interface ArrayMemberExpression extends ast.Syn {
|
23 | readonly tag: "ArrayMemberExpression";
|
24 | readonly object: Expression;
|
25 | readonly index: Expression;
|
26 | }
|
27 | export interface StructMemberExpression extends ast.Syn {
|
28 | readonly tag: "StructMemberExpression";
|
29 | readonly deref: boolean;
|
30 | readonly object: Expression;
|
31 | readonly field: ast.Identifier;
|
32 | }
|
33 | export interface CallExpression extends ast.Syn {
|
34 | readonly tag: "CallExpression";
|
35 | readonly callee: ast.Identifier;
|
36 | readonly arguments: Expression[];
|
37 | }
|
38 | export interface IndirectCallExpression extends ast.Syn {
|
39 | readonly tag: "IndirectCallExpression";
|
40 | readonly callee: Expression;
|
41 | readonly arguments: Expression[];
|
42 | }
|
43 | export interface CastExpression extends ast.Syn {
|
44 | readonly tag: "CastExpression";
|
45 | readonly kind: ast.Type;
|
46 | readonly argument: Expression;
|
47 | }
|
48 | export interface UnaryExpression extends ast.Syn {
|
49 | readonly tag: "UnaryExpression";
|
50 | readonly operator: "&" | "!" | "~" | "-" | "*";
|
51 | readonly argument: Expression;
|
52 | }
|
53 |
|
54 |
|
55 |
|
56 | export interface BinaryExpression extends ast.Syn {
|
57 | readonly tag: "BinaryExpression";
|
58 | readonly operator: "*" | "/" | "%" | "+" | "-" | "<<" | ">>" | "<" | "<=" | ">=" | ">" | "==" | "!=" | "&" | "^" | "|";
|
59 | readonly left: Expression;
|
60 | readonly right: Expression;
|
61 | }
|
62 | export interface LogicalExpression extends ast.Syn {
|
63 | readonly tag: "LogicalExpression";
|
64 | readonly operator: "||" | "&&";
|
65 | readonly left: Expression;
|
66 | readonly right: Expression;
|
67 | }
|
68 | export interface ConditionalExpression extends ast.Syn {
|
69 | readonly tag: "ConditionalExpression";
|
70 | readonly test: Expression;
|
71 | readonly consequent: Expression;
|
72 | readonly alternate: Expression;
|
73 | }
|
74 | export interface AllocExpression extends ast.Syn {
|
75 | readonly tag: "AllocExpression";
|
76 | readonly kind: ast.Type;
|
77 | }
|
78 | export interface AllocArrayExpression extends ast.Syn {
|
79 | readonly tag: "AllocArrayExpression";
|
80 | readonly kind: ast.Type;
|
81 | readonly size: Expression;
|
82 | }
|
83 | export interface ResultExpression extends ast.Syn {
|
84 | readonly tag: "ResultExpression";
|
85 | }
|
86 | export interface LengthExpression extends ast.Syn {
|
87 | readonly tag: "LengthExpression";
|
88 | readonly argument: Expression;
|
89 | }
|
90 | export interface HasTagExpression extends ast.Syn {
|
91 | readonly tag: "HasTagExpression";
|
92 | readonly kind: ast.Type;
|
93 | readonly argument: Expression;
|
94 | }
|
95 | export interface AssignmentExpression extends ast.Syn {
|
96 | readonly tag: "AssignmentExpression";
|
97 | readonly operator: "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | "&=" | "^=" | "|=";
|
98 | readonly left: Expression;
|
99 | readonly right: Expression;
|
100 | }
|
101 | export interface UpdateExpression extends ast.Syn {
|
102 | readonly tag: "UpdateExpression";
|
103 | readonly operator: "++" | "--";
|
104 | readonly argument: Expression;
|
105 | }
|
106 | export interface AssertExpression extends ast.Syn {
|
107 | readonly tag: "AssertExpression";
|
108 | readonly test: Expression;
|
109 | }
|
110 | export interface ErrorExpression extends ast.Syn {
|
111 | readonly tag: "ErrorExpression";
|
112 | readonly argument: Expression;
|
113 | }
|
114 | export declare type Statement = AnnoStatement | ExpressionStatement | VariableDeclaration | IfStatement | WhileStatement | ForStatement | ReturnStatement | BlockStatement | ast.BreakStatement | ast.ContinueStatement;
|
115 | export interface Anno {
|
116 | readonly tag: "requires" | "ensures" | "loop_invariant" | "assert";
|
117 | readonly test: Expression;
|
118 | }
|
119 | export interface AnnoStatement extends ast.Syn {
|
120 | readonly tag: "AnnoStatement";
|
121 | readonly anno: Anno;
|
122 | }
|
123 | export interface ExpressionStatement extends ast.Syn {
|
124 | readonly tag: "ExpressionStatement";
|
125 | readonly expression: Expression;
|
126 | }
|
127 | export interface VariableDeclaration extends ast.Syn {
|
128 | readonly tag: "VariableDeclaration";
|
129 | readonly kind: ast.Type;
|
130 | readonly id: ast.Identifier;
|
131 | readonly init: Expression | null;
|
132 | }
|
133 | export interface IfStatement extends ast.Syn {
|
134 | readonly tag: "IfStatement";
|
135 | readonly test: Expression;
|
136 | readonly consequent: [Anno[], Statement];
|
137 | readonly alternate?: [Anno[], Statement];
|
138 | }
|
139 | export interface WhileStatement extends ast.Syn {
|
140 | readonly tag: "WhileStatement";
|
141 | readonly test: Expression;
|
142 | readonly annos: Anno[];
|
143 | readonly body: Statement;
|
144 | }
|
145 | export interface ForStatement extends ast.Syn {
|
146 | readonly tag: "ForStatement";
|
147 | readonly init: VariableDeclaration | ExpressionStatement | null;
|
148 | readonly test: Expression;
|
149 | readonly update: Expression | null;
|
150 | readonly annos: Anno[];
|
151 | readonly body: Statement;
|
152 | }
|
153 | export interface ReturnStatement extends ast.Syn {
|
154 | readonly tag: "ReturnStatement";
|
155 | readonly argument: Expression | null;
|
156 | }
|
157 | export interface BlockStatement extends ast.Syn {
|
158 | readonly tag: "BlockStatement";
|
159 | readonly body: Statement[];
|
160 | }
|
161 | export declare type Declaration = FunctionDeclaration | BlockStatement;
|
162 | export interface VariableDeclarationOnly extends ast.Syn {
|
163 | readonly kind: ast.Type;
|
164 | readonly id: ast.Identifier;
|
165 | }
|
166 | export interface FunctionDeclaration extends ast.Syn {
|
167 | readonly tag: "FunctionDeclaration";
|
168 | readonly returns: ast.Type;
|
169 | readonly id: ast.Identifier;
|
170 | readonly params: ast.VariableDeclarationOnly[];
|
171 | readonly annos: Anno[];
|
172 | readonly body: null | BlockStatement;
|
173 | }
|