-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78d62a5
commit 204e239
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
tests/func/regressions/test_issue31_glr_drop_parses_on_lexical_ambiguity.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from parglare import Grammar, GLRParser | ||
|
||
|
||
def test_issue31_glr_drop_parses_on_lexical_ambiguity(): | ||
grammar = """ | ||
model: element+; | ||
element: title | ||
| table_with_note | ||
| table_with_title; | ||
table_with_title: table_title table_with_note; | ||
table_with_note: table note*; | ||
terminals | ||
title: /title/; // <-- This is lexically ambiguous with the next. | ||
table_title: /title/; | ||
table: "table"; | ||
note: "note"; | ||
""" | ||
|
||
# this input should yield 4 parse trees. | ||
input = "title table title table" | ||
|
||
g = Grammar.from_string(grammar) | ||
parser = GLRParser(g, debug=True, debug_colors=True) | ||
results = parser.parse(input) | ||
|
||
# We should have 4 solutions for the input. | ||
assert len(results) == 4 |