Skip to content

Commit 4432753

Browse files
authored
Merge pull request #120 from bmahe/update_elasticsearch
Update to example repositories and to the grammar to support new cases
2 parents 72a9af0 + 123fab5 commit 4432753

File tree

8 files changed

+34801
-27011
lines changed

8 files changed

+34801
-27011
lines changed

grammar.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const PREC = {
44
// https://introcs.cs.princeton.edu/java/11precedence/
55
COMMENT: 0, // // /* */
66
ASSIGN: 1, // = += -= *= /= %= &= ^= |= <<= >>= >>>=
7-
SWITCH_EXP: 1, // always prefer to parse switch as expression over statement
87
DECL: 2,
98
ELEMENT_VAL: 2,
109
TERNARY: 3, // ?:
@@ -66,8 +65,10 @@ module.exports = grammar({
6665
[$._unannotated_type, $.scoped_type_identifier],
6766
[$._unannotated_type, $.generic_type],
6867
[$.generic_type, $.primary_expression],
68+
[$.expression, $.statement],
6969
// Only conflicts in switch expressions
7070
[$.lambda_expression, $.primary_expression],
71+
[$.inferred_parameters, $.primary_expression],
7172
],
7273

7374
word: $ => $.identifier,
@@ -174,7 +175,7 @@ module.exports = grammar({
174175
$.primary_expression,
175176
$.unary_expression,
176177
$.cast_expression,
177-
prec(PREC.SWITCH_EXP, $.switch_expression),
178+
$.switch_expression,
178179
),
179180

180181
cast_expression: $ => prec(PREC.CAST, seq(
@@ -233,15 +234,15 @@ module.exports = grammar({
233234

234235
lambda_expression: $ => seq(
235236
field('parameters', choice(
236-
$.identifier, $.formal_parameters, $.inferred_parameters
237+
$.identifier, $.formal_parameters, $.inferred_parameters, $._reserved_identifier
237238
)),
238239
'->',
239240
field('body', choice($.expression, $.block))
240241
),
241242

242243
inferred_parameters: $ => seq(
243244
'(',
244-
commaSep1($.identifier),
245+
commaSep1(choice($.identifier, $._reserved_identifier)),
245246
')'
246247
),
247248

@@ -290,6 +291,7 @@ module.exports = grammar({
290291

291292
array_creation_expression: $ => prec.right(seq(
292293
'new',
294+
repeat($._annotation),
293295
field('type', $._simple_type),
294296
choice(
295297
seq(
@@ -922,6 +924,7 @@ module.exports = grammar({
922924
$.constant_declaration,
923925
$.class_declaration,
924926
$.interface_declaration,
927+
$.enum_declaration,
925928
$.annotation_type_declaration
926929
)),
927930
'}'

script/known-failures.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
examples/flink/flink-quickstart/flink-quickstart-java/src/main/resources/archetype-resources/src/main/java/DataStreamJob.java
2+
examples/flink/flink-walkthroughs/flink-walkthrough-datastream-java/src/main/resources/archetype-resources/src/main/java/FraudDetectionJob.java
3+
examples/flink/flink-walkthroughs/flink-walkthrough-datastream-java/src/main/resources/archetype-resources/src/main/java/FraudDetector.java

script/parse-examples

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ function clone_repo {
2626
}
2727

2828
clone_repo elastic elasticsearch 4d62640bf116af7e825d89c7319a39c3f2f325b4
29-
clone_repo google guava e24fddc5fff7fd36d33ea38737b6606a7e476845
30-
clone_repo ReactiveX RxJava 8a6bf14fc9a61f7c1c0016ca217be02ca86211d2
29+
clone_repo google guava v31.1
30+
clone_repo ReactiveX RxJava v3.1.5
31+
clone_repo apache flink release-1.15.1
32+
clone_repo apache logging-log4j2 rel/2.17.2
33+
clone_repo apache cassandra cassandra-4.0.5
3134

3235
known_failures="$(cat script/known-failures.txt)"
3336

src/grammar.json

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,12 +1194,8 @@
11941194
"name": "cast_expression"
11951195
},
11961196
{
1197-
"type": "PREC",
1198-
"value": 1,
1199-
"content": {
1200-
"type": "SYMBOL",
1201-
"name": "switch_expression"
1202-
}
1197+
"type": "SYMBOL",
1198+
"name": "switch_expression"
12031199
}
12041200
]
12051201
},
@@ -2066,6 +2062,10 @@
20662062
{
20672063
"type": "SYMBOL",
20682064
"name": "inferred_parameters"
2065+
},
2066+
{
2067+
"type": "SYMBOL",
2068+
"name": "_reserved_identifier"
20692069
}
20702070
]
20712071
}
@@ -2104,8 +2104,17 @@
21042104
"type": "SEQ",
21052105
"members": [
21062106
{
2107-
"type": "SYMBOL",
2108-
"name": "identifier"
2107+
"type": "CHOICE",
2108+
"members": [
2109+
{
2110+
"type": "SYMBOL",
2111+
"name": "identifier"
2112+
},
2113+
{
2114+
"type": "SYMBOL",
2115+
"name": "_reserved_identifier"
2116+
}
2117+
]
21092118
},
21102119
{
21112120
"type": "REPEAT",
@@ -2117,8 +2126,17 @@
21172126
"value": ","
21182127
},
21192128
{
2120-
"type": "SYMBOL",
2121-
"name": "identifier"
2129+
"type": "CHOICE",
2130+
"members": [
2131+
{
2132+
"type": "SYMBOL",
2133+
"name": "identifier"
2134+
},
2135+
{
2136+
"type": "SYMBOL",
2137+
"name": "_reserved_identifier"
2138+
}
2139+
]
21222140
}
21232141
]
21242142
}
@@ -2401,6 +2419,13 @@
24012419
"type": "STRING",
24022420
"value": "new"
24032421
},
2422+
{
2423+
"type": "REPEAT",
2424+
"content": {
2425+
"type": "SYMBOL",
2426+
"name": "_annotation"
2427+
}
2428+
},
24042429
{
24052430
"type": "FIELD",
24062431
"name": "type",
@@ -5852,6 +5877,10 @@
58525877
"type": "SYMBOL",
58535878
"name": "interface_declaration"
58545879
},
5880+
{
5881+
"type": "SYMBOL",
5882+
"name": "enum_declaration"
5883+
},
58555884
{
58565885
"type": "SYMBOL",
58575886
"name": "annotation_type_declaration"
@@ -7059,9 +7088,17 @@
70597088
"generic_type",
70607089
"primary_expression"
70617090
],
7091+
[
7092+
"expression",
7093+
"statement"
7094+
],
70627095
[
70637096
"lambda_expression",
70647097
"primary_expression"
7098+
],
7099+
[
7100+
"inferred_parameters",
7101+
"primary_expression"
70657102
]
70667103
],
70677104
"precedences": [],

src/node-types.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,10 @@
487487
"type": "constant_declaration",
488488
"named": true
489489
},
490+
{
491+
"type": "enum_declaration",
492+
"named": true
493+
},
490494
{
491495
"type": "interface_declaration",
492496
"named": true
@@ -677,6 +681,20 @@
677681
}
678682
]
679683
}
684+
},
685+
"children": {
686+
"multiple": true,
687+
"required": false,
688+
"types": [
689+
{
690+
"type": "annotation",
691+
"named": true
692+
},
693+
{
694+
"type": "marker_annotation",
695+
"named": true
696+
}
697+
]
680698
}
681699
},
682700
{

0 commit comments

Comments
 (0)