khulnasoft commited on
Commit
0c77d6e
1 Parent(s): 2136b1f

Upload 26 files

Browse files
vendor/tree-sitter-ql/Cargo.toml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [package]
2
+ name = "tree-sitter-ql"
3
+ description = "ql grammar for the tree-sitter parsing library"
4
+ version = "0.19.0"
5
+ keywords = ["incremental", "parsing", "ql"]
6
+ categories = ["parsing", "text-editors"]
7
+ repository = "https://github.com/tree-sitter/tree-sitter-javascript"
8
+ edition = "2018"
9
+ license = "MIT"
10
+ authors = ["Sam Lanning <[email protected]>"]
11
+
12
+ build = "bindings/rust/build.rs"
13
+ include = [
14
+ "bindings/rust/*",
15
+ "grammar.js",
16
+ "queries/*",
17
+ "src/*",
18
+ ]
19
+
20
+ [lib]
21
+ path = "bindings/rust/lib.rs"
22
+
23
+ [dependencies]
24
+ tree-sitter = ">= 0.20, < 0.21"
25
+
26
+ [build-dependencies]
27
+ cc = "1.0"
vendor/tree-sitter-ql/README.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # tree-sitter-ql
2
+
3
+ [![Build Status](https://travis-ci.org/tree-sitter/tree-sitter-ql.svg?branch=master)](https://travis-ci.org/tree-sitter/tree-sitter-ql)
4
+
5
+ tree-sitter grammar for GitHub CodeQL ([Language Spec](https://codeql.github.com/docs/ql-language-reference/ql-language-specification/))
vendor/tree-sitter-ql/bindings/node/binding.cc ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "tree_sitter/parser.h"
2
+ #include <node.h>
3
+ #include "nan.h"
4
+
5
+ using namespace v8;
6
+
7
+ extern "C" TSLanguage * tree_sitter_ql();
8
+
9
+ namespace {
10
+
11
+ NAN_METHOD(New) {}
12
+
13
+ void Init(Local<Object> exports, Local<Object> module) {
14
+ Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
15
+ tpl->SetClassName(Nan::New("Language").ToLocalChecked());
16
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
17
+
18
+ Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
19
+ Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
20
+ Nan::SetInternalFieldPointer(instance, 0, tree_sitter_ql());
21
+
22
+ Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("ql").ToLocalChecked());
23
+ Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
24
+ }
25
+
26
+ NODE_MODULE(tree_sitter_ql_binding, Init)
27
+
28
+ } // namespace
vendor/tree-sitter-ql/bindings/node/index.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ try {
2
+ module.exports = require("../../build/Release/tree_sitter_ql_binding");
3
+ } catch (error1) {
4
+ if (error1.code !== 'MODULE_NOT_FOUND') {
5
+ throw error1;
6
+ }
7
+ try {
8
+ module.exports = require("../../build/Debug/tree_sitter_ql_binding");
9
+ } catch (error2) {
10
+ if (error2.code !== 'MODULE_NOT_FOUND') {
11
+ throw error2;
12
+ }
13
+ throw error1
14
+ }
15
+ }
16
+
17
+ try {
18
+ module.exports.nodeTypeInfo = require("../../src/node-types.json");
19
+ } catch (_) {}
vendor/tree-sitter-ql/bindings/rust/build.rs ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ fn main() {
2
+ let src_dir = std::path::Path::new("src");
3
+
4
+ let mut c_config = cc::Build::new();
5
+ c_config.include(&src_dir);
6
+ c_config
7
+ .flag_if_supported("-Wno-unused-parameter")
8
+ .flag_if_supported("-Wno-unused-but-set-variable")
9
+ .flag_if_supported("-Wno-trigraphs");
10
+ let parser_path = src_dir.join("parser.c");
11
+ c_config.file(&parser_path);
12
+
13
+ // If your language uses an external scanner written in C,
14
+ // then include this block of code:
15
+
16
+ /*
17
+ let scanner_path = src_dir.join("scanner.c");
18
+ c_config.file(&scanner_path);
19
+ println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
20
+ */
21
+
22
+ c_config.compile("parser");
23
+ println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
24
+
25
+ // If your language uses an external scanner written in C++,
26
+ // then include this block of code:
27
+
28
+ /*
29
+ let mut cpp_config = cc::Build::new();
30
+ cpp_config.cpp(true);
31
+ cpp_config.include(&src_dir);
32
+ cpp_config
33
+ .flag_if_supported("-Wno-unused-parameter")
34
+ .flag_if_supported("-Wno-unused-but-set-variable");
35
+ let scanner_path = src_dir.join("scanner.cc");
36
+ cpp_config.file(&scanner_path);
37
+ cpp_config.compile("scanner");
38
+ println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
39
+ */
40
+ }
vendor/tree-sitter-ql/bindings/rust/lib.rs ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //! This crate provides ql language support for the [tree-sitter][] parsing library.
2
+ //!
3
+ //! Typically, you will use the [language][language func] function to add this language to a
4
+ //! tree-sitter [Parser][], and then use the parser to parse some code:
5
+ //!
6
+ //! ```
7
+ //! let code = "";
8
+ //! let mut parser = tree_sitter::Parser::new();
9
+ //! parser.set_language(tree_sitter_ql::language()).expect("Error loading ql grammar");
10
+ //! let tree = parser.parse(code, None).unwrap();
11
+ //! ```
12
+ //!
13
+ //! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
14
+ //! [language func]: fn.language.html
15
+ //! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
16
+ //! [tree-sitter]: https://tree-sitter.github.io/
17
+
18
+ use tree_sitter::Language;
19
+
20
+ extern "C" {
21
+ fn tree_sitter_ql() -> Language;
22
+ }
23
+
24
+ /// Get the tree-sitter [Language][] for this grammar.
25
+ ///
26
+ /// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
27
+ pub fn language() -> Language {
28
+ unsafe { tree_sitter_ql() }
29
+ }
30
+
31
+ /// The content of the [`node-types.json`][] file for this grammar.
32
+ ///
33
+ /// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
34
+ pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
35
+
36
+ // Uncomment these to include any queries that this grammar contains
37
+
38
+ pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
39
+ // pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
40
+ // pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
41
+ pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
42
+
43
+ #[cfg(test)]
44
+ mod tests {
45
+ #[test]
46
+ fn test_can_load_grammar() {
47
+ let mut parser = tree_sitter::Parser::new();
48
+ parser
49
+ .set_language(super::language())
50
+ .expect("Error loading ql language");
51
+ }
52
+ }
vendor/tree-sitter-ql/grammar.js ADDED
@@ -0,0 +1,471 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module.exports = grammar({
2
+ name: 'ql',
3
+
4
+ conflicts: $ => [
5
+ [$.simpleId, $.className],
6
+ [$.simpleId, $.literalId],
7
+ [$.moduleName, $.varName],
8
+ [$.simpleId, $.moduleInstantiation],
9
+ [$.className, $.moduleInstantiation],
10
+ ],
11
+
12
+ extras: $ => [
13
+ /[ \t\r\n]/,
14
+ $.line_comment,
15
+ $.block_comment,
16
+ ],
17
+
18
+ word: $ => $._lower_id,
19
+
20
+ rules: {
21
+ ql: $ => repeat($.moduleMember),
22
+
23
+ module: $ => seq(
24
+ 'module',
25
+ field("name", $.moduleName),
26
+ optional(
27
+ seq(
28
+ "<",
29
+ sep1(field('parameter', $.moduleParam), ","),
30
+ ">"
31
+ )
32
+ ),
33
+ optional(seq(
34
+ "implements",
35
+ sep1(field('implements', $.signatureExpr), ",")
36
+ )),
37
+ choice(
38
+ seq(
39
+ "{",
40
+ repeat($.moduleMember),
41
+ "}"
42
+ ),
43
+ $.moduleAliasBody
44
+ )
45
+ ),
46
+
47
+ moduleMember: $ => choice(
48
+ seq(
49
+ repeat($.annotation),
50
+ choice($.importDirective, $.classlessPredicate, $.dataclass, $.datatype, $.select, $.module)
51
+ ),
52
+ $.qldoc
53
+ ),
54
+
55
+ importDirective: $ => seq(
56
+ 'import',
57
+ $.importModuleExpr,
58
+ optional(seq('as', $.moduleName))
59
+ ),
60
+
61
+ moduleAliasBody: $ => seq('=', $.moduleExpr, ";"),
62
+ predicateAliasBody: $ => seq('=', $.predicateExpr, ";"),
63
+ typeAliasBody: $ => seq('=', $.typeExpr, ";"),
64
+ typeUnionBody: $ => seq('=', $.typeExpr, "or", sep($.typeExpr, "or"), ";"),
65
+
66
+ classlessPredicate: $ => seq(
67
+ field("returnType", choice($.predicate, $.typeExpr)),
68
+ field("name", $.predicateName),
69
+ choice(
70
+ seq("(", sep($.varDecl, ","), ")", $._optbody),
71
+ $.predicateAliasBody
72
+ )
73
+ ),
74
+
75
+ datatype: $ => seq(
76
+ 'newtype',
77
+ field("name", $.className),
78
+ '=',
79
+ $.datatypeBranches
80
+ ),
81
+
82
+ datatypeBranches: $ => sep1($.datatypeBranch, "or"),
83
+
84
+ datatypeBranch: $ => seq(
85
+ optional($.qldoc),
86
+ optional($.annotation),
87
+ field("name", $.className),
88
+ "(",
89
+ sep($.varDecl, ","),
90
+ ")",
91
+ optional($.body)
92
+ ),
93
+
94
+ select: $ => seq(
95
+ optional(seq("from", sep($.varDecl, ","))),
96
+ optional(seq("where", $._exprOrTerm)),
97
+ seq('select', $.asExprs, optional($.orderBys))
98
+ ),
99
+
100
+ dataclass: $ => seq(
101
+ 'class',
102
+ field("name", $.className),
103
+ choice(
104
+ seq(
105
+ optional(field("extends", seq('extends', sep1($.typeExpr, ",")))),
106
+ optional(field("instanceof", seq('instanceof', sep1($.typeExpr, ",")))),
107
+ choice(
108
+ seq(
109
+ "{",
110
+ repeat($.classMember),
111
+ "}"
112
+ ),
113
+ ";"
114
+ )
115
+ ),
116
+ $.typeAliasBody,
117
+ $.typeUnionBody
118
+ )
119
+ ),
120
+
121
+ classMember: $ => choice(
122
+ seq(
123
+ repeat($.annotation),
124
+ choice($.charpred, $.memberPredicate, $.field)
125
+ ),
126
+ $.qldoc
127
+ ),
128
+
129
+ charpred: $ => seq($.className, "(", ")", "{", field('body', $._exprOrTerm), "}"),
130
+
131
+ memberPredicate: $ => seq(
132
+ field("returnType", choice($.predicate, $.typeExpr)),
133
+ field("name", $.predicateName),
134
+ "(",
135
+ sep($.varDecl, ","),
136
+ ")",
137
+ $._optbody
138
+ ),
139
+
140
+ field: $ => seq($.varDecl, ";"),
141
+
142
+ _optbody: $ => choice(
143
+ $.empty,
144
+ $.body,
145
+ $.higherOrderTerm
146
+ ),
147
+
148
+ empty: $ => ";",
149
+
150
+ body: $ => seq("{", $._exprOrTerm, "}"),
151
+
152
+ higherOrderTerm: $ => seq(
153
+ '=',
154
+ field("name", $.literalId),
155
+ "(",
156
+ sep($.predicateExpr, ","),
157
+ ")",
158
+ "(",
159
+ sep($._call_arg, ","),
160
+ ")"
161
+ ),
162
+
163
+ special_call: $ => seq($.specialId, "(", ")"),
164
+ prefix_cast: $ => prec.dynamic(10, seq("(", $.typeExpr, ")", $._exprOrTerm)),
165
+ unary_expr: $ => prec.left(9, seq($.unop, $._exprOrTerm)),
166
+ mul_expr: $ => prec.left(9, seq(
167
+ field('left', $._exprOrTerm),
168
+ $.mulop,
169
+ field('right', $._exprOrTerm)
170
+ )),
171
+ add_expr: $ => prec.left(8, seq(
172
+ field('left', $._exprOrTerm),
173
+ $.addop,
174
+ field('right', $._exprOrTerm)
175
+ )),
176
+ in_expr: $ => prec.left(7, seq(
177
+ field('left', $._exprOrTerm),
178
+ 'in',
179
+ field('right', $._primary)
180
+ )),
181
+ comp_term: $ => prec.left(6, seq(
182
+ field('left', $._exprOrTerm),
183
+ $.compop,
184
+ field('right', $._exprOrTerm)
185
+ )),
186
+ instance_of: $ => prec.left(5, seq($._exprOrTerm, 'instanceof', $.typeExpr)),
187
+ negation: $ => prec.left(4, seq('not', $._exprOrTerm)),
188
+ if_term: $ => prec.left(3, seq(
189
+ "if", field('cond', $._exprOrTerm),
190
+ "then", field('first', $._exprOrTerm),
191
+ "else", field('second', $._exprOrTerm)
192
+ )),
193
+ conjunction: $ => prec.left(3, seq(
194
+ field('left', $._exprOrTerm),
195
+ "and",
196
+ field('right', $._exprOrTerm)
197
+ )),
198
+ disjunction: $ => prec.left(2, seq(
199
+ field('left', $._exprOrTerm),
200
+ "or",
201
+ field('right', $._exprOrTerm)
202
+ )),
203
+ implication: $ => prec.left(1, seq(
204
+ field('left', $._exprOrTerm),
205
+ "implies",
206
+ field('right', $._exprOrTerm)
207
+ )),
208
+
209
+ quantified: $ => seq($.quantifier, "(",
210
+ choice(
211
+ seq(
212
+ sep($.varDecl, ","),
213
+ optional(seq("|", field('range', $._exprOrTerm), optional(seq("|", field('formula', $._exprOrTerm)))))
214
+ ),
215
+ field('expr', $._exprOrTerm)
216
+ ),
217
+ ")"),
218
+
219
+ specialId: $ => 'none',
220
+
221
+ quantifier: $ => choice('exists', 'forall', 'forex'),
222
+
223
+ _call_arg: $ => choice(
224
+ $._exprOrTerm, // ExprArg
225
+ $.underscore // DontCare
226
+ ),
227
+
228
+ underscore: $ => '_',
229
+
230
+ qualifiedRhs: $ => choice(
231
+ seq( // QualCall
232
+ field("name", $.predicateName),
233
+ optional($.closure),
234
+ "(",
235
+ sep($._call_arg, ","),
236
+ ")"
237
+ ),
238
+ seq( // QualCast
239
+ "(",
240
+ $.typeExpr,
241
+ ")"
242
+ )
243
+ ),
244
+
245
+ call_body: $ => seq("(", sep($._call_arg, ","), ")"),
246
+ unqual_agg_body: $ => seq(
247
+ "(",
248
+ sep($.varDecl, ","),
249
+ "|",
250
+ field('guard', optional($._exprOrTerm)),
251
+ field('asExprs', optional(seq("|", $.asExprs))),
252
+ ")"
253
+ ),
254
+
255
+ _call_or_unqual_agg_body: $ => choice($.call_body, $.unqual_agg_body),
256
+
257
+ call_or_unqual_agg_expr: $ => prec.dynamic(10, seq($.aritylessPredicateExpr, optional($.closure), $._call_or_unqual_agg_body)),
258
+ qualified_expr: $ => seq($._primary, ".", $.qualifiedRhs),
259
+ super_ref: $ => seq(optional(seq($.typeExpr, ".")), $.super),
260
+
261
+
262
+ // The split here is to ensure that the node is non-empty
263
+ full_aggregate_body: $ => choice(
264
+ seq(sep($.varDecl, ","),
265
+ seq(
266
+ "|",
267
+ field('guard', optional($._exprOrTerm)),
268
+ optional(seq("|", field('asExprs', $.asExprs), field('orderBys', optional($.orderBys))))
269
+ )
270
+ ),
271
+ sep1($.varDecl, ","),
272
+ ),
273
+
274
+ expr_aggregate_body: $ => seq(field('asExprs', $.asExprs), field('orderBys', optional($.orderBys))),
275
+
276
+ aggregate: $ => seq($.aggId, // Agg
277
+ optional(
278
+ seq("[", sep1($._exprOrTerm, ","), "]")
279
+ ),
280
+ "(",
281
+ optional(
282
+ choice($.full_aggregate_body, $.expr_aggregate_body)
283
+ ),
284
+ ")"
285
+ ),
286
+ range: $ => seq( // Range
287
+ "[",
288
+ field('lower', $._exprOrTerm), "..", field('upper', $._exprOrTerm),
289
+ "]"
290
+ ),
291
+ set_literal: $ => seq(
292
+ "[",
293
+ sep($._exprOrTerm, ','),
294
+ optional(','),
295
+ "]"
296
+ ),
297
+
298
+ par_expr: $ => seq("(", $._exprOrTerm, ")"),
299
+
300
+ expr_annotation: $ => seq(
301
+ field('name', $.annotName),
302
+ "[",
303
+ field('annot_arg', $.annotName),
304
+ "]",
305
+ "(",
306
+ $._exprOrTerm,
307
+ ")",
308
+ ),
309
+
310
+ _exprOrTerm: $ => choice(
311
+ $.special_call,
312
+ $.prefix_cast,
313
+ $._primary,
314
+ $.unary_expr,
315
+ $.mul_expr,
316
+ $.add_expr,
317
+ $.in_expr,
318
+ $.comp_term,
319
+ $.instance_of,
320
+ $.negation,
321
+ $.if_term,
322
+ $.conjunction,
323
+ $.disjunction,
324
+ $.implication,
325
+ $.quantified, // QuantifiedTerm
326
+ ),
327
+
328
+ _primary: $ => choice(
329
+ $.call_or_unqual_agg_expr, //
330
+ $.qualified_expr, // QualifiedExpr
331
+ $.literal, // Lit
332
+ $.variable, // Var
333
+ $.super_ref,
334
+ $.aggregate,
335
+ $.range,
336
+ $.set_literal,
337
+ $.par_expr, // ParExpr
338
+ $.expr_annotation, // ExprAnnotation
339
+ ),
340
+
341
+ literal: $ => choice(
342
+ $.integer, // IntLit
343
+ $.float, // FloatLit
344
+ $.bool, // BoolLit
345
+ $.string // StringLit
346
+ ),
347
+
348
+
349
+ bool: $ => choice($.true, $.false),
350
+
351
+ variable: $ => choice($.this, $.result, $.varName),
352
+
353
+ compop: $ => choice('=', '!=', '<', '>', '<=', '>='),
354
+
355
+ unop: $ => choice('+', '-'),
356
+
357
+ mulop: $ => choice('*', '/', '%'),
358
+
359
+ addop: $ => choice('+', '-'),
360
+
361
+ closure: $ => choice('*', '+'),
362
+
363
+ direction: $ => choice('asc', 'desc'),
364
+
365
+ varDecl: $ => seq($.typeExpr, $.varName),
366
+
367
+ moduleParam: $ => seq(
368
+ field('signature', $.signatureExpr),
369
+ field('parameter', $.simpleId)
370
+ ),
371
+
372
+ asExprs: $ => sep1($.asExpr, ","),
373
+
374
+ asExpr: $ => seq($._exprOrTerm, optional(seq('as', $.varName))),
375
+
376
+ orderBys: $ => seq("order", "by", sep1($.orderBy, ",")),
377
+
378
+ orderBy: $ => seq($._exprOrTerm, optional($.direction)),
379
+
380
+ qldoc: $ => /\/\*\*[^*]*\*+([^/*][^*]*\*+)*\//,
381
+
382
+ literalId: $ => choice($._lower_id, $._upper_id),
383
+
384
+ annotation: $ => choice(
385
+ field('name', $.annotName), // SimpleAnnotation
386
+ seq( // ArgsAnnotation
387
+ field('name', $.annotName),
388
+ "[",
389
+ field('args', sep1($.annotArg, ",")),
390
+ "]"
391
+ )
392
+ ),
393
+
394
+ annotName: $ => $._lower_id,
395
+
396
+ annotArg: $ => choice($.simpleId, $.this, $.result),
397
+
398
+ moduleName: $ => $.simpleId,
399
+
400
+ importModuleExpr: $ => seq(
401
+ repeat(seq(field("qualName", $.simpleId), ".")),
402
+ $.moduleExpr
403
+ ),
404
+
405
+ moduleExpr: $ => choice(
406
+ $.simpleId,
407
+ $.moduleInstantiation,
408
+ seq($.moduleExpr, "::", field("name", choice($.simpleId, $.moduleInstantiation)))
409
+ ),
410
+
411
+ moduleInstantiation: $ => seq(
412
+ field("name", $.moduleName),
413
+ "<",
414
+ sep1($.signatureExpr, ","),
415
+ ">"
416
+ ),
417
+
418
+ primitiveType: $ => choice('boolean', 'date', 'float', 'int', 'string'),
419
+
420
+ simpleId: $ => choice($._lower_id, $._upper_id),
421
+
422
+ className: $ => $._upper_id,
423
+
424
+ dbtype: $ => /@[a-z][A-Za-z0-9_]*/,
425
+
426
+ typeExpr: $ => choice(
427
+ seq(optional(seq(field("qualifier", $.moduleExpr), "::")), field("name", $.className)),
428
+ $.dbtype,
429
+ $.primitiveType
430
+ ),
431
+
432
+ signatureExpr: $ => choice(
433
+ field("type_expr", $.typeExpr),
434
+ field("mod_expr", $.moduleExpr),
435
+ field("predicate", $.predicateExpr)
436
+ ),
437
+
438
+ predicateName: $ => $._lower_id,
439
+
440
+ aritylessPredicateExpr: $ => seq(optional(seq(field('qualifier', $.moduleExpr), "::")), field("name", $.literalId)),
441
+
442
+ predicateExpr: $ => seq($.aritylessPredicateExpr, '/', $.integer),
443
+
444
+ varName: $ => $.simpleId,
445
+
446
+ aggId: $ => choice('avg', 'concat', 'strictconcat', 'count', 'max', 'min', 'rank', 'strictcount', 'strictsum', 'sum', 'any', 'unique'),
447
+
448
+ _upper_id: $ => /[A-Z][A-Za-z0-9_]*/,
449
+ _lower_id: $ => /[a-z][A-Za-z0-9_]*/,
450
+ integer: $ => /[0-9]+/,
451
+ float: $ => /[0-9]+\.[0-9]+/,
452
+ string: $ => /"([^"\\\r\n\t]|\\["\\nrt])*"/,
453
+ line_comment: $ => /\/\/[^\r\n]*/,
454
+ block_comment: $ => /\/\*([^*]+\*+([^/*][^*]*\*+)*|\*)\//,
455
+
456
+ false: $ => 'false',
457
+ predicate: $ => 'predicate',
458
+ result: $ => 'result',
459
+ super: $ => 'super',
460
+ this: $ => 'this',
461
+ true: $ => 'true',
462
+ }
463
+ });
464
+
465
+ function sep(rule, s) {
466
+ return optional(sep1(rule, s))
467
+ }
468
+
469
+ function sep1(rule, s) {
470
+ return seq(rule, repeat(seq(s, rule)))
471
+ }
vendor/tree-sitter-ql/package.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "tree-sitter-ql",
3
+ "version": "0.19.0",
4
+ "description": "tree-sitter grammar for Semmle QL",
5
+ "keywords": [
6
+ "tree-sitter",
7
+ "semmle-ql"
8
+ ],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/tree-sitter/tree-sitter-ql.git"
12
+ },
13
+ "author": "Sam Lanning <[email protected]>",
14
+ "license": "MIT",
15
+ "devDependencies": {
16
+ "tree-sitter-cli": "^0.20.6"
17
+ },
18
+ "scripts": {
19
+ "tree-sitter": "tree-sitter",
20
+ "generate": "tree-sitter generate",
21
+ "test": "tree-sitter test",
22
+ "build": "tree-sitter generate && node-gyp build"
23
+ },
24
+ "tree-sitter": [
25
+ {
26
+ "file-types": [
27
+ "ql",
28
+ "qll"
29
+ ],
30
+ "scope": "source.ql"
31
+ }
32
+ ],
33
+ "dependencies": {
34
+ "nan": "^2.14.1"
35
+ },
36
+ "bugs": {
37
+ "url": "https://github.com/tree-sitter/tree-sitter-ql/issues"
38
+ },
39
+ "homepage": "https://github.com/tree-sitter/tree-sitter-ql#readme",
40
+ "main": "bindings/node",
41
+ "directories": {
42
+ "example": "examples",
43
+ "test": "test"
44
+ }
45
+ }
vendor/tree-sitter-ql/queries/highlights.scm ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ "and"
3
+ "any"
4
+ "as"
5
+ "asc"
6
+ "avg"
7
+ "by"
8
+ "class"
9
+ "concat"
10
+ "count"
11
+ "desc"
12
+ "else"
13
+ "exists"
14
+ "extends"
15
+ "forall"
16
+ "forex"
17
+ "from"
18
+ "if"
19
+ "implies"
20
+ "import"
21
+ "in"
22
+ "instanceof"
23
+ "max"
24
+ "min"
25
+ "module"
26
+ "newtype"
27
+ "not"
28
+ "or"
29
+ "order"
30
+ "rank"
31
+ "select"
32
+ "strictconcat"
33
+ "strictcount"
34
+ "strictsum"
35
+ "sum"
36
+ "then"
37
+ "where"
38
+
39
+ (false)
40
+ (predicate)
41
+ (result)
42
+ (specialId)
43
+ (super)
44
+ (this)
45
+ (true)
46
+ ] @keyword
47
+
48
+ [
49
+ "boolean"
50
+ "float"
51
+ "int"
52
+ "date"
53
+ "string"
54
+ ] @type.builtin
55
+
56
+ (annotName) @attribute
57
+
58
+ [
59
+ "<"
60
+ "<="
61
+ "="
62
+ ">"
63
+ ">="
64
+ "-"
65
+ "!="
66
+ "/"
67
+ "*"
68
+ "%"
69
+ "+"
70
+ "::"
71
+ ] @operator
72
+
73
+ [
74
+ "("
75
+ ")"
76
+ "{"
77
+ "}"
78
+ "["
79
+ "]"
80
+ ] @punctuation.bracket
81
+
82
+ [
83
+ ","
84
+ "|"
85
+ ] @punctuation.delimiter
86
+
87
+ (className) @type
88
+
89
+ (varName) @variable
90
+
91
+ (integer) @number
92
+ (float) @number
93
+
94
+ (string) @string
95
+
96
+ (aritylessPredicateExpr (literalId) @function)
97
+ (predicateName) @function
98
+
99
+ [
100
+ (line_comment)
101
+ (block_comment)
102
+ (qldoc)
103
+ ] @comment
vendor/tree-sitter-ql/queries/tags.scm ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (classlessPredicate
2
+ name: (predicateName) @name) @definition.function
3
+
4
+ (memberPredicate
5
+ name: (predicateName) @name) @definition.method
6
+
7
+ (aritylessPredicateExpr
8
+ name: (literalId) @name) @reference.call
9
+
10
+ (module
11
+ name: (moduleName) @name) @definition.module
12
+
13
+ (dataclass
14
+ name: (className) @name) @definition.class
15
+
16
+ (datatype
17
+ name: (className) @name) @definition.class
18
+
19
+ (datatypeBranch
20
+ name: (className) @name) @definition.class
21
+
22
+ (qualifiedRhs
23
+ name: (predicateName) @name) @reference.call
24
+
25
+ (typeExpr
26
+ name: (className) @name) @reference.type
vendor/tree-sitter-ql/script/fetch-examples ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ function checkout() {
6
+ repo=$1; url=$2; sha=$3
7
+
8
+ if [ ! -d "$repo" ]; then
9
+ git clone "https://github.com/$url" "$repo"
10
+ fi
11
+
12
+ pushd "$repo"
13
+ git fetch && git reset --hard "$sha"
14
+ popd
15
+ }
16
+
17
+ checkout examples/codeql github/codeql 86404af50100b409b18e62651295e79393a6016a
vendor/tree-sitter-ql/script/known-failures.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ examples/codeql/docs/language/ql-training/query-examples/cpp/data-flow-cpp-2.ql
2
+ examples/codeql/docs/language/ql-training/query-examples/java/empty-if-java-class.ql
vendor/tree-sitter-ql/script/parse-examples ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ set -eu
4
+
5
+ known_failures="$(cat script/known-failures.txt)"
6
+
7
+ tree-sitter parse -q \
8
+ 'examples/**/*.ql' \
9
+ $(for file in $known_failures; do echo "!${file}"; done)
10
+
11
+ example_count=$(find examples -name '*.cs' | wc -l)
12
+ failure_count=$(wc -w <<< "$known_failures")
13
+ success_count=$(( $example_count - $failure_count ))
14
+ success_percent=$(bc -l <<< "100*${success_count}/${example_count}")
15
+
16
+ printf \
17
+ "Successfully parsed %d of %d example files (%.1f%%)\n" \
18
+ $success_count $example_count $success_percent
vendor/tree-sitter-ql/src/grammar.json ADDED
@@ -0,0 +1,3310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "ql",
3
+ "word": "_lower_id",
4
+ "rules": {
5
+ "ql": {
6
+ "type": "REPEAT",
7
+ "content": {
8
+ "type": "SYMBOL",
9
+ "name": "moduleMember"
10
+ }
11
+ },
12
+ "module": {
13
+ "type": "SEQ",
14
+ "members": [
15
+ {
16
+ "type": "STRING",
17
+ "value": "module"
18
+ },
19
+ {
20
+ "type": "FIELD",
21
+ "name": "name",
22
+ "content": {
23
+ "type": "SYMBOL",
24
+ "name": "moduleName"
25
+ }
26
+ },
27
+ {
28
+ "type": "CHOICE",
29
+ "members": [
30
+ {
31
+ "type": "SEQ",
32
+ "members": [
33
+ {
34
+ "type": "STRING",
35
+ "value": "<"
36
+ },
37
+ {
38
+ "type": "SEQ",
39
+ "members": [
40
+ {
41
+ "type": "FIELD",
42
+ "name": "parameter",
43
+ "content": {
44
+ "type": "SYMBOL",
45
+ "name": "moduleParam"
46
+ }
47
+ },
48
+ {
49
+ "type": "REPEAT",
50
+ "content": {
51
+ "type": "SEQ",
52
+ "members": [
53
+ {
54
+ "type": "STRING",
55
+ "value": ","
56
+ },
57
+ {
58
+ "type": "FIELD",
59
+ "name": "parameter",
60
+ "content": {
61
+ "type": "SYMBOL",
62
+ "name": "moduleParam"
63
+ }
64
+ }
65
+ ]
66
+ }
67
+ }
68
+ ]
69
+ },
70
+ {
71
+ "type": "STRING",
72
+ "value": ">"
73
+ }
74
+ ]
75
+ },
76
+ {
77
+ "type": "BLANK"
78
+ }
79
+ ]
80
+ },
81
+ {
82
+ "type": "CHOICE",
83
+ "members": [
84
+ {
85
+ "type": "SEQ",
86
+ "members": [
87
+ {
88
+ "type": "STRING",
89
+ "value": "implements"
90
+ },
91
+ {
92
+ "type": "SEQ",
93
+ "members": [
94
+ {
95
+ "type": "FIELD",
96
+ "name": "implements",
97
+ "content": {
98
+ "type": "SYMBOL",
99
+ "name": "signatureExpr"
100
+ }
101
+ },
102
+ {
103
+ "type": "REPEAT",
104
+ "content": {
105
+ "type": "SEQ",
106
+ "members": [
107
+ {
108
+ "type": "STRING",
109
+ "value": ","
110
+ },
111
+ {
112
+ "type": "FIELD",
113
+ "name": "implements",
114
+ "content": {
115
+ "type": "SYMBOL",
116
+ "name": "signatureExpr"
117
+ }
118
+ }
119
+ ]
120
+ }
121
+ }
122
+ ]
123
+ }
124
+ ]
125
+ },
126
+ {
127
+ "type": "BLANK"
128
+ }
129
+ ]
130
+ },
131
+ {
132
+ "type": "CHOICE",
133
+ "members": [
134
+ {
135
+ "type": "SEQ",
136
+ "members": [
137
+ {
138
+ "type": "STRING",
139
+ "value": "{"
140
+ },
141
+ {
142
+ "type": "REPEAT",
143
+ "content": {
144
+ "type": "SYMBOL",
145
+ "name": "moduleMember"
146
+ }
147
+ },
148
+ {
149
+ "type": "STRING",
150
+ "value": "}"
151
+ }
152
+ ]
153
+ },
154
+ {
155
+ "type": "SYMBOL",
156
+ "name": "moduleAliasBody"
157
+ }
158
+ ]
159
+ }
160
+ ]
161
+ },
162
+ "moduleMember": {
163
+ "type": "CHOICE",
164
+ "members": [
165
+ {
166
+ "type": "SEQ",
167
+ "members": [
168
+ {
169
+ "type": "REPEAT",
170
+ "content": {
171
+ "type": "SYMBOL",
172
+ "name": "annotation"
173
+ }
174
+ },
175
+ {
176
+ "type": "CHOICE",
177
+ "members": [
178
+ {
179
+ "type": "SYMBOL",
180
+ "name": "importDirective"
181
+ },
182
+ {
183
+ "type": "SYMBOL",
184
+ "name": "classlessPredicate"
185
+ },
186
+ {
187
+ "type": "SYMBOL",
188
+ "name": "dataclass"
189
+ },
190
+ {
191
+ "type": "SYMBOL",
192
+ "name": "datatype"
193
+ },
194
+ {
195
+ "type": "SYMBOL",
196
+ "name": "select"
197
+ },
198
+ {
199
+ "type": "SYMBOL",
200
+ "name": "module"
201
+ }
202
+ ]
203
+ }
204
+ ]
205
+ },
206
+ {
207
+ "type": "SYMBOL",
208
+ "name": "qldoc"
209
+ }
210
+ ]
211
+ },
212
+ "importDirective": {
213
+ "type": "SEQ",
214
+ "members": [
215
+ {
216
+ "type": "STRING",
217
+ "value": "import"
218
+ },
219
+ {
220
+ "type": "SYMBOL",
221
+ "name": "importModuleExpr"
222
+ },
223
+ {
224
+ "type": "CHOICE",
225
+ "members": [
226
+ {
227
+ "type": "SEQ",
228
+ "members": [
229
+ {
230
+ "type": "STRING",
231
+ "value": "as"
232
+ },
233
+ {
234
+ "type": "SYMBOL",
235
+ "name": "moduleName"
236
+ }
237
+ ]
238
+ },
239
+ {
240
+ "type": "BLANK"
241
+ }
242
+ ]
243
+ }
244
+ ]
245
+ },
246
+ "moduleAliasBody": {
247
+ "type": "SEQ",
248
+ "members": [
249
+ {
250
+ "type": "STRING",
251
+ "value": "="
252
+ },
253
+ {
254
+ "type": "SYMBOL",
255
+ "name": "moduleExpr"
256
+ },
257
+ {
258
+ "type": "STRING",
259
+ "value": ";"
260
+ }
261
+ ]
262
+ },
263
+ "predicateAliasBody": {
264
+ "type": "SEQ",
265
+ "members": [
266
+ {
267
+ "type": "STRING",
268
+ "value": "="
269
+ },
270
+ {
271
+ "type": "SYMBOL",
272
+ "name": "predicateExpr"
273
+ },
274
+ {
275
+ "type": "STRING",
276
+ "value": ";"
277
+ }
278
+ ]
279
+ },
280
+ "typeAliasBody": {
281
+ "type": "SEQ",
282
+ "members": [
283
+ {
284
+ "type": "STRING",
285
+ "value": "="
286
+ },
287
+ {
288
+ "type": "SYMBOL",
289
+ "name": "typeExpr"
290
+ },
291
+ {
292
+ "type": "STRING",
293
+ "value": ";"
294
+ }
295
+ ]
296
+ },
297
+ "typeUnionBody": {
298
+ "type": "SEQ",
299
+ "members": [
300
+ {
301
+ "type": "STRING",
302
+ "value": "="
303
+ },
304
+ {
305
+ "type": "SYMBOL",
306
+ "name": "typeExpr"
307
+ },
308
+ {
309
+ "type": "STRING",
310
+ "value": "or"
311
+ },
312
+ {
313
+ "type": "CHOICE",
314
+ "members": [
315
+ {
316
+ "type": "SEQ",
317
+ "members": [
318
+ {
319
+ "type": "SYMBOL",
320
+ "name": "typeExpr"
321
+ },
322
+ {
323
+ "type": "REPEAT",
324
+ "content": {
325
+ "type": "SEQ",
326
+ "members": [
327
+ {
328
+ "type": "STRING",
329
+ "value": "or"
330
+ },
331
+ {
332
+ "type": "SYMBOL",
333
+ "name": "typeExpr"
334
+ }
335
+ ]
336
+ }
337
+ }
338
+ ]
339
+ },
340
+ {
341
+ "type": "BLANK"
342
+ }
343
+ ]
344
+ },
345
+ {
346
+ "type": "STRING",
347
+ "value": ";"
348
+ }
349
+ ]
350
+ },
351
+ "classlessPredicate": {
352
+ "type": "SEQ",
353
+ "members": [
354
+ {
355
+ "type": "FIELD",
356
+ "name": "returnType",
357
+ "content": {
358
+ "type": "CHOICE",
359
+ "members": [
360
+ {
361
+ "type": "SYMBOL",
362
+ "name": "predicate"
363
+ },
364
+ {
365
+ "type": "SYMBOL",
366
+ "name": "typeExpr"
367
+ }
368
+ ]
369
+ }
370
+ },
371
+ {
372
+ "type": "FIELD",
373
+ "name": "name",
374
+ "content": {
375
+ "type": "SYMBOL",
376
+ "name": "predicateName"
377
+ }
378
+ },
379
+ {
380
+ "type": "CHOICE",
381
+ "members": [
382
+ {
383
+ "type": "SEQ",
384
+ "members": [
385
+ {
386
+ "type": "STRING",
387
+ "value": "("
388
+ },
389
+ {
390
+ "type": "CHOICE",
391
+ "members": [
392
+ {
393
+ "type": "SEQ",
394
+ "members": [
395
+ {
396
+ "type": "SYMBOL",
397
+ "name": "varDecl"
398
+ },
399
+ {
400
+ "type": "REPEAT",
401
+ "content": {
402
+ "type": "SEQ",
403
+ "members": [
404
+ {
405
+ "type": "STRING",
406
+ "value": ","
407
+ },
408
+ {
409
+ "type": "SYMBOL",
410
+ "name": "varDecl"
411
+ }
412
+ ]
413
+ }
414
+ }
415
+ ]
416
+ },
417
+ {
418
+ "type": "BLANK"
419
+ }
420
+ ]
421
+ },
422
+ {
423
+ "type": "STRING",
424
+ "value": ")"
425
+ },
426
+ {
427
+ "type": "SYMBOL",
428
+ "name": "_optbody"
429
+ }
430
+ ]
431
+ },
432
+ {
433
+ "type": "SYMBOL",
434
+ "name": "predicateAliasBody"
435
+ }
436
+ ]
437
+ }
438
+ ]
439
+ },
440
+ "datatype": {
441
+ "type": "SEQ",
442
+ "members": [
443
+ {
444
+ "type": "STRING",
445
+ "value": "newtype"
446
+ },
447
+ {
448
+ "type": "FIELD",
449
+ "name": "name",
450
+ "content": {
451
+ "type": "SYMBOL",
452
+ "name": "className"
453
+ }
454
+ },
455
+ {
456
+ "type": "STRING",
457
+ "value": "="
458
+ },
459
+ {
460
+ "type": "SYMBOL",
461
+ "name": "datatypeBranches"
462
+ }
463
+ ]
464
+ },
465
+ "datatypeBranches": {
466
+ "type": "SEQ",
467
+ "members": [
468
+ {
469
+ "type": "SYMBOL",
470
+ "name": "datatypeBranch"
471
+ },
472
+ {
473
+ "type": "REPEAT",
474
+ "content": {
475
+ "type": "SEQ",
476
+ "members": [
477
+ {
478
+ "type": "STRING",
479
+ "value": "or"
480
+ },
481
+ {
482
+ "type": "SYMBOL",
483
+ "name": "datatypeBranch"
484
+ }
485
+ ]
486
+ }
487
+ }
488
+ ]
489
+ },
490
+ "datatypeBranch": {
491
+ "type": "SEQ",
492
+ "members": [
493
+ {
494
+ "type": "CHOICE",
495
+ "members": [
496
+ {
497
+ "type": "SYMBOL",
498
+ "name": "qldoc"
499
+ },
500
+ {
501
+ "type": "BLANK"
502
+ }
503
+ ]
504
+ },
505
+ {
506
+ "type": "CHOICE",
507
+ "members": [
508
+ {
509
+ "type": "SYMBOL",
510
+ "name": "annotation"
511
+ },
512
+ {
513
+ "type": "BLANK"
514
+ }
515
+ ]
516
+ },
517
+ {
518
+ "type": "FIELD",
519
+ "name": "name",
520
+ "content": {
521
+ "type": "SYMBOL",
522
+ "name": "className"
523
+ }
524
+ },
525
+ {
526
+ "type": "STRING",
527
+ "value": "("
528
+ },
529
+ {
530
+ "type": "CHOICE",
531
+ "members": [
532
+ {
533
+ "type": "SEQ",
534
+ "members": [
535
+ {
536
+ "type": "SYMBOL",
537
+ "name": "varDecl"
538
+ },
539
+ {
540
+ "type": "REPEAT",
541
+ "content": {
542
+ "type": "SEQ",
543
+ "members": [
544
+ {
545
+ "type": "STRING",
546
+ "value": ","
547
+ },
548
+ {
549
+ "type": "SYMBOL",
550
+ "name": "varDecl"
551
+ }
552
+ ]
553
+ }
554
+ }
555
+ ]
556
+ },
557
+ {
558
+ "type": "BLANK"
559
+ }
560
+ ]
561
+ },
562
+ {
563
+ "type": "STRING",
564
+ "value": ")"
565
+ },
566
+ {
567
+ "type": "CHOICE",
568
+ "members": [
569
+ {
570
+ "type": "SYMBOL",
571
+ "name": "body"
572
+ },
573
+ {
574
+ "type": "BLANK"
575
+ }
576
+ ]
577
+ }
578
+ ]
579
+ },
580
+ "select": {
581
+ "type": "SEQ",
582
+ "members": [
583
+ {
584
+ "type": "CHOICE",
585
+ "members": [
586
+ {
587
+ "type": "SEQ",
588
+ "members": [
589
+ {
590
+ "type": "STRING",
591
+ "value": "from"
592
+ },
593
+ {
594
+ "type": "CHOICE",
595
+ "members": [
596
+ {
597
+ "type": "SEQ",
598
+ "members": [
599
+ {
600
+ "type": "SYMBOL",
601
+ "name": "varDecl"
602
+ },
603
+ {
604
+ "type": "REPEAT",
605
+ "content": {
606
+ "type": "SEQ",
607
+ "members": [
608
+ {
609
+ "type": "STRING",
610
+ "value": ","
611
+ },
612
+ {
613
+ "type": "SYMBOL",
614
+ "name": "varDecl"
615
+ }
616
+ ]
617
+ }
618
+ }
619
+ ]
620
+ },
621
+ {
622
+ "type": "BLANK"
623
+ }
624
+ ]
625
+ }
626
+ ]
627
+ },
628
+ {
629
+ "type": "BLANK"
630
+ }
631
+ ]
632
+ },
633
+ {
634
+ "type": "CHOICE",
635
+ "members": [
636
+ {
637
+ "type": "SEQ",
638
+ "members": [
639
+ {
640
+ "type": "STRING",
641
+ "value": "where"
642
+ },
643
+ {
644
+ "type": "SYMBOL",
645
+ "name": "_exprOrTerm"
646
+ }
647
+ ]
648
+ },
649
+ {
650
+ "type": "BLANK"
651
+ }
652
+ ]
653
+ },
654
+ {
655
+ "type": "SEQ",
656
+ "members": [
657
+ {
658
+ "type": "STRING",
659
+ "value": "select"
660
+ },
661
+ {
662
+ "type": "SYMBOL",
663
+ "name": "asExprs"
664
+ },
665
+ {
666
+ "type": "CHOICE",
667
+ "members": [
668
+ {
669
+ "type": "SYMBOL",
670
+ "name": "orderBys"
671
+ },
672
+ {
673
+ "type": "BLANK"
674
+ }
675
+ ]
676
+ }
677
+ ]
678
+ }
679
+ ]
680
+ },
681
+ "dataclass": {
682
+ "type": "SEQ",
683
+ "members": [
684
+ {
685
+ "type": "STRING",
686
+ "value": "class"
687
+ },
688
+ {
689
+ "type": "FIELD",
690
+ "name": "name",
691
+ "content": {
692
+ "type": "SYMBOL",
693
+ "name": "className"
694
+ }
695
+ },
696
+ {
697
+ "type": "CHOICE",
698
+ "members": [
699
+ {
700
+ "type": "SEQ",
701
+ "members": [
702
+ {
703
+ "type": "CHOICE",
704
+ "members": [
705
+ {
706
+ "type": "FIELD",
707
+ "name": "extends",
708
+ "content": {
709
+ "type": "SEQ",
710
+ "members": [
711
+ {
712
+ "type": "STRING",
713
+ "value": "extends"
714
+ },
715
+ {
716
+ "type": "SEQ",
717
+ "members": [
718
+ {
719
+ "type": "SYMBOL",
720
+ "name": "typeExpr"
721
+ },
722
+ {
723
+ "type": "REPEAT",
724
+ "content": {
725
+ "type": "SEQ",
726
+ "members": [
727
+ {
728
+ "type": "STRING",
729
+ "value": ","
730
+ },
731
+ {
732
+ "type": "SYMBOL",
733
+ "name": "typeExpr"
734
+ }
735
+ ]
736
+ }
737
+ }
738
+ ]
739
+ }
740
+ ]
741
+ }
742
+ },
743
+ {
744
+ "type": "BLANK"
745
+ }
746
+ ]
747
+ },
748
+ {
749
+ "type": "CHOICE",
750
+ "members": [
751
+ {
752
+ "type": "FIELD",
753
+ "name": "instanceof",
754
+ "content": {
755
+ "type": "SEQ",
756
+ "members": [
757
+ {
758
+ "type": "STRING",
759
+ "value": "instanceof"
760
+ },
761
+ {
762
+ "type": "SEQ",
763
+ "members": [
764
+ {
765
+ "type": "SYMBOL",
766
+ "name": "typeExpr"
767
+ },
768
+ {
769
+ "type": "REPEAT",
770
+ "content": {
771
+ "type": "SEQ",
772
+ "members": [
773
+ {
774
+ "type": "STRING",
775
+ "value": ","
776
+ },
777
+ {
778
+ "type": "SYMBOL",
779
+ "name": "typeExpr"
780
+ }
781
+ ]
782
+ }
783
+ }
784
+ ]
785
+ }
786
+ ]
787
+ }
788
+ },
789
+ {
790
+ "type": "BLANK"
791
+ }
792
+ ]
793
+ },
794
+ {
795
+ "type": "CHOICE",
796
+ "members": [
797
+ {
798
+ "type": "SEQ",
799
+ "members": [
800
+ {
801
+ "type": "STRING",
802
+ "value": "{"
803
+ },
804
+ {
805
+ "type": "REPEAT",
806
+ "content": {
807
+ "type": "SYMBOL",
808
+ "name": "classMember"
809
+ }
810
+ },
811
+ {
812
+ "type": "STRING",
813
+ "value": "}"
814
+ }
815
+ ]
816
+ },
817
+ {
818
+ "type": "STRING",
819
+ "value": ";"
820
+ }
821
+ ]
822
+ }
823
+ ]
824
+ },
825
+ {
826
+ "type": "SYMBOL",
827
+ "name": "typeAliasBody"
828
+ },
829
+ {
830
+ "type": "SYMBOL",
831
+ "name": "typeUnionBody"
832
+ }
833
+ ]
834
+ }
835
+ ]
836
+ },
837
+ "classMember": {
838
+ "type": "CHOICE",
839
+ "members": [
840
+ {
841
+ "type": "SEQ",
842
+ "members": [
843
+ {
844
+ "type": "REPEAT",
845
+ "content": {
846
+ "type": "SYMBOL",
847
+ "name": "annotation"
848
+ }
849
+ },
850
+ {
851
+ "type": "CHOICE",
852
+ "members": [
853
+ {
854
+ "type": "SYMBOL",
855
+ "name": "charpred"
856
+ },
857
+ {
858
+ "type": "SYMBOL",
859
+ "name": "memberPredicate"
860
+ },
861
+ {
862
+ "type": "SYMBOL",
863
+ "name": "field"
864
+ }
865
+ ]
866
+ }
867
+ ]
868
+ },
869
+ {
870
+ "type": "SYMBOL",
871
+ "name": "qldoc"
872
+ }
873
+ ]
874
+ },
875
+ "charpred": {
876
+ "type": "SEQ",
877
+ "members": [
878
+ {
879
+ "type": "SYMBOL",
880
+ "name": "className"
881
+ },
882
+ {
883
+ "type": "STRING",
884
+ "value": "("
885
+ },
886
+ {
887
+ "type": "STRING",
888
+ "value": ")"
889
+ },
890
+ {
891
+ "type": "STRING",
892
+ "value": "{"
893
+ },
894
+ {
895
+ "type": "FIELD",
896
+ "name": "body",
897
+ "content": {
898
+ "type": "SYMBOL",
899
+ "name": "_exprOrTerm"
900
+ }
901
+ },
902
+ {
903
+ "type": "STRING",
904
+ "value": "}"
905
+ }
906
+ ]
907
+ },
908
+ "memberPredicate": {
909
+ "type": "SEQ",
910
+ "members": [
911
+ {
912
+ "type": "FIELD",
913
+ "name": "returnType",
914
+ "content": {
915
+ "type": "CHOICE",
916
+ "members": [
917
+ {
918
+ "type": "SYMBOL",
919
+ "name": "predicate"
920
+ },
921
+ {
922
+ "type": "SYMBOL",
923
+ "name": "typeExpr"
924
+ }
925
+ ]
926
+ }
927
+ },
928
+ {
929
+ "type": "FIELD",
930
+ "name": "name",
931
+ "content": {
932
+ "type": "SYMBOL",
933
+ "name": "predicateName"
934
+ }
935
+ },
936
+ {
937
+ "type": "STRING",
938
+ "value": "("
939
+ },
940
+ {
941
+ "type": "CHOICE",
942
+ "members": [
943
+ {
944
+ "type": "SEQ",
945
+ "members": [
946
+ {
947
+ "type": "SYMBOL",
948
+ "name": "varDecl"
949
+ },
950
+ {
951
+ "type": "REPEAT",
952
+ "content": {
953
+ "type": "SEQ",
954
+ "members": [
955
+ {
956
+ "type": "STRING",
957
+ "value": ","
958
+ },
959
+ {
960
+ "type": "SYMBOL",
961
+ "name": "varDecl"
962
+ }
963
+ ]
964
+ }
965
+ }
966
+ ]
967
+ },
968
+ {
969
+ "type": "BLANK"
970
+ }
971
+ ]
972
+ },
973
+ {
974
+ "type": "STRING",
975
+ "value": ")"
976
+ },
977
+ {
978
+ "type": "SYMBOL",
979
+ "name": "_optbody"
980
+ }
981
+ ]
982
+ },
983
+ "field": {
984
+ "type": "SEQ",
985
+ "members": [
986
+ {
987
+ "type": "SYMBOL",
988
+ "name": "varDecl"
989
+ },
990
+ {
991
+ "type": "STRING",
992
+ "value": ";"
993
+ }
994
+ ]
995
+ },
996
+ "_optbody": {
997
+ "type": "CHOICE",
998
+ "members": [
999
+ {
1000
+ "type": "SYMBOL",
1001
+ "name": "empty"
1002
+ },
1003
+ {
1004
+ "type": "SYMBOL",
1005
+ "name": "body"
1006
+ },
1007
+ {
1008
+ "type": "SYMBOL",
1009
+ "name": "higherOrderTerm"
1010
+ }
1011
+ ]
1012
+ },
1013
+ "empty": {
1014
+ "type": "STRING",
1015
+ "value": ";"
1016
+ },
1017
+ "body": {
1018
+ "type": "SEQ",
1019
+ "members": [
1020
+ {
1021
+ "type": "STRING",
1022
+ "value": "{"
1023
+ },
1024
+ {
1025
+ "type": "SYMBOL",
1026
+ "name": "_exprOrTerm"
1027
+ },
1028
+ {
1029
+ "type": "STRING",
1030
+ "value": "}"
1031
+ }
1032
+ ]
1033
+ },
1034
+ "higherOrderTerm": {
1035
+ "type": "SEQ",
1036
+ "members": [
1037
+ {
1038
+ "type": "STRING",
1039
+ "value": "="
1040
+ },
1041
+ {
1042
+ "type": "FIELD",
1043
+ "name": "name",
1044
+ "content": {
1045
+ "type": "SYMBOL",
1046
+ "name": "literalId"
1047
+ }
1048
+ },
1049
+ {
1050
+ "type": "STRING",
1051
+ "value": "("
1052
+ },
1053
+ {
1054
+ "type": "CHOICE",
1055
+ "members": [
1056
+ {
1057
+ "type": "SEQ",
1058
+ "members": [
1059
+ {
1060
+ "type": "SYMBOL",
1061
+ "name": "predicateExpr"
1062
+ },
1063
+ {
1064
+ "type": "REPEAT",
1065
+ "content": {
1066
+ "type": "SEQ",
1067
+ "members": [
1068
+ {
1069
+ "type": "STRING",
1070
+ "value": ","
1071
+ },
1072
+ {
1073
+ "type": "SYMBOL",
1074
+ "name": "predicateExpr"
1075
+ }
1076
+ ]
1077
+ }
1078
+ }
1079
+ ]
1080
+ },
1081
+ {
1082
+ "type": "BLANK"
1083
+ }
1084
+ ]
1085
+ },
1086
+ {
1087
+ "type": "STRING",
1088
+ "value": ")"
1089
+ },
1090
+ {
1091
+ "type": "STRING",
1092
+ "value": "("
1093
+ },
1094
+ {
1095
+ "type": "CHOICE",
1096
+ "members": [
1097
+ {
1098
+ "type": "SEQ",
1099
+ "members": [
1100
+ {
1101
+ "type": "SYMBOL",
1102
+ "name": "_call_arg"
1103
+ },
1104
+ {
1105
+ "type": "REPEAT",
1106
+ "content": {
1107
+ "type": "SEQ",
1108
+ "members": [
1109
+ {
1110
+ "type": "STRING",
1111
+ "value": ","
1112
+ },
1113
+ {
1114
+ "type": "SYMBOL",
1115
+ "name": "_call_arg"
1116
+ }
1117
+ ]
1118
+ }
1119
+ }
1120
+ ]
1121
+ },
1122
+ {
1123
+ "type": "BLANK"
1124
+ }
1125
+ ]
1126
+ },
1127
+ {
1128
+ "type": "STRING",
1129
+ "value": ")"
1130
+ }
1131
+ ]
1132
+ },
1133
+ "special_call": {
1134
+ "type": "SEQ",
1135
+ "members": [
1136
+ {
1137
+ "type": "SYMBOL",
1138
+ "name": "specialId"
1139
+ },
1140
+ {
1141
+ "type": "STRING",
1142
+ "value": "("
1143
+ },
1144
+ {
1145
+ "type": "STRING",
1146
+ "value": ")"
1147
+ }
1148
+ ]
1149
+ },
1150
+ "prefix_cast": {
1151
+ "type": "PREC_DYNAMIC",
1152
+ "value": 10,
1153
+ "content": {
1154
+ "type": "SEQ",
1155
+ "members": [
1156
+ {
1157
+ "type": "STRING",
1158
+ "value": "("
1159
+ },
1160
+ {
1161
+ "type": "SYMBOL",
1162
+ "name": "typeExpr"
1163
+ },
1164
+ {
1165
+ "type": "STRING",
1166
+ "value": ")"
1167
+ },
1168
+ {
1169
+ "type": "SYMBOL",
1170
+ "name": "_exprOrTerm"
1171
+ }
1172
+ ]
1173
+ }
1174
+ },
1175
+ "unary_expr": {
1176
+ "type": "PREC_LEFT",
1177
+ "value": 9,
1178
+ "content": {
1179
+ "type": "SEQ",
1180
+ "members": [
1181
+ {
1182
+ "type": "SYMBOL",
1183
+ "name": "unop"
1184
+ },
1185
+ {
1186
+ "type": "SYMBOL",
1187
+ "name": "_exprOrTerm"
1188
+ }
1189
+ ]
1190
+ }
1191
+ },
1192
+ "mul_expr": {
1193
+ "type": "PREC_LEFT",
1194
+ "value": 9,
1195
+ "content": {
1196
+ "type": "SEQ",
1197
+ "members": [
1198
+ {
1199
+ "type": "FIELD",
1200
+ "name": "left",
1201
+ "content": {
1202
+ "type": "SYMBOL",
1203
+ "name": "_exprOrTerm"
1204
+ }
1205
+ },
1206
+ {
1207
+ "type": "SYMBOL",
1208
+ "name": "mulop"
1209
+ },
1210
+ {
1211
+ "type": "FIELD",
1212
+ "name": "right",
1213
+ "content": {
1214
+ "type": "SYMBOL",
1215
+ "name": "_exprOrTerm"
1216
+ }
1217
+ }
1218
+ ]
1219
+ }
1220
+ },
1221
+ "add_expr": {
1222
+ "type": "PREC_LEFT",
1223
+ "value": 8,
1224
+ "content": {
1225
+ "type": "SEQ",
1226
+ "members": [
1227
+ {
1228
+ "type": "FIELD",
1229
+ "name": "left",
1230
+ "content": {
1231
+ "type": "SYMBOL",
1232
+ "name": "_exprOrTerm"
1233
+ }
1234
+ },
1235
+ {
1236
+ "type": "SYMBOL",
1237
+ "name": "addop"
1238
+ },
1239
+ {
1240
+ "type": "FIELD",
1241
+ "name": "right",
1242
+ "content": {
1243
+ "type": "SYMBOL",
1244
+ "name": "_exprOrTerm"
1245
+ }
1246
+ }
1247
+ ]
1248
+ }
1249
+ },
1250
+ "in_expr": {
1251
+ "type": "PREC_LEFT",
1252
+ "value": 7,
1253
+ "content": {
1254
+ "type": "SEQ",
1255
+ "members": [
1256
+ {
1257
+ "type": "FIELD",
1258
+ "name": "left",
1259
+ "content": {
1260
+ "type": "SYMBOL",
1261
+ "name": "_exprOrTerm"
1262
+ }
1263
+ },
1264
+ {
1265
+ "type": "STRING",
1266
+ "value": "in"
1267
+ },
1268
+ {
1269
+ "type": "FIELD",
1270
+ "name": "right",
1271
+ "content": {
1272
+ "type": "SYMBOL",
1273
+ "name": "_primary"
1274
+ }
1275
+ }
1276
+ ]
1277
+ }
1278
+ },
1279
+ "comp_term": {
1280
+ "type": "PREC_LEFT",
1281
+ "value": 6,
1282
+ "content": {
1283
+ "type": "SEQ",
1284
+ "members": [
1285
+ {
1286
+ "type": "FIELD",
1287
+ "name": "left",
1288
+ "content": {
1289
+ "type": "SYMBOL",
1290
+ "name": "_exprOrTerm"
1291
+ }
1292
+ },
1293
+ {
1294
+ "type": "SYMBOL",
1295
+ "name": "compop"
1296
+ },
1297
+ {
1298
+ "type": "FIELD",
1299
+ "name": "right",
1300
+ "content": {
1301
+ "type": "SYMBOL",
1302
+ "name": "_exprOrTerm"
1303
+ }
1304
+ }
1305
+ ]
1306
+ }
1307
+ },
1308
+ "instance_of": {
1309
+ "type": "PREC_LEFT",
1310
+ "value": 5,
1311
+ "content": {
1312
+ "type": "SEQ",
1313
+ "members": [
1314
+ {
1315
+ "type": "SYMBOL",
1316
+ "name": "_exprOrTerm"
1317
+ },
1318
+ {
1319
+ "type": "STRING",
1320
+ "value": "instanceof"
1321
+ },
1322
+ {
1323
+ "type": "SYMBOL",
1324
+ "name": "typeExpr"
1325
+ }
1326
+ ]
1327
+ }
1328
+ },
1329
+ "negation": {
1330
+ "type": "PREC_LEFT",
1331
+ "value": 4,
1332
+ "content": {
1333
+ "type": "SEQ",
1334
+ "members": [
1335
+ {
1336
+ "type": "STRING",
1337
+ "value": "not"
1338
+ },
1339
+ {
1340
+ "type": "SYMBOL",
1341
+ "name": "_exprOrTerm"
1342
+ }
1343
+ ]
1344
+ }
1345
+ },
1346
+ "if_term": {
1347
+ "type": "PREC_LEFT",
1348
+ "value": 3,
1349
+ "content": {
1350
+ "type": "SEQ",
1351
+ "members": [
1352
+ {
1353
+ "type": "STRING",
1354
+ "value": "if"
1355
+ },
1356
+ {
1357
+ "type": "FIELD",
1358
+ "name": "cond",
1359
+ "content": {
1360
+ "type": "SYMBOL",
1361
+ "name": "_exprOrTerm"
1362
+ }
1363
+ },
1364
+ {
1365
+ "type": "STRING",
1366
+ "value": "then"
1367
+ },
1368
+ {
1369
+ "type": "FIELD",
1370
+ "name": "first",
1371
+ "content": {
1372
+ "type": "SYMBOL",
1373
+ "name": "_exprOrTerm"
1374
+ }
1375
+ },
1376
+ {
1377
+ "type": "STRING",
1378
+ "value": "else"
1379
+ },
1380
+ {
1381
+ "type": "FIELD",
1382
+ "name": "second",
1383
+ "content": {
1384
+ "type": "SYMBOL",
1385
+ "name": "_exprOrTerm"
1386
+ }
1387
+ }
1388
+ ]
1389
+ }
1390
+ },
1391
+ "conjunction": {
1392
+ "type": "PREC_LEFT",
1393
+ "value": 3,
1394
+ "content": {
1395
+ "type": "SEQ",
1396
+ "members": [
1397
+ {
1398
+ "type": "FIELD",
1399
+ "name": "left",
1400
+ "content": {
1401
+ "type": "SYMBOL",
1402
+ "name": "_exprOrTerm"
1403
+ }
1404
+ },
1405
+ {
1406
+ "type": "STRING",
1407
+ "value": "and"
1408
+ },
1409
+ {
1410
+ "type": "FIELD",
1411
+ "name": "right",
1412
+ "content": {
1413
+ "type": "SYMBOL",
1414
+ "name": "_exprOrTerm"
1415
+ }
1416
+ }
1417
+ ]
1418
+ }
1419
+ },
1420
+ "disjunction": {
1421
+ "type": "PREC_LEFT",
1422
+ "value": 2,
1423
+ "content": {
1424
+ "type": "SEQ",
1425
+ "members": [
1426
+ {
1427
+ "type": "FIELD",
1428
+ "name": "left",
1429
+ "content": {
1430
+ "type": "SYMBOL",
1431
+ "name": "_exprOrTerm"
1432
+ }
1433
+ },
1434
+ {
1435
+ "type": "STRING",
1436
+ "value": "or"
1437
+ },
1438
+ {
1439
+ "type": "FIELD",
1440
+ "name": "right",
1441
+ "content": {
1442
+ "type": "SYMBOL",
1443
+ "name": "_exprOrTerm"
1444
+ }
1445
+ }
1446
+ ]
1447
+ }
1448
+ },
1449
+ "implication": {
1450
+ "type": "PREC_LEFT",
1451
+ "value": 1,
1452
+ "content": {
1453
+ "type": "SEQ",
1454
+ "members": [
1455
+ {
1456
+ "type": "FIELD",
1457
+ "name": "left",
1458
+ "content": {
1459
+ "type": "SYMBOL",
1460
+ "name": "_exprOrTerm"
1461
+ }
1462
+ },
1463
+ {
1464
+ "type": "STRING",
1465
+ "value": "implies"
1466
+ },
1467
+ {
1468
+ "type": "FIELD",
1469
+ "name": "right",
1470
+ "content": {
1471
+ "type": "SYMBOL",
1472
+ "name": "_exprOrTerm"
1473
+ }
1474
+ }
1475
+ ]
1476
+ }
1477
+ },
1478
+ "quantified": {
1479
+ "type": "SEQ",
1480
+ "members": [
1481
+ {
1482
+ "type": "SYMBOL",
1483
+ "name": "quantifier"
1484
+ },
1485
+ {
1486
+ "type": "STRING",
1487
+ "value": "("
1488
+ },
1489
+ {
1490
+ "type": "CHOICE",
1491
+ "members": [
1492
+ {
1493
+ "type": "SEQ",
1494
+ "members": [
1495
+ {
1496
+ "type": "CHOICE",
1497
+ "members": [
1498
+ {
1499
+ "type": "SEQ",
1500
+ "members": [
1501
+ {
1502
+ "type": "SYMBOL",
1503
+ "name": "varDecl"
1504
+ },
1505
+ {
1506
+ "type": "REPEAT",
1507
+ "content": {
1508
+ "type": "SEQ",
1509
+ "members": [
1510
+ {
1511
+ "type": "STRING",
1512
+ "value": ","
1513
+ },
1514
+ {
1515
+ "type": "SYMBOL",
1516
+ "name": "varDecl"
1517
+ }
1518
+ ]
1519
+ }
1520
+ }
1521
+ ]
1522
+ },
1523
+ {
1524
+ "type": "BLANK"
1525
+ }
1526
+ ]
1527
+ },
1528
+ {
1529
+ "type": "CHOICE",
1530
+ "members": [
1531
+ {
1532
+ "type": "SEQ",
1533
+ "members": [
1534
+ {
1535
+ "type": "STRING",
1536
+ "value": "|"
1537
+ },
1538
+ {
1539
+ "type": "FIELD",
1540
+ "name": "range",
1541
+ "content": {
1542
+ "type": "SYMBOL",
1543
+ "name": "_exprOrTerm"
1544
+ }
1545
+ },
1546
+ {
1547
+ "type": "CHOICE",
1548
+ "members": [
1549
+ {
1550
+ "type": "SEQ",
1551
+ "members": [
1552
+ {
1553
+ "type": "STRING",
1554
+ "value": "|"
1555
+ },
1556
+ {
1557
+ "type": "FIELD",
1558
+ "name": "formula",
1559
+ "content": {
1560
+ "type": "SYMBOL",
1561
+ "name": "_exprOrTerm"
1562
+ }
1563
+ }
1564
+ ]
1565
+ },
1566
+ {
1567
+ "type": "BLANK"
1568
+ }
1569
+ ]
1570
+ }
1571
+ ]
1572
+ },
1573
+ {
1574
+ "type": "BLANK"
1575
+ }
1576
+ ]
1577
+ }
1578
+ ]
1579
+ },
1580
+ {
1581
+ "type": "FIELD",
1582
+ "name": "expr",
1583
+ "content": {
1584
+ "type": "SYMBOL",
1585
+ "name": "_exprOrTerm"
1586
+ }
1587
+ }
1588
+ ]
1589
+ },
1590
+ {
1591
+ "type": "STRING",
1592
+ "value": ")"
1593
+ }
1594
+ ]
1595
+ },
1596
+ "specialId": {
1597
+ "type": "STRING",
1598
+ "value": "none"
1599
+ },
1600
+ "quantifier": {
1601
+ "type": "CHOICE",
1602
+ "members": [
1603
+ {
1604
+ "type": "STRING",
1605
+ "value": "exists"
1606
+ },
1607
+ {
1608
+ "type": "STRING",
1609
+ "value": "forall"
1610
+ },
1611
+ {
1612
+ "type": "STRING",
1613
+ "value": "forex"
1614
+ }
1615
+ ]
1616
+ },
1617
+ "_call_arg": {
1618
+ "type": "CHOICE",
1619
+ "members": [
1620
+ {
1621
+ "type": "SYMBOL",
1622
+ "name": "_exprOrTerm"
1623
+ },
1624
+ {
1625
+ "type": "SYMBOL",
1626
+ "name": "underscore"
1627
+ }
1628
+ ]
1629
+ },
1630
+ "underscore": {
1631
+ "type": "STRING",
1632
+ "value": "_"
1633
+ },
1634
+ "qualifiedRhs": {
1635
+ "type": "CHOICE",
1636
+ "members": [
1637
+ {
1638
+ "type": "SEQ",
1639
+ "members": [
1640
+ {
1641
+ "type": "FIELD",
1642
+ "name": "name",
1643
+ "content": {
1644
+ "type": "SYMBOL",
1645
+ "name": "predicateName"
1646
+ }
1647
+ },
1648
+ {
1649
+ "type": "CHOICE",
1650
+ "members": [
1651
+ {
1652
+ "type": "SYMBOL",
1653
+ "name": "closure"
1654
+ },
1655
+ {
1656
+ "type": "BLANK"
1657
+ }
1658
+ ]
1659
+ },
1660
+ {
1661
+ "type": "STRING",
1662
+ "value": "("
1663
+ },
1664
+ {
1665
+ "type": "CHOICE",
1666
+ "members": [
1667
+ {
1668
+ "type": "SEQ",
1669
+ "members": [
1670
+ {
1671
+ "type": "SYMBOL",
1672
+ "name": "_call_arg"
1673
+ },
1674
+ {
1675
+ "type": "REPEAT",
1676
+ "content": {
1677
+ "type": "SEQ",
1678
+ "members": [
1679
+ {
1680
+ "type": "STRING",
1681
+ "value": ","
1682
+ },
1683
+ {
1684
+ "type": "SYMBOL",
1685
+ "name": "_call_arg"
1686
+ }
1687
+ ]
1688
+ }
1689
+ }
1690
+ ]
1691
+ },
1692
+ {
1693
+ "type": "BLANK"
1694
+ }
1695
+ ]
1696
+ },
1697
+ {
1698
+ "type": "STRING",
1699
+ "value": ")"
1700
+ }
1701
+ ]
1702
+ },
1703
+ {
1704
+ "type": "SEQ",
1705
+ "members": [
1706
+ {
1707
+ "type": "STRING",
1708
+ "value": "("
1709
+ },
1710
+ {
1711
+ "type": "SYMBOL",
1712
+ "name": "typeExpr"
1713
+ },
1714
+ {
1715
+ "type": "STRING",
1716
+ "value": ")"
1717
+ }
1718
+ ]
1719
+ }
1720
+ ]
1721
+ },
1722
+ "call_body": {
1723
+ "type": "SEQ",
1724
+ "members": [
1725
+ {
1726
+ "type": "STRING",
1727
+ "value": "("
1728
+ },
1729
+ {
1730
+ "type": "CHOICE",
1731
+ "members": [
1732
+ {
1733
+ "type": "SEQ",
1734
+ "members": [
1735
+ {
1736
+ "type": "SYMBOL",
1737
+ "name": "_call_arg"
1738
+ },
1739
+ {
1740
+ "type": "REPEAT",
1741
+ "content": {
1742
+ "type": "SEQ",
1743
+ "members": [
1744
+ {
1745
+ "type": "STRING",
1746
+ "value": ","
1747
+ },
1748
+ {
1749
+ "type": "SYMBOL",
1750
+ "name": "_call_arg"
1751
+ }
1752
+ ]
1753
+ }
1754
+ }
1755
+ ]
1756
+ },
1757
+ {
1758
+ "type": "BLANK"
1759
+ }
1760
+ ]
1761
+ },
1762
+ {
1763
+ "type": "STRING",
1764
+ "value": ")"
1765
+ }
1766
+ ]
1767
+ },
1768
+ "unqual_agg_body": {
1769
+ "type": "SEQ",
1770
+ "members": [
1771
+ {
1772
+ "type": "STRING",
1773
+ "value": "("
1774
+ },
1775
+ {
1776
+ "type": "CHOICE",
1777
+ "members": [
1778
+ {
1779
+ "type": "SEQ",
1780
+ "members": [
1781
+ {
1782
+ "type": "SYMBOL",
1783
+ "name": "varDecl"
1784
+ },
1785
+ {
1786
+ "type": "REPEAT",
1787
+ "content": {
1788
+ "type": "SEQ",
1789
+ "members": [
1790
+ {
1791
+ "type": "STRING",
1792
+ "value": ","
1793
+ },
1794
+ {
1795
+ "type": "SYMBOL",
1796
+ "name": "varDecl"
1797
+ }
1798
+ ]
1799
+ }
1800
+ }
1801
+ ]
1802
+ },
1803
+ {
1804
+ "type": "BLANK"
1805
+ }
1806
+ ]
1807
+ },
1808
+ {
1809
+ "type": "STRING",
1810
+ "value": "|"
1811
+ },
1812
+ {
1813
+ "type": "FIELD",
1814
+ "name": "guard",
1815
+ "content": {
1816
+ "type": "CHOICE",
1817
+ "members": [
1818
+ {
1819
+ "type": "SYMBOL",
1820
+ "name": "_exprOrTerm"
1821
+ },
1822
+ {
1823
+ "type": "BLANK"
1824
+ }
1825
+ ]
1826
+ }
1827
+ },
1828
+ {
1829
+ "type": "FIELD",
1830
+ "name": "asExprs",
1831
+ "content": {
1832
+ "type": "CHOICE",
1833
+ "members": [
1834
+ {
1835
+ "type": "SEQ",
1836
+ "members": [
1837
+ {
1838
+ "type": "STRING",
1839
+ "value": "|"
1840
+ },
1841
+ {
1842
+ "type": "SYMBOL",
1843
+ "name": "asExprs"
1844
+ }
1845
+ ]
1846
+ },
1847
+ {
1848
+ "type": "BLANK"
1849
+ }
1850
+ ]
1851
+ }
1852
+ },
1853
+ {
1854
+ "type": "STRING",
1855
+ "value": ")"
1856
+ }
1857
+ ]
1858
+ },
1859
+ "_call_or_unqual_agg_body": {
1860
+ "type": "CHOICE",
1861
+ "members": [
1862
+ {
1863
+ "type": "SYMBOL",
1864
+ "name": "call_body"
1865
+ },
1866
+ {
1867
+ "type": "SYMBOL",
1868
+ "name": "unqual_agg_body"
1869
+ }
1870
+ ]
1871
+ },
1872
+ "call_or_unqual_agg_expr": {
1873
+ "type": "PREC_DYNAMIC",
1874
+ "value": 10,
1875
+ "content": {
1876
+ "type": "SEQ",
1877
+ "members": [
1878
+ {
1879
+ "type": "SYMBOL",
1880
+ "name": "aritylessPredicateExpr"
1881
+ },
1882
+ {
1883
+ "type": "CHOICE",
1884
+ "members": [
1885
+ {
1886
+ "type": "SYMBOL",
1887
+ "name": "closure"
1888
+ },
1889
+ {
1890
+ "type": "BLANK"
1891
+ }
1892
+ ]
1893
+ },
1894
+ {
1895
+ "type": "SYMBOL",
1896
+ "name": "_call_or_unqual_agg_body"
1897
+ }
1898
+ ]
1899
+ }
1900
+ },
1901
+ "qualified_expr": {
1902
+ "type": "SEQ",
1903
+ "members": [
1904
+ {
1905
+ "type": "SYMBOL",
1906
+ "name": "_primary"
1907
+ },
1908
+ {
1909
+ "type": "STRING",
1910
+ "value": "."
1911
+ },
1912
+ {
1913
+ "type": "SYMBOL",
1914
+ "name": "qualifiedRhs"
1915
+ }
1916
+ ]
1917
+ },
1918
+ "super_ref": {
1919
+ "type": "SEQ",
1920
+ "members": [
1921
+ {
1922
+ "type": "CHOICE",
1923
+ "members": [
1924
+ {
1925
+ "type": "SEQ",
1926
+ "members": [
1927
+ {
1928
+ "type": "SYMBOL",
1929
+ "name": "typeExpr"
1930
+ },
1931
+ {
1932
+ "type": "STRING",
1933
+ "value": "."
1934
+ }
1935
+ ]
1936
+ },
1937
+ {
1938
+ "type": "BLANK"
1939
+ }
1940
+ ]
1941
+ },
1942
+ {
1943
+ "type": "SYMBOL",
1944
+ "name": "super"
1945
+ }
1946
+ ]
1947
+ },
1948
+ "full_aggregate_body": {
1949
+ "type": "CHOICE",
1950
+ "members": [
1951
+ {
1952
+ "type": "SEQ",
1953
+ "members": [
1954
+ {
1955
+ "type": "CHOICE",
1956
+ "members": [
1957
+ {
1958
+ "type": "SEQ",
1959
+ "members": [
1960
+ {
1961
+ "type": "SYMBOL",
1962
+ "name": "varDecl"
1963
+ },
1964
+ {
1965
+ "type": "REPEAT",
1966
+ "content": {
1967
+ "type": "SEQ",
1968
+ "members": [
1969
+ {
1970
+ "type": "STRING",
1971
+ "value": ","
1972
+ },
1973
+ {
1974
+ "type": "SYMBOL",
1975
+ "name": "varDecl"
1976
+ }
1977
+ ]
1978
+ }
1979
+ }
1980
+ ]
1981
+ },
1982
+ {
1983
+ "type": "BLANK"
1984
+ }
1985
+ ]
1986
+ },
1987
+ {
1988
+ "type": "SEQ",
1989
+ "members": [
1990
+ {
1991
+ "type": "STRING",
1992
+ "value": "|"
1993
+ },
1994
+ {
1995
+ "type": "FIELD",
1996
+ "name": "guard",
1997
+ "content": {
1998
+ "type": "CHOICE",
1999
+ "members": [
2000
+ {
2001
+ "type": "SYMBOL",
2002
+ "name": "_exprOrTerm"
2003
+ },
2004
+ {
2005
+ "type": "BLANK"
2006
+ }
2007
+ ]
2008
+ }
2009
+ },
2010
+ {
2011
+ "type": "CHOICE",
2012
+ "members": [
2013
+ {
2014
+ "type": "SEQ",
2015
+ "members": [
2016
+ {
2017
+ "type": "STRING",
2018
+ "value": "|"
2019
+ },
2020
+ {
2021
+ "type": "FIELD",
2022
+ "name": "asExprs",
2023
+ "content": {
2024
+ "type": "SYMBOL",
2025
+ "name": "asExprs"
2026
+ }
2027
+ },
2028
+ {
2029
+ "type": "FIELD",
2030
+ "name": "orderBys",
2031
+ "content": {
2032
+ "type": "CHOICE",
2033
+ "members": [
2034
+ {
2035
+ "type": "SYMBOL",
2036
+ "name": "orderBys"
2037
+ },
2038
+ {
2039
+ "type": "BLANK"
2040
+ }
2041
+ ]
2042
+ }
2043
+ }
2044
+ ]
2045
+ },
2046
+ {
2047
+ "type": "BLANK"
2048
+ }
2049
+ ]
2050
+ }
2051
+ ]
2052
+ }
2053
+ ]
2054
+ },
2055
+ {
2056
+ "type": "SEQ",
2057
+ "members": [
2058
+ {
2059
+ "type": "SYMBOL",
2060
+ "name": "varDecl"
2061
+ },
2062
+ {
2063
+ "type": "REPEAT",
2064
+ "content": {
2065
+ "type": "SEQ",
2066
+ "members": [
2067
+ {
2068
+ "type": "STRING",
2069
+ "value": ","
2070
+ },
2071
+ {
2072
+ "type": "SYMBOL",
2073
+ "name": "varDecl"
2074
+ }
2075
+ ]
2076
+ }
2077
+ }
2078
+ ]
2079
+ }
2080
+ ]
2081
+ },
2082
+ "expr_aggregate_body": {
2083
+ "type": "SEQ",
2084
+ "members": [
2085
+ {
2086
+ "type": "FIELD",
2087
+ "name": "asExprs",
2088
+ "content": {
2089
+ "type": "SYMBOL",
2090
+ "name": "asExprs"
2091
+ }
2092
+ },
2093
+ {
2094
+ "type": "FIELD",
2095
+ "name": "orderBys",
2096
+ "content": {
2097
+ "type": "CHOICE",
2098
+ "members": [
2099
+ {
2100
+ "type": "SYMBOL",
2101
+ "name": "orderBys"
2102
+ },
2103
+ {
2104
+ "type": "BLANK"
2105
+ }
2106
+ ]
2107
+ }
2108
+ }
2109
+ ]
2110
+ },
2111
+ "aggregate": {
2112
+ "type": "SEQ",
2113
+ "members": [
2114
+ {
2115
+ "type": "SYMBOL",
2116
+ "name": "aggId"
2117
+ },
2118
+ {
2119
+ "type": "CHOICE",
2120
+ "members": [
2121
+ {
2122
+ "type": "SEQ",
2123
+ "members": [
2124
+ {
2125
+ "type": "STRING",
2126
+ "value": "["
2127
+ },
2128
+ {
2129
+ "type": "SEQ",
2130
+ "members": [
2131
+ {
2132
+ "type": "SYMBOL",
2133
+ "name": "_exprOrTerm"
2134
+ },
2135
+ {
2136
+ "type": "REPEAT",
2137
+ "content": {
2138
+ "type": "SEQ",
2139
+ "members": [
2140
+ {
2141
+ "type": "STRING",
2142
+ "value": ","
2143
+ },
2144
+ {
2145
+ "type": "SYMBOL",
2146
+ "name": "_exprOrTerm"
2147
+ }
2148
+ ]
2149
+ }
2150
+ }
2151
+ ]
2152
+ },
2153
+ {
2154
+ "type": "STRING",
2155
+ "value": "]"
2156
+ }
2157
+ ]
2158
+ },
2159
+ {
2160
+ "type": "BLANK"
2161
+ }
2162
+ ]
2163
+ },
2164
+ {
2165
+ "type": "STRING",
2166
+ "value": "("
2167
+ },
2168
+ {
2169
+ "type": "CHOICE",
2170
+ "members": [
2171
+ {
2172
+ "type": "CHOICE",
2173
+ "members": [
2174
+ {
2175
+ "type": "SYMBOL",
2176
+ "name": "full_aggregate_body"
2177
+ },
2178
+ {
2179
+ "type": "SYMBOL",
2180
+ "name": "expr_aggregate_body"
2181
+ }
2182
+ ]
2183
+ },
2184
+ {
2185
+ "type": "BLANK"
2186
+ }
2187
+ ]
2188
+ },
2189
+ {
2190
+ "type": "STRING",
2191
+ "value": ")"
2192
+ }
2193
+ ]
2194
+ },
2195
+ "range": {
2196
+ "type": "SEQ",
2197
+ "members": [
2198
+ {
2199
+ "type": "STRING",
2200
+ "value": "["
2201
+ },
2202
+ {
2203
+ "type": "FIELD",
2204
+ "name": "lower",
2205
+ "content": {
2206
+ "type": "SYMBOL",
2207
+ "name": "_exprOrTerm"
2208
+ }
2209
+ },
2210
+ {
2211
+ "type": "STRING",
2212
+ "value": ".."
2213
+ },
2214
+ {
2215
+ "type": "FIELD",
2216
+ "name": "upper",
2217
+ "content": {
2218
+ "type": "SYMBOL",
2219
+ "name": "_exprOrTerm"
2220
+ }
2221
+ },
2222
+ {
2223
+ "type": "STRING",
2224
+ "value": "]"
2225
+ }
2226
+ ]
2227
+ },
2228
+ "set_literal": {
2229
+ "type": "SEQ",
2230
+ "members": [
2231
+ {
2232
+ "type": "STRING",
2233
+ "value": "["
2234
+ },
2235
+ {
2236
+ "type": "CHOICE",
2237
+ "members": [
2238
+ {
2239
+ "type": "SEQ",
2240
+ "members": [
2241
+ {
2242
+ "type": "SYMBOL",
2243
+ "name": "_exprOrTerm"
2244
+ },
2245
+ {
2246
+ "type": "REPEAT",
2247
+ "content": {
2248
+ "type": "SEQ",
2249
+ "members": [
2250
+ {
2251
+ "type": "STRING",
2252
+ "value": ","
2253
+ },
2254
+ {
2255
+ "type": "SYMBOL",
2256
+ "name": "_exprOrTerm"
2257
+ }
2258
+ ]
2259
+ }
2260
+ }
2261
+ ]
2262
+ },
2263
+ {
2264
+ "type": "BLANK"
2265
+ }
2266
+ ]
2267
+ },
2268
+ {
2269
+ "type": "CHOICE",
2270
+ "members": [
2271
+ {
2272
+ "type": "STRING",
2273
+ "value": ","
2274
+ },
2275
+ {
2276
+ "type": "BLANK"
2277
+ }
2278
+ ]
2279
+ },
2280
+ {
2281
+ "type": "STRING",
2282
+ "value": "]"
2283
+ }
2284
+ ]
2285
+ },
2286
+ "par_expr": {
2287
+ "type": "SEQ",
2288
+ "members": [
2289
+ {
2290
+ "type": "STRING",
2291
+ "value": "("
2292
+ },
2293
+ {
2294
+ "type": "SYMBOL",
2295
+ "name": "_exprOrTerm"
2296
+ },
2297
+ {
2298
+ "type": "STRING",
2299
+ "value": ")"
2300
+ }
2301
+ ]
2302
+ },
2303
+ "expr_annotation": {
2304
+ "type": "SEQ",
2305
+ "members": [
2306
+ {
2307
+ "type": "FIELD",
2308
+ "name": "name",
2309
+ "content": {
2310
+ "type": "SYMBOL",
2311
+ "name": "annotName"
2312
+ }
2313
+ },
2314
+ {
2315
+ "type": "STRING",
2316
+ "value": "["
2317
+ },
2318
+ {
2319
+ "type": "FIELD",
2320
+ "name": "annot_arg",
2321
+ "content": {
2322
+ "type": "SYMBOL",
2323
+ "name": "annotName"
2324
+ }
2325
+ },
2326
+ {
2327
+ "type": "STRING",
2328
+ "value": "]"
2329
+ },
2330
+ {
2331
+ "type": "STRING",
2332
+ "value": "("
2333
+ },
2334
+ {
2335
+ "type": "SYMBOL",
2336
+ "name": "_exprOrTerm"
2337
+ },
2338
+ {
2339
+ "type": "STRING",
2340
+ "value": ")"
2341
+ }
2342
+ ]
2343
+ },
2344
+ "_exprOrTerm": {
2345
+ "type": "CHOICE",
2346
+ "members": [
2347
+ {
2348
+ "type": "SYMBOL",
2349
+ "name": "special_call"
2350
+ },
2351
+ {
2352
+ "type": "SYMBOL",
2353
+ "name": "prefix_cast"
2354
+ },
2355
+ {
2356
+ "type": "SYMBOL",
2357
+ "name": "_primary"
2358
+ },
2359
+ {
2360
+ "type": "SYMBOL",
2361
+ "name": "unary_expr"
2362
+ },
2363
+ {
2364
+ "type": "SYMBOL",
2365
+ "name": "mul_expr"
2366
+ },
2367
+ {
2368
+ "type": "SYMBOL",
2369
+ "name": "add_expr"
2370
+ },
2371
+ {
2372
+ "type": "SYMBOL",
2373
+ "name": "in_expr"
2374
+ },
2375
+ {
2376
+ "type": "SYMBOL",
2377
+ "name": "comp_term"
2378
+ },
2379
+ {
2380
+ "type": "SYMBOL",
2381
+ "name": "instance_of"
2382
+ },
2383
+ {
2384
+ "type": "SYMBOL",
2385
+ "name": "negation"
2386
+ },
2387
+ {
2388
+ "type": "SYMBOL",
2389
+ "name": "if_term"
2390
+ },
2391
+ {
2392
+ "type": "SYMBOL",
2393
+ "name": "conjunction"
2394
+ },
2395
+ {
2396
+ "type": "SYMBOL",
2397
+ "name": "disjunction"
2398
+ },
2399
+ {
2400
+ "type": "SYMBOL",
2401
+ "name": "implication"
2402
+ },
2403
+ {
2404
+ "type": "SYMBOL",
2405
+ "name": "quantified"
2406
+ }
2407
+ ]
2408
+ },
2409
+ "_primary": {
2410
+ "type": "CHOICE",
2411
+ "members": [
2412
+ {
2413
+ "type": "SYMBOL",
2414
+ "name": "call_or_unqual_agg_expr"
2415
+ },
2416
+ {
2417
+ "type": "SYMBOL",
2418
+ "name": "qualified_expr"
2419
+ },
2420
+ {
2421
+ "type": "SYMBOL",
2422
+ "name": "literal"
2423
+ },
2424
+ {
2425
+ "type": "SYMBOL",
2426
+ "name": "variable"
2427
+ },
2428
+ {
2429
+ "type": "SYMBOL",
2430
+ "name": "super_ref"
2431
+ },
2432
+ {
2433
+ "type": "SYMBOL",
2434
+ "name": "aggregate"
2435
+ },
2436
+ {
2437
+ "type": "SYMBOL",
2438
+ "name": "range"
2439
+ },
2440
+ {
2441
+ "type": "SYMBOL",
2442
+ "name": "set_literal"
2443
+ },
2444
+ {
2445
+ "type": "SYMBOL",
2446
+ "name": "par_expr"
2447
+ },
2448
+ {
2449
+ "type": "SYMBOL",
2450
+ "name": "expr_annotation"
2451
+ }
2452
+ ]
2453
+ },
2454
+ "literal": {
2455
+ "type": "CHOICE",
2456
+ "members": [
2457
+ {
2458
+ "type": "SYMBOL",
2459
+ "name": "integer"
2460
+ },
2461
+ {
2462
+ "type": "SYMBOL",
2463
+ "name": "float"
2464
+ },
2465
+ {
2466
+ "type": "SYMBOL",
2467
+ "name": "bool"
2468
+ },
2469
+ {
2470
+ "type": "SYMBOL",
2471
+ "name": "string"
2472
+ }
2473
+ ]
2474
+ },
2475
+ "bool": {
2476
+ "type": "CHOICE",
2477
+ "members": [
2478
+ {
2479
+ "type": "SYMBOL",
2480
+ "name": "true"
2481
+ },
2482
+ {
2483
+ "type": "SYMBOL",
2484
+ "name": "false"
2485
+ }
2486
+ ]
2487
+ },
2488
+ "variable": {
2489
+ "type": "CHOICE",
2490
+ "members": [
2491
+ {
2492
+ "type": "SYMBOL",
2493
+ "name": "this"
2494
+ },
2495
+ {
2496
+ "type": "SYMBOL",
2497
+ "name": "result"
2498
+ },
2499
+ {
2500
+ "type": "SYMBOL",
2501
+ "name": "varName"
2502
+ }
2503
+ ]
2504
+ },
2505
+ "compop": {
2506
+ "type": "CHOICE",
2507
+ "members": [
2508
+ {
2509
+ "type": "STRING",
2510
+ "value": "="
2511
+ },
2512
+ {
2513
+ "type": "STRING",
2514
+ "value": "!="
2515
+ },
2516
+ {
2517
+ "type": "STRING",
2518
+ "value": "<"
2519
+ },
2520
+ {
2521
+ "type": "STRING",
2522
+ "value": ">"
2523
+ },
2524
+ {
2525
+ "type": "STRING",
2526
+ "value": "<="
2527
+ },
2528
+ {
2529
+ "type": "STRING",
2530
+ "value": ">="
2531
+ }
2532
+ ]
2533
+ },
2534
+ "unop": {
2535
+ "type": "CHOICE",
2536
+ "members": [
2537
+ {
2538
+ "type": "STRING",
2539
+ "value": "+"
2540
+ },
2541
+ {
2542
+ "type": "STRING",
2543
+ "value": "-"
2544
+ }
2545
+ ]
2546
+ },
2547
+ "mulop": {
2548
+ "type": "CHOICE",
2549
+ "members": [
2550
+ {
2551
+ "type": "STRING",
2552
+ "value": "*"
2553
+ },
2554
+ {
2555
+ "type": "STRING",
2556
+ "value": "/"
2557
+ },
2558
+ {
2559
+ "type": "STRING",
2560
+ "value": "%"
2561
+ }
2562
+ ]
2563
+ },
2564
+ "addop": {
2565
+ "type": "CHOICE",
2566
+ "members": [
2567
+ {
2568
+ "type": "STRING",
2569
+ "value": "+"
2570
+ },
2571
+ {
2572
+ "type": "STRING",
2573
+ "value": "-"
2574
+ }
2575
+ ]
2576
+ },
2577
+ "closure": {
2578
+ "type": "CHOICE",
2579
+ "members": [
2580
+ {
2581
+ "type": "STRING",
2582
+ "value": "*"
2583
+ },
2584
+ {
2585
+ "type": "STRING",
2586
+ "value": "+"
2587
+ }
2588
+ ]
2589
+ },
2590
+ "direction": {
2591
+ "type": "CHOICE",
2592
+ "members": [
2593
+ {
2594
+ "type": "STRING",
2595
+ "value": "asc"
2596
+ },
2597
+ {
2598
+ "type": "STRING",
2599
+ "value": "desc"
2600
+ }
2601
+ ]
2602
+ },
2603
+ "varDecl": {
2604
+ "type": "SEQ",
2605
+ "members": [
2606
+ {
2607
+ "type": "SYMBOL",
2608
+ "name": "typeExpr"
2609
+ },
2610
+ {
2611
+ "type": "SYMBOL",
2612
+ "name": "varName"
2613
+ }
2614
+ ]
2615
+ },
2616
+ "moduleParam": {
2617
+ "type": "SEQ",
2618
+ "members": [
2619
+ {
2620
+ "type": "FIELD",
2621
+ "name": "signature",
2622
+ "content": {
2623
+ "type": "SYMBOL",
2624
+ "name": "signatureExpr"
2625
+ }
2626
+ },
2627
+ {
2628
+ "type": "FIELD",
2629
+ "name": "parameter",
2630
+ "content": {
2631
+ "type": "SYMBOL",
2632
+ "name": "simpleId"
2633
+ }
2634
+ }
2635
+ ]
2636
+ },
2637
+ "asExprs": {
2638
+ "type": "SEQ",
2639
+ "members": [
2640
+ {
2641
+ "type": "SYMBOL",
2642
+ "name": "asExpr"
2643
+ },
2644
+ {
2645
+ "type": "REPEAT",
2646
+ "content": {
2647
+ "type": "SEQ",
2648
+ "members": [
2649
+ {
2650
+ "type": "STRING",
2651
+ "value": ","
2652
+ },
2653
+ {
2654
+ "type": "SYMBOL",
2655
+ "name": "asExpr"
2656
+ }
2657
+ ]
2658
+ }
2659
+ }
2660
+ ]
2661
+ },
2662
+ "asExpr": {
2663
+ "type": "SEQ",
2664
+ "members": [
2665
+ {
2666
+ "type": "SYMBOL",
2667
+ "name": "_exprOrTerm"
2668
+ },
2669
+ {
2670
+ "type": "CHOICE",
2671
+ "members": [
2672
+ {
2673
+ "type": "SEQ",
2674
+ "members": [
2675
+ {
2676
+ "type": "STRING",
2677
+ "value": "as"
2678
+ },
2679
+ {
2680
+ "type": "SYMBOL",
2681
+ "name": "varName"
2682
+ }
2683
+ ]
2684
+ },
2685
+ {
2686
+ "type": "BLANK"
2687
+ }
2688
+ ]
2689
+ }
2690
+ ]
2691
+ },
2692
+ "orderBys": {
2693
+ "type": "SEQ",
2694
+ "members": [
2695
+ {
2696
+ "type": "STRING",
2697
+ "value": "order"
2698
+ },
2699
+ {
2700
+ "type": "STRING",
2701
+ "value": "by"
2702
+ },
2703
+ {
2704
+ "type": "SEQ",
2705
+ "members": [
2706
+ {
2707
+ "type": "SYMBOL",
2708
+ "name": "orderBy"
2709
+ },
2710
+ {
2711
+ "type": "REPEAT",
2712
+ "content": {
2713
+ "type": "SEQ",
2714
+ "members": [
2715
+ {
2716
+ "type": "STRING",
2717
+ "value": ","
2718
+ },
2719
+ {
2720
+ "type": "SYMBOL",
2721
+ "name": "orderBy"
2722
+ }
2723
+ ]
2724
+ }
2725
+ }
2726
+ ]
2727
+ }
2728
+ ]
2729
+ },
2730
+ "orderBy": {
2731
+ "type": "SEQ",
2732
+ "members": [
2733
+ {
2734
+ "type": "SYMBOL",
2735
+ "name": "_exprOrTerm"
2736
+ },
2737
+ {
2738
+ "type": "CHOICE",
2739
+ "members": [
2740
+ {
2741
+ "type": "SYMBOL",
2742
+ "name": "direction"
2743
+ },
2744
+ {
2745
+ "type": "BLANK"
2746
+ }
2747
+ ]
2748
+ }
2749
+ ]
2750
+ },
2751
+ "qldoc": {
2752
+ "type": "PATTERN",
2753
+ "value": "\\/\\*\\*[^*]*\\*+([^/*][^*]*\\*+)*\\/"
2754
+ },
2755
+ "literalId": {
2756
+ "type": "CHOICE",
2757
+ "members": [
2758
+ {
2759
+ "type": "SYMBOL",
2760
+ "name": "_lower_id"
2761
+ },
2762
+ {
2763
+ "type": "SYMBOL",
2764
+ "name": "_upper_id"
2765
+ }
2766
+ ]
2767
+ },
2768
+ "annotation": {
2769
+ "type": "CHOICE",
2770
+ "members": [
2771
+ {
2772
+ "type": "FIELD",
2773
+ "name": "name",
2774
+ "content": {
2775
+ "type": "SYMBOL",
2776
+ "name": "annotName"
2777
+ }
2778
+ },
2779
+ {
2780
+ "type": "SEQ",
2781
+ "members": [
2782
+ {
2783
+ "type": "FIELD",
2784
+ "name": "name",
2785
+ "content": {
2786
+ "type": "SYMBOL",
2787
+ "name": "annotName"
2788
+ }
2789
+ },
2790
+ {
2791
+ "type": "STRING",
2792
+ "value": "["
2793
+ },
2794
+ {
2795
+ "type": "FIELD",
2796
+ "name": "args",
2797
+ "content": {
2798
+ "type": "SEQ",
2799
+ "members": [
2800
+ {
2801
+ "type": "SYMBOL",
2802
+ "name": "annotArg"
2803
+ },
2804
+ {
2805
+ "type": "REPEAT",
2806
+ "content": {
2807
+ "type": "SEQ",
2808
+ "members": [
2809
+ {
2810
+ "type": "STRING",
2811
+ "value": ","
2812
+ },
2813
+ {
2814
+ "type": "SYMBOL",
2815
+ "name": "annotArg"
2816
+ }
2817
+ ]
2818
+ }
2819
+ }
2820
+ ]
2821
+ }
2822
+ },
2823
+ {
2824
+ "type": "STRING",
2825
+ "value": "]"
2826
+ }
2827
+ ]
2828
+ }
2829
+ ]
2830
+ },
2831
+ "annotName": {
2832
+ "type": "SYMBOL",
2833
+ "name": "_lower_id"
2834
+ },
2835
+ "annotArg": {
2836
+ "type": "CHOICE",
2837
+ "members": [
2838
+ {
2839
+ "type": "SYMBOL",
2840
+ "name": "simpleId"
2841
+ },
2842
+ {
2843
+ "type": "SYMBOL",
2844
+ "name": "this"
2845
+ },
2846
+ {
2847
+ "type": "SYMBOL",
2848
+ "name": "result"
2849
+ }
2850
+ ]
2851
+ },
2852
+ "moduleName": {
2853
+ "type": "SYMBOL",
2854
+ "name": "simpleId"
2855
+ },
2856
+ "importModuleExpr": {
2857
+ "type": "SEQ",
2858
+ "members": [
2859
+ {
2860
+ "type": "REPEAT",
2861
+ "content": {
2862
+ "type": "SEQ",
2863
+ "members": [
2864
+ {
2865
+ "type": "FIELD",
2866
+ "name": "qualName",
2867
+ "content": {
2868
+ "type": "SYMBOL",
2869
+ "name": "simpleId"
2870
+ }
2871
+ },
2872
+ {
2873
+ "type": "STRING",
2874
+ "value": "."
2875
+ }
2876
+ ]
2877
+ }
2878
+ },
2879
+ {
2880
+ "type": "SYMBOL",
2881
+ "name": "moduleExpr"
2882
+ }
2883
+ ]
2884
+ },
2885
+ "moduleExpr": {
2886
+ "type": "CHOICE",
2887
+ "members": [
2888
+ {
2889
+ "type": "SYMBOL",
2890
+ "name": "simpleId"
2891
+ },
2892
+ {
2893
+ "type": "SYMBOL",
2894
+ "name": "moduleInstantiation"
2895
+ },
2896
+ {
2897
+ "type": "SEQ",
2898
+ "members": [
2899
+ {
2900
+ "type": "SYMBOL",
2901
+ "name": "moduleExpr"
2902
+ },
2903
+ {
2904
+ "type": "STRING",
2905
+ "value": "::"
2906
+ },
2907
+ {
2908
+ "type": "FIELD",
2909
+ "name": "name",
2910
+ "content": {
2911
+ "type": "CHOICE",
2912
+ "members": [
2913
+ {
2914
+ "type": "SYMBOL",
2915
+ "name": "simpleId"
2916
+ },
2917
+ {
2918
+ "type": "SYMBOL",
2919
+ "name": "moduleInstantiation"
2920
+ }
2921
+ ]
2922
+ }
2923
+ }
2924
+ ]
2925
+ }
2926
+ ]
2927
+ },
2928
+ "moduleInstantiation": {
2929
+ "type": "SEQ",
2930
+ "members": [
2931
+ {
2932
+ "type": "FIELD",
2933
+ "name": "name",
2934
+ "content": {
2935
+ "type": "SYMBOL",
2936
+ "name": "moduleName"
2937
+ }
2938
+ },
2939
+ {
2940
+ "type": "STRING",
2941
+ "value": "<"
2942
+ },
2943
+ {
2944
+ "type": "SEQ",
2945
+ "members": [
2946
+ {
2947
+ "type": "SYMBOL",
2948
+ "name": "signatureExpr"
2949
+ },
2950
+ {
2951
+ "type": "REPEAT",
2952
+ "content": {
2953
+ "type": "SEQ",
2954
+ "members": [
2955
+ {
2956
+ "type": "STRING",
2957
+ "value": ","
2958
+ },
2959
+ {
2960
+ "type": "SYMBOL",
2961
+ "name": "signatureExpr"
2962
+ }
2963
+ ]
2964
+ }
2965
+ }
2966
+ ]
2967
+ },
2968
+ {
2969
+ "type": "STRING",
2970
+ "value": ">"
2971
+ }
2972
+ ]
2973
+ },
2974
+ "primitiveType": {
2975
+ "type": "CHOICE",
2976
+ "members": [
2977
+ {
2978
+ "type": "STRING",
2979
+ "value": "boolean"
2980
+ },
2981
+ {
2982
+ "type": "STRING",
2983
+ "value": "date"
2984
+ },
2985
+ {
2986
+ "type": "STRING",
2987
+ "value": "float"
2988
+ },
2989
+ {
2990
+ "type": "STRING",
2991
+ "value": "int"
2992
+ },
2993
+ {
2994
+ "type": "STRING",
2995
+ "value": "string"
2996
+ }
2997
+ ]
2998
+ },
2999
+ "simpleId": {
3000
+ "type": "CHOICE",
3001
+ "members": [
3002
+ {
3003
+ "type": "SYMBOL",
3004
+ "name": "_lower_id"
3005
+ },
3006
+ {
3007
+ "type": "SYMBOL",
3008
+ "name": "_upper_id"
3009
+ }
3010
+ ]
3011
+ },
3012
+ "className": {
3013
+ "type": "SYMBOL",
3014
+ "name": "_upper_id"
3015
+ },
3016
+ "dbtype": {
3017
+ "type": "PATTERN",
3018
+ "value": "@[a-z][A-Za-z0-9_]*"
3019
+ },
3020
+ "typeExpr": {
3021
+ "type": "CHOICE",
3022
+ "members": [
3023
+ {
3024
+ "type": "SEQ",
3025
+ "members": [
3026
+ {
3027
+ "type": "CHOICE",
3028
+ "members": [
3029
+ {
3030
+ "type": "SEQ",
3031
+ "members": [
3032
+ {
3033
+ "type": "FIELD",
3034
+ "name": "qualifier",
3035
+ "content": {
3036
+ "type": "SYMBOL",
3037
+ "name": "moduleExpr"
3038
+ }
3039
+ },
3040
+ {
3041
+ "type": "STRING",
3042
+ "value": "::"
3043
+ }
3044
+ ]
3045
+ },
3046
+ {
3047
+ "type": "BLANK"
3048
+ }
3049
+ ]
3050
+ },
3051
+ {
3052
+ "type": "FIELD",
3053
+ "name": "name",
3054
+ "content": {
3055
+ "type": "SYMBOL",
3056
+ "name": "className"
3057
+ }
3058
+ }
3059
+ ]
3060
+ },
3061
+ {
3062
+ "type": "SYMBOL",
3063
+ "name": "dbtype"
3064
+ },
3065
+ {
3066
+ "type": "SYMBOL",
3067
+ "name": "primitiveType"
3068
+ }
3069
+ ]
3070
+ },
3071
+ "signatureExpr": {
3072
+ "type": "CHOICE",
3073
+ "members": [
3074
+ {
3075
+ "type": "FIELD",
3076
+ "name": "type_expr",
3077
+ "content": {
3078
+ "type": "SYMBOL",
3079
+ "name": "typeExpr"
3080
+ }
3081
+ },
3082
+ {
3083
+ "type": "FIELD",
3084
+ "name": "mod_expr",
3085
+ "content": {
3086
+ "type": "SYMBOL",
3087
+ "name": "moduleExpr"
3088
+ }
3089
+ },
3090
+ {
3091
+ "type": "FIELD",
3092
+ "name": "predicate",
3093
+ "content": {
3094
+ "type": "SYMBOL",
3095
+ "name": "predicateExpr"
3096
+ }
3097
+ }
3098
+ ]
3099
+ },
3100
+ "predicateName": {
3101
+ "type": "SYMBOL",
3102
+ "name": "_lower_id"
3103
+ },
3104
+ "aritylessPredicateExpr": {
3105
+ "type": "SEQ",
3106
+ "members": [
3107
+ {
3108
+ "type": "CHOICE",
3109
+ "members": [
3110
+ {
3111
+ "type": "SEQ",
3112
+ "members": [
3113
+ {
3114
+ "type": "FIELD",
3115
+ "name": "qualifier",
3116
+ "content": {
3117
+ "type": "SYMBOL",
3118
+ "name": "moduleExpr"
3119
+ }
3120
+ },
3121
+ {
3122
+ "type": "STRING",
3123
+ "value": "::"
3124
+ }
3125
+ ]
3126
+ },
3127
+ {
3128
+ "type": "BLANK"
3129
+ }
3130
+ ]
3131
+ },
3132
+ {
3133
+ "type": "FIELD",
3134
+ "name": "name",
3135
+ "content": {
3136
+ "type": "SYMBOL",
3137
+ "name": "literalId"
3138
+ }
3139
+ }
3140
+ ]
3141
+ },
3142
+ "predicateExpr": {
3143
+ "type": "SEQ",
3144
+ "members": [
3145
+ {
3146
+ "type": "SYMBOL",
3147
+ "name": "aritylessPredicateExpr"
3148
+ },
3149
+ {
3150
+ "type": "STRING",
3151
+ "value": "/"
3152
+ },
3153
+ {
3154
+ "type": "SYMBOL",
3155
+ "name": "integer"
3156
+ }
3157
+ ]
3158
+ },
3159
+ "varName": {
3160
+ "type": "SYMBOL",
3161
+ "name": "simpleId"
3162
+ },
3163
+ "aggId": {
3164
+ "type": "CHOICE",
3165
+ "members": [
3166
+ {
3167
+ "type": "STRING",
3168
+ "value": "avg"
3169
+ },
3170
+ {
3171
+ "type": "STRING",
3172
+ "value": "concat"
3173
+ },
3174
+ {
3175
+ "type": "STRING",
3176
+ "value": "strictconcat"
3177
+ },
3178
+ {
3179
+ "type": "STRING",
3180
+ "value": "count"
3181
+ },
3182
+ {
3183
+ "type": "STRING",
3184
+ "value": "max"
3185
+ },
3186
+ {
3187
+ "type": "STRING",
3188
+ "value": "min"
3189
+ },
3190
+ {
3191
+ "type": "STRING",
3192
+ "value": "rank"
3193
+ },
3194
+ {
3195
+ "type": "STRING",
3196
+ "value": "strictcount"
3197
+ },
3198
+ {
3199
+ "type": "STRING",
3200
+ "value": "strictsum"
3201
+ },
3202
+ {
3203
+ "type": "STRING",
3204
+ "value": "sum"
3205
+ },
3206
+ {
3207
+ "type": "STRING",
3208
+ "value": "any"
3209
+ },
3210
+ {
3211
+ "type": "STRING",
3212
+ "value": "unique"
3213
+ }
3214
+ ]
3215
+ },
3216
+ "_upper_id": {
3217
+ "type": "PATTERN",
3218
+ "value": "[A-Z][A-Za-z0-9_]*"
3219
+ },
3220
+ "_lower_id": {
3221
+ "type": "PATTERN",
3222
+ "value": "[a-z][A-Za-z0-9_]*"
3223
+ },
3224
+ "integer": {
3225
+ "type": "PATTERN",
3226
+ "value": "[0-9]+"
3227
+ },
3228
+ "float": {
3229
+ "type": "PATTERN",
3230
+ "value": "[0-9]+\\.[0-9]+"
3231
+ },
3232
+ "string": {
3233
+ "type": "PATTERN",
3234
+ "value": "\"([^\"\\\\\\r\\n\\t]|\\\\[\"\\\\nrt])*\""
3235
+ },
3236
+ "line_comment": {
3237
+ "type": "PATTERN",
3238
+ "value": "\\/\\/[^\\r\\n]*"
3239
+ },
3240
+ "block_comment": {
3241
+ "type": "PATTERN",
3242
+ "value": "\\/\\*([^*]+\\*+([^/*][^*]*\\*+)*|\\*)\\/"
3243
+ },
3244
+ "false": {
3245
+ "type": "STRING",
3246
+ "value": "false"
3247
+ },
3248
+ "predicate": {
3249
+ "type": "STRING",
3250
+ "value": "predicate"
3251
+ },
3252
+ "result": {
3253
+ "type": "STRING",
3254
+ "value": "result"
3255
+ },
3256
+ "super": {
3257
+ "type": "STRING",
3258
+ "value": "super"
3259
+ },
3260
+ "this": {
3261
+ "type": "STRING",
3262
+ "value": "this"
3263
+ },
3264
+ "true": {
3265
+ "type": "STRING",
3266
+ "value": "true"
3267
+ }
3268
+ },
3269
+ "extras": [
3270
+ {
3271
+ "type": "PATTERN",
3272
+ "value": "[ \\t\\r\\n]"
3273
+ },
3274
+ {
3275
+ "type": "SYMBOL",
3276
+ "name": "line_comment"
3277
+ },
3278
+ {
3279
+ "type": "SYMBOL",
3280
+ "name": "block_comment"
3281
+ }
3282
+ ],
3283
+ "conflicts": [
3284
+ [
3285
+ "simpleId",
3286
+ "className"
3287
+ ],
3288
+ [
3289
+ "simpleId",
3290
+ "literalId"
3291
+ ],
3292
+ [
3293
+ "moduleName",
3294
+ "varName"
3295
+ ],
3296
+ [
3297
+ "simpleId",
3298
+ "moduleInstantiation"
3299
+ ],
3300
+ [
3301
+ "className",
3302
+ "moduleInstantiation"
3303
+ ]
3304
+ ],
3305
+ "precedences": [],
3306
+ "externals": [],
3307
+ "inline": [],
3308
+ "supertypes": []
3309
+ }
3310
+
vendor/tree-sitter-ql/src/node-types.json ADDED
The diff for this file is too large to render. See raw diff
 
vendor/tree-sitter-ql/src/parser.c ADDED
The diff for this file is too large to render. See raw diff
 
vendor/tree-sitter-ql/src/tree_sitter/parser.h ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef TREE_SITTER_PARSER_H_
2
+ #define TREE_SITTER_PARSER_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #include <stdbool.h>
9
+ #include <stdint.h>
10
+ #include <stdlib.h>
11
+
12
+ #define ts_builtin_sym_error ((TSSymbol)-1)
13
+ #define ts_builtin_sym_end 0
14
+ #define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
15
+
16
+ typedef uint16_t TSStateId;
17
+
18
+ #ifndef TREE_SITTER_API_H_
19
+ typedef uint16_t TSSymbol;
20
+ typedef uint16_t TSFieldId;
21
+ typedef struct TSLanguage TSLanguage;
22
+ #endif
23
+
24
+ typedef struct {
25
+ TSFieldId field_id;
26
+ uint8_t child_index;
27
+ bool inherited;
28
+ } TSFieldMapEntry;
29
+
30
+ typedef struct {
31
+ uint16_t index;
32
+ uint16_t length;
33
+ } TSFieldMapSlice;
34
+
35
+ typedef struct {
36
+ bool visible;
37
+ bool named;
38
+ bool supertype;
39
+ } TSSymbolMetadata;
40
+
41
+ typedef struct TSLexer TSLexer;
42
+
43
+ struct TSLexer {
44
+ int32_t lookahead;
45
+ TSSymbol result_symbol;
46
+ void (*advance)(TSLexer *, bool);
47
+ void (*mark_end)(TSLexer *);
48
+ uint32_t (*get_column)(TSLexer *);
49
+ bool (*is_at_included_range_start)(const TSLexer *);
50
+ bool (*eof)(const TSLexer *);
51
+ };
52
+
53
+ typedef enum {
54
+ TSParseActionTypeShift,
55
+ TSParseActionTypeReduce,
56
+ TSParseActionTypeAccept,
57
+ TSParseActionTypeRecover,
58
+ } TSParseActionType;
59
+
60
+ typedef union {
61
+ struct {
62
+ uint8_t type;
63
+ TSStateId state;
64
+ bool extra;
65
+ bool repetition;
66
+ } shift;
67
+ struct {
68
+ uint8_t type;
69
+ uint8_t child_count;
70
+ TSSymbol symbol;
71
+ int16_t dynamic_precedence;
72
+ uint16_t production_id;
73
+ } reduce;
74
+ uint8_t type;
75
+ } TSParseAction;
76
+
77
+ typedef struct {
78
+ uint16_t lex_state;
79
+ uint16_t external_lex_state;
80
+ } TSLexMode;
81
+
82
+ typedef union {
83
+ TSParseAction action;
84
+ struct {
85
+ uint8_t count;
86
+ bool reusable;
87
+ } entry;
88
+ } TSParseActionEntry;
89
+
90
+ struct TSLanguage {
91
+ uint32_t version;
92
+ uint32_t symbol_count;
93
+ uint32_t alias_count;
94
+ uint32_t token_count;
95
+ uint32_t external_token_count;
96
+ uint32_t state_count;
97
+ uint32_t large_state_count;
98
+ uint32_t production_id_count;
99
+ uint32_t field_count;
100
+ uint16_t max_alias_sequence_length;
101
+ const uint16_t *parse_table;
102
+ const uint16_t *small_parse_table;
103
+ const uint32_t *small_parse_table_map;
104
+ const TSParseActionEntry *parse_actions;
105
+ const char * const *symbol_names;
106
+ const char * const *field_names;
107
+ const TSFieldMapSlice *field_map_slices;
108
+ const TSFieldMapEntry *field_map_entries;
109
+ const TSSymbolMetadata *symbol_metadata;
110
+ const TSSymbol *public_symbol_map;
111
+ const uint16_t *alias_map;
112
+ const TSSymbol *alias_sequences;
113
+ const TSLexMode *lex_modes;
114
+ bool (*lex_fn)(TSLexer *, TSStateId);
115
+ bool (*keyword_lex_fn)(TSLexer *, TSStateId);
116
+ TSSymbol keyword_capture_token;
117
+ struct {
118
+ const bool *states;
119
+ const TSSymbol *symbol_map;
120
+ void *(*create)(void);
121
+ void (*destroy)(void *);
122
+ bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
123
+ unsigned (*serialize)(void *, char *);
124
+ void (*deserialize)(void *, const char *, unsigned);
125
+ } external_scanner;
126
+ const TSStateId *primary_state_ids;
127
+ };
128
+
129
+ /*
130
+ * Lexer Macros
131
+ */
132
+
133
+ #define START_LEXER() \
134
+ bool result = false; \
135
+ bool skip = false; \
136
+ bool eof = false; \
137
+ int32_t lookahead; \
138
+ goto start; \
139
+ next_state: \
140
+ lexer->advance(lexer, skip); \
141
+ start: \
142
+ skip = false; \
143
+ lookahead = lexer->lookahead;
144
+
145
+ #define ADVANCE(state_value) \
146
+ { \
147
+ state = state_value; \
148
+ goto next_state; \
149
+ }
150
+
151
+ #define SKIP(state_value) \
152
+ { \
153
+ skip = true; \
154
+ state = state_value; \
155
+ goto next_state; \
156
+ }
157
+
158
+ #define ACCEPT_TOKEN(symbol_value) \
159
+ result = true; \
160
+ lexer->result_symbol = symbol_value; \
161
+ lexer->mark_end(lexer);
162
+
163
+ #define END_STATE() return result;
164
+
165
+ /*
166
+ * Parse Table Macros
167
+ */
168
+
169
+ #define SMALL_STATE(id) id - LARGE_STATE_COUNT
170
+
171
+ #define STATE(id) id
172
+
173
+ #define ACTIONS(id) id
174
+
175
+ #define SHIFT(state_value) \
176
+ {{ \
177
+ .shift = { \
178
+ .type = TSParseActionTypeShift, \
179
+ .state = state_value \
180
+ } \
181
+ }}
182
+
183
+ #define SHIFT_REPEAT(state_value) \
184
+ {{ \
185
+ .shift = { \
186
+ .type = TSParseActionTypeShift, \
187
+ .state = state_value, \
188
+ .repetition = true \
189
+ } \
190
+ }}
191
+
192
+ #define SHIFT_EXTRA() \
193
+ {{ \
194
+ .shift = { \
195
+ .type = TSParseActionTypeShift, \
196
+ .extra = true \
197
+ } \
198
+ }}
199
+
200
+ #define REDUCE(symbol_val, child_count_val, ...) \
201
+ {{ \
202
+ .reduce = { \
203
+ .type = TSParseActionTypeReduce, \
204
+ .symbol = symbol_val, \
205
+ .child_count = child_count_val, \
206
+ __VA_ARGS__ \
207
+ }, \
208
+ }}
209
+
210
+ #define RECOVER() \
211
+ {{ \
212
+ .type = TSParseActionTypeRecover \
213
+ }}
214
+
215
+ #define ACCEPT_INPUT() \
216
+ {{ \
217
+ .type = TSParseActionTypeAccept \
218
+ }}
219
+
220
+ #ifdef __cplusplus
221
+ }
222
+ #endif
223
+
224
+ #endif // TREE_SITTER_PARSER_H_
vendor/tree-sitter-ql/test/corpus/basic.txt ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ============
2
+ Basic select
3
+ ============
4
+
5
+ import javascript
6
+
7
+ select
8
+ "hello world" as foo,
9
+ "other",
10
+ "string with escaped \\ backslashes \" quotes \n\r\t whitespace",
11
+ 1234,
12
+ 1234.4321,
13
+ true,
14
+ false
15
+
16
+ ---
17
+
18
+ (ql
19
+ (moduleMember (importDirective (importModuleExpr (moduleExpr (simpleId)))))
20
+ (moduleMember (select (asExprs
21
+ (asExpr (literal (string)) (varName (simpleId)))
22
+ (asExpr (literal (string)))
23
+ (asExpr (literal (string)))
24
+ (asExpr (literal (integer)))
25
+ (asExpr (literal (float)))
26
+ (asExpr (literal (bool (true))))
27
+ (asExpr (literal (bool (false))))))))
28
+
29
+ ============
30
+ Select with variables and order by
31
+ ============
32
+
33
+ from
34
+ Foo foo,
35
+ some::submodule::Bar bar,
36
+ @dbtype bar,
37
+ boolean b,
38
+ date d,
39
+ float f,
40
+ int i,
41
+ string s
42
+ select "hello world"
43
+ order by foo, bar desc, baz asc
44
+
45
+ ---
46
+
47
+ (ql (moduleMember
48
+ (select
49
+ (varDecl (typeExpr (className)) (varName (simpleId)))
50
+ (varDecl (typeExpr (moduleExpr (moduleExpr (simpleId)) (simpleId)) (className)) (varName (simpleId)))
51
+ (varDecl (typeExpr (dbtype)) (varName (simpleId)))
52
+ (varDecl (typeExpr (primitiveType)) (varName (simpleId)))
53
+ (varDecl (typeExpr (primitiveType)) (varName (simpleId)))
54
+ (varDecl (typeExpr (primitiveType)) (varName (simpleId)))
55
+ (varDecl (typeExpr (primitiveType)) (varName (simpleId)))
56
+ (varDecl (typeExpr (primitiveType)) (varName (simpleId)))
57
+ (asExprs
58
+ (asExpr (literal (string))))
59
+ (orderBys
60
+ (orderBy (variable (varName (simpleId))))
61
+ (orderBy (variable (varName (simpleId))) (direction))
62
+ (orderBy (variable (varName (simpleId))) (direction))))))
63
+
64
+ ========================
65
+ Annotations and comments
66
+ ========================
67
+
68
+ private import foo // some other comment
69
+
70
+ /*
71
+ * Some comment
72
+ */
73
+ pragma[noinline]
74
+ bindingset[foobar, this]
75
+ import bar
76
+
77
+ ---
78
+
79
+ (ql
80
+ (moduleMember (annotation (annotName)) (importDirective (importModuleExpr (moduleExpr (simpleId)))))
81
+ (line_comment) (block_comment)
82
+ (moduleMember
83
+ (annotation (annotName) (annotArg (simpleId)))
84
+ (annotation (annotName) (annotArg (simpleId)) (annotArg (this)))
85
+ (importDirective (importModuleExpr (moduleExpr (simpleId))))))
vendor/tree-sitter-ql/test/corpus/class.txt ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ===========
2
+ empty class
3
+ ===========
4
+
5
+ class Foo extends Bar {}
6
+
7
+ ---
8
+ (ql (moduleMember (dataclass (className) (typeExpr (className)))))
9
+
10
+ ===================================
11
+ class with characteristic predicate
12
+ ===================================
13
+
14
+ abstract class Foo extends Bar {
15
+
16
+ pragma[inline]
17
+ Foo() {
18
+ this = this
19
+ }
20
+
21
+ }
22
+
23
+ ---
24
+
25
+ (ql (moduleMember
26
+ (annotation (annotName))
27
+ (dataclass (className) (typeExpr (className))
28
+ (classMember (annotation (annotName) (annotArg (simpleId)))
29
+ (charpred (className)
30
+ (comp_term (variable (this)) (compop) (variable (this))))))))
31
+ ==================
32
+ class with members
33
+ ==================
34
+
35
+ class X extends Y {
36
+ m::F f;
37
+
38
+ m::F a() {
39
+ result = f
40
+ }
41
+ }
42
+
43
+ ---
44
+
45
+ (ql (moduleMember
46
+ (dataclass (className) (typeExpr (className))
47
+ (classMember (field (varDecl (typeExpr (moduleExpr (simpleId)) (className)) (varName (simpleId)))))
48
+ (classMember (memberPredicate (typeExpr (moduleExpr (simpleId)) (className)) (predicateName)
49
+ (body (comp_term (variable (result)) (compop) (variable (varName (simpleId))))))))))
50
+
51
+ ===========
52
+ class alias
53
+ ===========
54
+
55
+ class X = foo::Bas;
56
+
57
+ ---
58
+ (ql (moduleMember
59
+ (dataclass (className) (typeAliasBody (typeExpr (moduleExpr (simpleId)) (className))))))
60
+
61
+
62
+ ================
63
+ class instanceof
64
+ ================
65
+
66
+ class X extends Y1, Y2 instanceof Z1, Z2 {
67
+ X() { none() }
68
+ }
69
+
70
+ ---
71
+
72
+ (ql
73
+ (moduleMember
74
+ (dataclass
75
+ (className)
76
+ (typeExpr
77
+ (className))
78
+ (typeExpr
79
+ (className))
80
+ (typeExpr
81
+ (className))
82
+ (typeExpr
83
+ (className))
84
+ (classMember
85
+ (charpred
86
+ (className)
87
+ (special_call
88
+ (specialId)))))))
vendor/tree-sitter-ql/test/corpus/ctf.txt ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ =========================
2
+ dataflow example from ctf
3
+ =========================
4
+
5
+ from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
6
+ where cfg.hasFlowPath(source, sink)
7
+ select sink.getNode(), source, sink, "Potential XSS vulnerability in plugin."
8
+
9
+ ---
10
+
11
+ (ql (moduleMember
12
+ (select
13
+ (varDecl (typeExpr (className)) (varName (simpleId)))
14
+ (varDecl (typeExpr (moduleExpr (simpleId)) (className)) (varName (simpleId)))
15
+ (varDecl (typeExpr (moduleExpr (simpleId)) (className)) (varName (simpleId)))
16
+ (qualified_expr
17
+ (variable (varName (simpleId)))
18
+ (qualifiedRhs (predicateName) (variable (varName (simpleId))) (variable (varName (simpleId)))))
19
+ (asExprs
20
+ (asExpr (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName))))
21
+ (asExpr (variable (varName (simpleId))))
22
+ (asExpr (variable (varName (simpleId))))
23
+ (asExpr (literal (string)))))))
vendor/tree-sitter-ql/test/corpus/expr.txt ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ====
2
+ cast
3
+ ====
4
+
5
+ select (Foo) f
6
+
7
+ ---
8
+ (ql (moduleMember (select (asExprs (asExpr (prefix_cast (typeExpr (className)) (variable (varName (simpleId)))))))))
9
+ ========
10
+ dontcare
11
+ ========
12
+
13
+ select foo(_)
14
+
15
+ ---
16
+ (ql (moduleMember (select (asExprs (asExpr (call_or_unqual_agg_expr (aritylessPredicateExpr (literalId)) (call_body (underscore))))))))
17
+ ====
18
+ unop
19
+ ====
20
+
21
+ select - 5, + 5
22
+
23
+ ---
24
+ (ql (moduleMember (select (asExprs (asExpr (unary_expr (unop) (literal (integer)))) (asExpr (unary_expr (unop) (literal (integer))))))))
25
+ =====
26
+ binop
27
+ =====
28
+
29
+ select 5 + 5, 5 - 5, 5 * 5, 5 / 5, 5 % 5
30
+
31
+ ---
32
+
33
+ (ql (moduleMember
34
+ (select
35
+ (asExprs
36
+ (asExpr (add_expr (literal (integer)) (addop) (literal (integer))))
37
+ (asExpr (add_expr (literal (integer)) (addop) (literal (integer))))
38
+ (asExpr (mul_expr (literal (integer)) (mulop) (literal (integer))))
39
+ (asExpr (mul_expr (literal (integer)) (mulop) (literal (integer))))
40
+ (asExpr (mul_expr (literal (integer)) (mulop) (literal (integer))))))))
41
+
42
+ ===========
43
+ set literal
44
+ ===========
45
+
46
+ select [1,2,4]
47
+
48
+ ---
49
+
50
+ (ql (moduleMember
51
+ (select
52
+ (asExprs
53
+ (asExpr
54
+ (set_literal
55
+ (literal (integer))
56
+ (literal (integer))
57
+ (literal (integer))))))))
58
+
59
+ ====================
60
+ uniqueness aggregate
61
+ ====================
62
+
63
+ select unique(int x | x = 1 | x)
64
+
65
+ ---
66
+
67
+ (ql (moduleMember
68
+ (select
69
+ (asExprs
70
+ (asExpr
71
+ (aggregate
72
+ (aggId)
73
+ (full_aggregate_body
74
+ (varDecl (typeExpr (primitiveType)) (varName (simpleId)))
75
+ (comp_term (variable (varName (simpleId))) (compop) (literal (integer)))
76
+ (asExprs (asExpr (variable (varName (simpleId))))))))))))
77
+
78
+ ================
79
+ binop precedence
80
+ ================
81
+
82
+ select
83
+ // left associative
84
+ 5 + 5 - 5,
85
+ 5 - 5 + 5,
86
+ // mul binds tighter
87
+ 5 + 5 * 5,
88
+ 5 + 5 / 5,
89
+ 5 * 5 + 5,
90
+ 5 / 5 + 5,
91
+ // left associative
92
+ 5 / 5 * 5,
93
+ 5 * 5 / 5,
94
+ // mod tighter,
95
+ 5 * 5 % 5,
96
+ 5 % 5 * 5
97
+
98
+ ---
99
+
100
+ (ql (moduleMember (select (line_comment)
101
+ (asExprs
102
+ (asExpr (add_expr (add_expr (literal (integer)) (addop) (literal (integer))) (addop) (literal (integer))))
103
+ (asExpr (add_expr (add_expr (literal (integer)) (addop) (literal (integer))) (addop) (literal (integer))))
104
+ (line_comment)
105
+ (asExpr (add_expr (literal (integer)) (addop) (mul_expr (literal (integer)) (mulop) (literal (integer)))))
106
+ (asExpr (add_expr (literal (integer)) (addop) (mul_expr (literal (integer)) (mulop) (literal (integer)))))
107
+ (asExpr (add_expr (mul_expr (literal (integer)) (mulop) (literal (integer))) (addop) (literal (integer))))
108
+ (asExpr (add_expr (mul_expr (literal (integer)) (mulop) (literal (integer))) (addop) (literal (integer))))
109
+ (line_comment)
110
+ (asExpr (mul_expr (mul_expr (literal (integer)) (mulop) (literal (integer))) (mulop) (literal (integer))))
111
+ (asExpr (mul_expr (mul_expr (literal (integer)) (mulop) (literal (integer))) (mulop) (literal (integer))))
112
+ (line_comment)
113
+ (asExpr (mul_expr (mul_expr (literal (integer)) (mulop) (literal (integer))) (mulop) (literal (integer))))
114
+ (asExpr (mul_expr (mul_expr (literal (integer)) (mulop) (literal (integer))) (mulop) (literal (integer))))))))
115
+
116
+ ===========================
117
+ unary minus and prefix cast
118
+ ===========================
119
+
120
+ where x = -(float) -7
121
+ select 0
122
+
123
+ ---
124
+
125
+ (ql (moduleMember
126
+ (select
127
+ (comp_term
128
+ (variable (varName (simpleId)))
129
+ (compop)
130
+ (unary_expr
131
+ (unop)
132
+ (prefix_cast
133
+ (typeExpr (primitiveType))
134
+ (unary_expr
135
+ (unop)
136
+ (literal (integer))))))
137
+ (asExprs (asExpr (literal (integer)))))))
138
+
139
+ ========================
140
+ unary minus and non-cast
141
+ ========================
142
+
143
+ where x = -(foo) -7
144
+ select 0
145
+
146
+ ---
147
+
148
+ (ql (moduleMember
149
+ (select
150
+ (comp_term
151
+ (variable (varName (simpleId)))
152
+ (compop)
153
+ (add_expr
154
+ (unary_expr
155
+ (unop)
156
+ (par_expr (variable (varName (simpleId)))))
157
+ (addop)
158
+ (literal (integer))))
159
+ (asExprs (asExpr (literal (integer)))))))
160
+
161
+ ==============================
162
+ unary minus and multiplication
163
+ ==============================
164
+
165
+ where x = -a * b
166
+ select 0
167
+
168
+ ---
169
+
170
+ (ql (moduleMember
171
+ (select
172
+ (comp_term
173
+ (variable (varName (simpleId)))
174
+ (compop)
175
+ (mul_expr
176
+ (unary_expr
177
+ (unop)
178
+ (variable (varName (simpleId))))
179
+ (mulop)
180
+ (variable (varName (simpleId)))))
181
+ (asExprs (asExpr (literal (integer)))))))
182
+
183
+ ========================
184
+ expression-level pragmas
185
+ ========================
186
+
187
+ from int i
188
+ where i = pragma[only_bind_out](5)
189
+ select i
190
+
191
+ ---
192
+
193
+ (ql (moduleMember (select
194
+ (varDecl (typeExpr (primitiveType)) (varName (simpleId)))
195
+ (comp_term
196
+ (variable (varName (simpleId)))
197
+ (compop)
198
+ (expr_annotation
199
+ (annotName)
200
+ (annotName)
201
+ (literal (integer))))
202
+ (asExprs (asExpr (variable (varName (simpleId))))))))
203
+
204
+ ===========================
205
+ unary minus and prefix cast
206
+ ===========================
207
+
208
+ where x = -(float) -7
209
+ select 0
210
+
211
+ ---
212
+
213
+ (ql (moduleMember
214
+ (select
215
+ (comp_term
216
+ (variable (varName (simpleId)))
217
+ (compop)
218
+ (unary_expr
219
+ (unop)
220
+ (prefix_cast
221
+ (typeExpr (primitiveType))
222
+ (unary_expr
223
+ (unop)
224
+ (literal (integer))))))
225
+ (asExprs (asExpr (literal (integer)))))))
226
+
227
+ ========================
228
+ unary minus and non-cast
229
+ ========================
230
+
231
+ where x = -(foo) -7
232
+ select 0
233
+
234
+ ---
235
+
236
+ (ql (moduleMember
237
+ (select
238
+ (comp_term
239
+ (variable (varName (simpleId)))
240
+ (compop)
241
+ (add_expr
242
+ (unary_expr
243
+ (unop)
244
+ (par_expr (variable (varName (simpleId)))))
245
+ (addop)
246
+ (literal (integer))))
247
+ (asExprs (asExpr (literal (integer)))))))
248
+
249
+
250
+ ===============================
251
+ set literal with trailing comma
252
+ ===============================
253
+
254
+ where x in [1,2,]
255
+ select x
256
+
257
+ ---
258
+
259
+ (ql (moduleMember
260
+ (select
261
+ (in_expr
262
+ (variable (varName (simpleId)))
263
+ (set_literal
264
+ (literal (integer))
265
+ (literal (integer))))
266
+ (asExprs (asExpr (variable (varName (simpleId))))))))
vendor/tree-sitter-ql/test/corpus/formula.txt ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ===========
2
+ comparisons
3
+ ===========
4
+
5
+ from File f
6
+ where (f = f)
7
+ or f != f
8
+ and f < f
9
+ and (f > f or f <= f)
10
+ and f >= f
11
+ select f
12
+
13
+ ---
14
+
15
+ (ql (moduleMember
16
+ (select
17
+ (varDecl (typeExpr (className)) (varName (simpleId)))
18
+ (disjunction
19
+ (par_expr (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId)))))
20
+ (conjunction
21
+ (conjunction
22
+ (conjunction
23
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))
24
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId)))))
25
+ (par_expr (disjunction
26
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))
27
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId)))))))
28
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))))
29
+ (asExprs (asExpr (variable (varName (simpleId))))))))
30
+
31
+ ==========
32
+ instanceof
33
+ ==========
34
+
35
+ from Foo f
36
+ where f instanceof Foo
37
+ select f
38
+
39
+ ---
40
+
41
+ (ql (moduleMember
42
+ (select
43
+ (varDecl (typeExpr (className)) (varName (simpleId)))
44
+ (instance_of (variable (varName (simpleId))) (typeExpr (className)))
45
+ (asExprs (asExpr (variable (varName (simpleId))))))))
46
+
47
+ =====
48
+ range
49
+ =====
50
+
51
+ from int i
52
+ where i in [0..10]
53
+ select i
54
+
55
+ ---
56
+
57
+ (ql (moduleMember
58
+ (select
59
+ (varDecl (typeExpr (primitiveType)) (varName (simpleId)))
60
+ (in_expr (variable (varName (simpleId))) (range (literal (integer)) (literal (integer))))
61
+ (asExprs (asExpr (variable (varName (simpleId))))))))
62
+
63
+ =====
64
+ set literals
65
+ =====
66
+
67
+ from int i
68
+ where i in [1, 2]
69
+ select i
70
+
71
+ ---
72
+
73
+ (ql (moduleMember
74
+ (select
75
+ (varDecl (typeExpr (primitiveType)) (varName (simpleId)))
76
+ (in_expr (variable (varName (simpleId))) (set_literal (literal (integer)) (literal (integer))))
77
+ (asExprs (asExpr (variable (varName (simpleId))))))))
78
+
79
+ =================
80
+ predicateRef call
81
+ =================
82
+
83
+ from int i
84
+ where bar(i) and module::baz+()
85
+ select i
86
+
87
+ ---
88
+
89
+ (ql (moduleMember
90
+ (select
91
+ (varDecl (typeExpr (primitiveType)) (varName (simpleId)))
92
+ (conjunction
93
+ (call_or_unqual_agg_expr (aritylessPredicateExpr (literalId)) (call_body (variable (varName (simpleId)))))
94
+ (call_or_unqual_agg_expr (aritylessPredicateExpr (moduleExpr (simpleId)) (literalId)) (closure) (call_body)))
95
+ (asExprs (asExpr (variable (varName (simpleId))))))))
96
+ =================================
97
+ calls with results & method calls
98
+ =================================
99
+
100
+ from int i
101
+ select i.foo+(), 1.foo(), 1.1.foo()
102
+
103
+ ---
104
+ (ql (moduleMember
105
+ (select
106
+ (varDecl (typeExpr (primitiveType)) (varName (simpleId)))
107
+ (asExprs
108
+ (asExpr (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName) (closure))))
109
+ (asExpr (qualified_expr (literal (integer)) (qualifiedRhs (predicateName))))
110
+ (asExpr (qualified_expr (literal (float)) (qualifiedRhs (predicateName))))))))
111
+
112
+ ==============
113
+ quantification
114
+ ==============
115
+
116
+
117
+ from Foo f
118
+ where exists(f.aThing())
119
+ or exists(Foo f | f.aThing())
120
+ or exists(Foo f | f.aThing() | f.aThing())
121
+ or forall(Foo f | f.aThing() | f.aThing())
122
+ or forex(Foo f | f.aThing() | f.aThing())
123
+ select f
124
+
125
+ ---
126
+
127
+ (ql (moduleMember
128
+ (select
129
+ (varDecl (typeExpr (className)) (varName (simpleId)))
130
+ (disjunction
131
+ (disjunction
132
+ (disjunction
133
+ (disjunction
134
+ (quantified (quantifier) (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName))))
135
+ (quantified (quantifier) (varDecl (typeExpr (className)) (varName (simpleId)))
136
+ (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName)))))
137
+ (quantified (quantifier) (varDecl (typeExpr (className)) (varName (simpleId)))
138
+ (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName)))
139
+ (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName)))))
140
+ (quantified (quantifier) (varDecl (typeExpr (className)) (varName (simpleId)))
141
+ (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName)))
142
+ (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName)))))
143
+ (quantified (quantifier) (varDecl (typeExpr (className)) (varName (simpleId)))
144
+ (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName)))
145
+ (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName)))))
146
+ (asExprs (asExpr (variable (varName (simpleId))))))))
147
+
148
+ ==================
149
+ unary op ambiguity
150
+ ==================
151
+
152
+ from int x
153
+ where x = -1 and any()
154
+ select x
155
+
156
+ ---
157
+
158
+ (ql (moduleMember
159
+ (select
160
+ (varDecl (typeExpr (primitiveType)) (varName (simpleId)))
161
+ (conjunction
162
+ (comp_term
163
+ (variable (varName (simpleId)))
164
+ (compop)
165
+ (unary_expr (unop) (literal (integer))))
166
+ (aggregate (aggId)))
167
+ (asExprs (asExpr (variable (varName (simpleId))))))))
168
+
169
+ ====================
170
+ unary op ambiguity 2
171
+ ====================
172
+
173
+ where -1 in [-1..1]
174
+ select "yes"
175
+
176
+ ---
177
+
178
+ (ql (moduleMember
179
+ (select
180
+ (in_expr
181
+ (unary_expr (unop) (literal (integer)))
182
+ (range
183
+ (unary_expr (unop) (literal (integer)))
184
+ (literal (integer))))
185
+ (asExprs (asExpr (literal (string)))))))
vendor/tree-sitter-ql/test/corpus/modules.txt ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ======
2
+ module
3
+ ======
4
+
5
+ module foo {
6
+ module bar {
7
+ import woo
8
+
9
+ predicate baz();
10
+ }
11
+ }
12
+
13
+ ---
14
+
15
+ (ql (moduleMember
16
+ (module (moduleName (simpleId)) (moduleMember
17
+ (module (moduleName (simpleId))
18
+ (moduleMember (importDirective (importModuleExpr (moduleExpr (simpleId)))))
19
+ (moduleMember (classlessPredicate (predicate) (predicateName) (empty))))))))
20
+
21
+ ============
22
+ module alias
23
+ ============
24
+
25
+ module foo = bar::baz;
26
+
27
+ ---
28
+
29
+ (ql (moduleMember (module (moduleName (simpleId)) (moduleAliasBody (moduleExpr (moduleExpr (simpleId)) (simpleId))))))
30
+
31
+ ==============================
32
+ parameterised module signature
33
+ ==============================
34
+
35
+ signature int supplyInt();
36
+
37
+ signature module SupplyInt {
38
+ int get();
39
+ class C extends Foo, Bar;
40
+ predicate baz(C c);
41
+ }
42
+
43
+ ---
44
+
45
+ (ql
46
+ (moduleMember
47
+ (annotation
48
+ (annotName))
49
+ (classlessPredicate
50
+ (typeExpr
51
+ (primitiveType))
52
+ (predicateName)
53
+ (empty)))
54
+ (moduleMember
55
+ (annotation
56
+ (annotName))
57
+ (module
58
+ (moduleName
59
+ (simpleId))
60
+ (moduleMember
61
+ (classlessPredicate
62
+ (typeExpr
63
+ (primitiveType))
64
+ (predicateName)
65
+ (empty)))
66
+ (moduleMember
67
+ (dataclass
68
+ (className)
69
+ (typeExpr
70
+ (className))
71
+ (typeExpr
72
+ (className))))
73
+ (moduleMember
74
+ (classlessPredicate
75
+ (predicate)
76
+ (predicateName)
77
+ (varDecl
78
+ (typeExpr
79
+ (className))
80
+ (varName
81
+ (simpleId)))
82
+ (empty))))))
83
+
84
+ ================================
85
+ parameterised module declaration
86
+ ================================
87
+
88
+ module PModule<supplyInt/0 s1, SupplyInt S2> {
89
+ int foo() { result = s1() + S2::get() }
90
+ }
91
+
92
+ ---
93
+
94
+ (ql
95
+ (moduleMember
96
+ (module
97
+ (moduleName
98
+ (simpleId))
99
+ (moduleParam
100
+ (signatureExpr
101
+ (predicateExpr
102
+ (aritylessPredicateExpr
103
+ (literalId))
104
+ (integer)))
105
+ (simpleId))
106
+ (moduleParam
107
+ (signatureExpr
108
+ (typeExpr
109
+ (className)))
110
+ (simpleId))
111
+ (moduleMember
112
+ (classlessPredicate
113
+ (typeExpr
114
+ (primitiveType))
115
+ (predicateName)
116
+ (body
117
+ (comp_term
118
+ (variable
119
+ (result))
120
+ (compop)
121
+ (add_expr
122
+ (call_or_unqual_agg_expr
123
+ (aritylessPredicateExpr
124
+ (literalId))
125
+ (call_body))
126
+ (addop)
127
+ (call_or_unqual_agg_expr
128
+ (aritylessPredicateExpr
129
+ (moduleExpr
130
+ (simpleId))
131
+ (literalId))
132
+ (call_body))))))))))
133
+
134
+ ===============================
135
+ parameterised module implements
136
+ ===============================
137
+
138
+ module Supply11 implements SupplyInt {
139
+ int get() { result = 11 }
140
+ }
141
+
142
+ ---
143
+
144
+ (ql
145
+ (moduleMember
146
+ (module
147
+ (moduleName
148
+ (simpleId))
149
+ (signatureExpr
150
+ (typeExpr
151
+ (className)))
152
+ (moduleMember
153
+ (classlessPredicate
154
+ (typeExpr
155
+ (primitiveType))
156
+ (predicateName)
157
+ (body
158
+ (comp_term
159
+ (variable
160
+ (result))
161
+ (compop)
162
+ (literal
163
+ (integer)))))))))
164
+
165
+ ================================
166
+ parameterised module application
167
+ ================================
168
+
169
+ select PModule<supply6/0, supply10/0, Supply11, Supply15>::foo()
170
+
171
+ ---
172
+
173
+
174
+ (ql
175
+ (moduleMember
176
+ (select
177
+ (asExprs
178
+ (asExpr
179
+ (call_or_unqual_agg_expr
180
+ (aritylessPredicateExpr
181
+ (moduleExpr
182
+ (moduleInstantiation
183
+ (moduleName
184
+ (simpleId))
185
+ (signatureExpr
186
+ (predicateExpr
187
+ (aritylessPredicateExpr
188
+ (literalId))
189
+ (integer)))
190
+ (signatureExpr
191
+ (predicateExpr
192
+ (aritylessPredicateExpr
193
+ (literalId))
194
+ (integer)))
195
+ (signatureExpr
196
+ (typeExpr
197
+ (className)))
198
+ (signatureExpr
199
+ (typeExpr
200
+ (className)))))
201
+ (literalId))
202
+ (call_body)))))))
203
+
204
+ ==================
205
+ second application
206
+ ==================
207
+
208
+ where node = DataFlow::BarrierGuard<containsDotDotSanitizer/3>::getABarrierNode()
209
+ select 1
210
+
211
+ ---
212
+
213
+ (ql
214
+ (moduleMember
215
+ (select
216
+ (comp_term
217
+ (variable
218
+ (varName
219
+ (simpleId)))
220
+ (compop)
221
+ (call_or_unqual_agg_expr
222
+ (aritylessPredicateExpr
223
+ (moduleExpr
224
+ (moduleExpr
225
+ (simpleId))
226
+ (moduleInstantiation
227
+ (moduleName
228
+ (simpleId))
229
+ (signatureExpr
230
+ (predicateExpr
231
+ (aritylessPredicateExpr
232
+ (literalId))
233
+ (integer)))))
234
+ (literalId))
235
+ (call_body)))
236
+ (asExprs
237
+ (asExpr
238
+ (literal
239
+ (integer)))))))
vendor/tree-sitter-ql/test/corpus/operators_and_precedence.txt ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ============
2
+ And vs Or 1
3
+ ============
4
+
5
+ from Foo f
6
+ where f = f and f = f or f = f
7
+ select f
8
+
9
+ ---
10
+
11
+ (ql (moduleMember
12
+ (select
13
+ (varDecl (typeExpr (className)) (varName (simpleId)))
14
+ (disjunction
15
+ (conjunction
16
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))
17
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId)))))
18
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId)))))
19
+ (asExprs (asExpr (variable (varName (simpleId))))))))
20
+
21
+ ============
22
+ And vs Or 2
23
+ ============
24
+
25
+ from Foo f
26
+ where f = f or f = f and f = f
27
+ select f
28
+
29
+ ---
30
+
31
+ (ql (moduleMember
32
+ (select (varDecl (typeExpr (className)) (varName (simpleId)))
33
+ (disjunction
34
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))
35
+ (conjunction
36
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))
37
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))))
38
+ (asExprs (asExpr (variable (varName (simpleId))))))))
39
+
40
+ ============
41
+ Or vs implies
42
+ ============
43
+
44
+ from Foo f
45
+ where (f = f or f = f implies f = f)
46
+ and (f = f implies f = f or f = f)
47
+ select f
48
+
49
+ ---
50
+
51
+ (ql (moduleMember
52
+ (select
53
+ (varDecl (typeExpr (className)) (varName (simpleId)))
54
+ (conjunction
55
+ (par_expr
56
+ (implication
57
+ (disjunction
58
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))
59
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId)))))
60
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))))
61
+ (par_expr
62
+ (implication
63
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))
64
+ (disjunction
65
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))
66
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))))))
67
+ (asExprs (asExpr (variable (varName (simpleId))))))))
68
+
69
+ ============
70
+ if then else
71
+ ============
72
+
73
+ from Foo f
74
+ where if f = f then f = f else f = f
75
+ select f
76
+
77
+ ---
78
+
79
+ (ql (moduleMember
80
+ (select
81
+ (varDecl (typeExpr (className)) (varName (simpleId)))
82
+ (if_term
83
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))
84
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))
85
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId)))))
86
+ (asExprs (asExpr (variable (varName (simpleId))))))))
87
+
88
+ ==========
89
+ and vs not
90
+ ==========
91
+
92
+ from Foo f
93
+ where not f = f and f = f
94
+ select f
95
+
96
+ ---
97
+
98
+ (ql (moduleMember
99
+ (select
100
+ (varDecl (typeExpr (className)) (varName (simpleId)))
101
+ (conjunction
102
+ (negation (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId)))))
103
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId)))))
104
+ (asExprs (asExpr (variable (varName (simpleId))))))))
105
+
106
+ ==========
107
+ call vs plus
108
+ ==========
109
+
110
+ select a+(b)
111
+
112
+ ---
113
+
114
+ (ql (moduleMember (select (asExprs (asExpr (call_or_unqual_agg_expr (aritylessPredicateExpr (literalId)) (closure) (call_body (variable (varName (simpleId))))))))))
115
+
116
+ ==========
117
+ cast vs subtract
118
+ ==========
119
+
120
+ select (A)-(b)
121
+
122
+ ---
123
+ (ql (moduleMember (select (asExprs (asExpr (prefix_cast (typeExpr (className)) (unary_expr (unop) (par_expr (variable (varName (simpleId)))))))))))
vendor/tree-sitter-ql/test/corpus/predicates.txt ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ =======
2
+ no-body
3
+ =======
4
+
5
+ predicate foo();
6
+
7
+ mod::Type foo(int arg, Foo arg);
8
+
9
+ ---
10
+
11
+ (ql
12
+ (moduleMember (classlessPredicate (predicate) (predicateName) (empty)))
13
+ (moduleMember (classlessPredicate (typeExpr (moduleExpr (simpleId)) (className)) (predicateName)
14
+ (varDecl (typeExpr (primitiveType)) (varName (simpleId))) (varDecl (typeExpr (className)) (varName (simpleId))) (empty))))
15
+
16
+ ================
17
+ simple predicate
18
+ ================
19
+
20
+ predicate foo(F f){
21
+ f = f
22
+ }
23
+
24
+ int predicateWithResult(){
25
+ result = 43
26
+ }
27
+
28
+ ---
29
+
30
+ (ql
31
+ (moduleMember (classlessPredicate (predicate) (predicateName) (varDecl (typeExpr (className)) (varName (simpleId))) (body
32
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId)))))))
33
+ (moduleMember (classlessPredicate (typeExpr (primitiveType)) (predicateName) (body
34
+ (comp_term (variable (result)) (compop) (literal (integer)))))))
35
+
36
+ =====================
37
+ higher-order relation
38
+ =====================
39
+
40
+ int foo(X x, Y y) = name(pred1/1, pred2/3)(x.x(), result)
41
+
42
+ ---
43
+
44
+ (ql (moduleMember
45
+ (classlessPredicate
46
+ (typeExpr (primitiveType))
47
+ (predicateName)
48
+ (varDecl (typeExpr (className)) (varName (simpleId)))
49
+ (varDecl (typeExpr (className)) (varName (simpleId)))
50
+ (higherOrderTerm (literalId)
51
+ (predicateExpr (aritylessPredicateExpr (literalId)) (integer))
52
+ (predicateExpr (aritylessPredicateExpr (literalId)) (integer))
53
+ (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName)))
54
+ (variable (result))))))
55
+
56
+ ===============
57
+ predicate alias
58
+ ===============
59
+
60
+ predicate foo = somePredicate/12;
61
+
62
+ ---
63
+
64
+ (ql (moduleMember (classlessPredicate
65
+ (predicate)
66
+ (predicateName) (predicateAliasBody (predicateExpr (aritylessPredicateExpr (literalId)) (integer))))))
67
+
68
+ ==========
69
+ type union
70
+ ==========
71
+
72
+ newtype T =
73
+ T1() or
74
+ T2(int x) { x = 1 or x = 2 } or
75
+ T3(int x) { x = 3 or x = 4 or x = 5 }
76
+
77
+ class T2orT3 = T2 or T3;
78
+
79
+ ---
80
+
81
+ (ql (moduleMember (datatype (className) (datatypeBranches
82
+ (datatypeBranch (className))
83
+ (datatypeBranch (className) (varDecl (typeExpr (primitiveType)) (varName (simpleId))) (body (disjunction
84
+ (comp_term (variable (varName (simpleId))) (compop) (literal (integer)))
85
+ (comp_term (variable (varName (simpleId))) (compop) (literal (integer))))))
86
+ (datatypeBranch (className) (varDecl (typeExpr (primitiveType)) (varName (simpleId))) (body (disjunction (disjunction
87
+ (comp_term (variable (varName (simpleId))) (compop) (literal (integer)))
88
+ (comp_term (variable (varName (simpleId))) (compop) (literal (integer))))
89
+ (comp_term (variable (varName (simpleId))) (compop) (literal (integer)))))))))
90
+ (moduleMember (dataclass (className) (typeUnionBody (typeExpr (className)) (typeExpr (className))))))
vendor/tree-sitter-ql/test/corpus/primary.txt ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ======
2
+ eparen
3
+ ======
4
+
5
+ select (f).getAThing()
6
+
7
+ ---
8
+
9
+ (ql (moduleMember (select (asExprs (asExpr (qualified_expr (par_expr (variable (varName (simpleId)))) (qualifiedRhs (predicateName))))))))
10
+
11
+ =====
12
+ super
13
+ =====
14
+
15
+ select super.foo(), module::Foo.super.foo()
16
+
17
+ ---
18
+
19
+ (ql (moduleMember
20
+ (select
21
+ (asExprs
22
+ (asExpr (qualified_expr (super_ref (super)) (qualifiedRhs (predicateName))))
23
+ (asExpr (qualified_expr (super_ref (typeExpr (moduleExpr (simpleId)) (className)) (super)) (qualifiedRhs (predicateName))))))))
24
+
25
+ ============
26
+ postfix cast
27
+ ============
28
+
29
+ select f.(Foo).thing()
30
+
31
+ ---
32
+
33
+ (ql (moduleMember (select (asExprs (asExpr (qualified_expr (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (typeExpr (className)))) (qualifiedRhs (predicateName))))))))
34
+
35
+ ===
36
+ any
37
+ ===
38
+
39
+ select
40
+ any(Foo f),
41
+ any(Foo f | f = f),
42
+ any(Foo f | | f.thing()),
43
+ any(Foo f | f = f | f.thing())
44
+
45
+ ---
46
+
47
+ (ql (moduleMember (select (asExprs
48
+ (asExpr (aggregate (aggId) (full_aggregate_body (varDecl (typeExpr (className)) (varName (simpleId))))))
49
+ (asExpr (aggregate (aggId) (full_aggregate_body (varDecl (typeExpr (className)) (varName (simpleId)))
50
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId)))))))
51
+ (asExpr (aggregate (aggId)
52
+ (full_aggregate_body
53
+ (varDecl (typeExpr (className)) (varName (simpleId)))
54
+ (asExprs (asExpr (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName))))))))
55
+ (asExpr (aggregate (aggId) (full_aggregate_body
56
+ (varDecl (typeExpr (className))
57
+ (varName (simpleId)))
58
+ (comp_term (variable (varName (simpleId))) (compop) (variable (varName (simpleId))))
59
+ (asExprs (asExpr (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName))))))))))))
60
+
61
+
62
+ =====
63
+ range
64
+ =====
65
+
66
+ select [0..10]
67
+
68
+ ---
69
+
70
+ (ql (moduleMember (select (asExprs (asExpr (range (literal (integer)) (literal (integer))))))))
71
+
72
+ ==========
73
+ aggregates
74
+ ==========
75
+
76
+ select
77
+ rank[123](Foo f),
78
+ count(f.thing()),
79
+ count(f.thing() as thing order by thing asc, thing desc),
80
+ count(Foo f),
81
+ count(f),
82
+ count (| | f),
83
+ count(),
84
+ count(Foo f | f.thing() ),
85
+ sum(Foo f | | f.x() ),
86
+ sum(Foo f | | f.x() as x),
87
+ sum(Foo f | | f.x() as x order by x),
88
+ sum(Foo f | | f.x() as x order by x asc, f.y()),
89
+ sum(Foo f | f.thing() | f.x() )
90
+
91
+ ---
92
+
93
+ (ql (moduleMember (select (asExprs
94
+ (asExpr (aggregate (aggId) (literal (integer))
95
+ (full_aggregate_body (varDecl (typeExpr (className)) (varName (simpleId))))))
96
+ (asExpr (aggregate (aggId)
97
+ (expr_aggregate_body (asExprs (asExpr (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName))))))))
98
+ (asExpr (aggregate (aggId)
99
+ (expr_aggregate_body (asExprs
100
+ (asExpr (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName))) (varName (simpleId))))
101
+ (orderBys
102
+ (orderBy (variable (varName (simpleId))) (direction))
103
+ (orderBy (variable (varName (simpleId))) (direction))))))
104
+ (asExpr (aggregate (aggId) (full_aggregate_body (varDecl (typeExpr (className)) (varName (simpleId))))))
105
+ (asExpr (aggregate (aggId) (expr_aggregate_body (asExprs (asExpr (variable (varName (simpleId))))))))
106
+ (asExpr (aggregate (aggId) (full_aggregate_body (asExprs (asExpr (variable (varName (simpleId))))))))
107
+ (asExpr (aggregate (aggId)))
108
+ (asExpr (aggregate (aggId)
109
+ (full_aggregate_body (varDecl (typeExpr (className)) (varName (simpleId)))
110
+ (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName))))))
111
+ (asExpr (aggregate (aggId)
112
+ (full_aggregate_body
113
+ (varDecl (typeExpr (className))
114
+ (varName (simpleId)))
115
+ (asExprs
116
+ (asExpr (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName))))))))
117
+ (asExpr (aggregate (aggId)
118
+ (full_aggregate_body
119
+ (varDecl (typeExpr (className)) (varName (simpleId)))
120
+ (asExprs
121
+ (asExpr (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName))) (varName (simpleId)))))))
122
+ (asExpr (aggregate (aggId) (full_aggregate_body
123
+ (varDecl (typeExpr (className)) (varName (simpleId)))
124
+ (asExprs
125
+ (asExpr (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName))) (varName (simpleId))))
126
+ (orderBys (orderBy (variable (varName (simpleId))))))))
127
+ (asExpr (aggregate (aggId)
128
+ (full_aggregate_body (varDecl (typeExpr (className)) (varName (simpleId)))
129
+ (asExprs (asExpr (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName))) (varName (simpleId))))
130
+ (orderBys
131
+ (orderBy (variable (varName (simpleId))) (direction))
132
+ (orderBy (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName))))))))
133
+ (asExpr (aggregate (aggId) (full_aggregate_body
134
+ (varDecl (typeExpr (className)) (varName (simpleId)))
135
+ (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName)))
136
+ (asExprs (asExpr (qualified_expr (variable (varName (simpleId))) (qualifiedRhs (predicateName))))))))))))