Skip to content

Commit

Permalink
U928-016: Fix parser for bracket expresions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roldak committed Oct 1, 2021
1 parent 52f162c commit 7973600
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ada/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,8 @@ def end_named_block():
BracketAggregate(
"[", cut(),
Opt(A.expr, "with"),
List(A.aggregate_assoc, sep=",", list_cls=AssocList),
List(A.aggregate_assoc,
sep=",", list_cls=AssocList, empty_valid=True),
"]"
),

Expand Down Expand Up @@ -1175,7 +1176,7 @@ def end_named_block():
# parsers, so that we can use A.subtype_indication | A.name in allocator.

qualified_name=QualExpr(
A.qual_name_internal, "'", Or(A.paren_expr, A.regular_aggregate)
A.qual_name_internal, "'", Or(A.paren_expr, A.aggregate)
),

qual_name_internal=Or(
Expand Down
1 change: 1 addition & 0 deletions testsuite/tests/parser/bracket_aggregate_0/input
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
4 changes: 4 additions & 0 deletions testsuite/tests/parser/bracket_aggregate_0/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BracketAggregate[1:1-1:3]
|f_ancestor_expr: <null>
|f_assocs:
| AssocList[1:2-1:2]: <empty list>
2 changes: 2 additions & 0 deletions testsuite/tests/parser/bracket_aggregate_0/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: parser
rule: aggregate
1 change: 1 addition & 0 deletions testsuite/tests/parser/qualified_expression_1/input
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Foo'[Bar, Baz]
18 changes: 18 additions & 0 deletions testsuite/tests/parser/qualified_expression_1/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
QualExpr[1:1-1:15]
|f_prefix:
| Id[1:1-1:4]: Foo
|f_suffix:
| BracketAggregate[1:5-1:15]
| |f_ancestor_expr: <null>
| |f_assocs:
| | AssocList[1:6-1:14]
| | | AggregateAssoc[1:6-1:9]
| | | |f_designators:
| | | | AlternativesList[1:5-1:5]: <empty list>
| | | |f_r_expr:
| | | | Id[1:6-1:9]: Bar
| | | AggregateAssoc[1:11-1:14]
| | | |f_designators:
| | | | AlternativesList[1:9-1:9]: <empty list>
| | | |f_r_expr:
| | | | Id[1:11-1:14]: Baz
2 changes: 2 additions & 0 deletions testsuite/tests/parser/qualified_expression_1/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: parser
rule: qualified_name

0 comments on commit 7973600

Please sign in to comment.