Skip to content

Commit

Permalink
Test for issue #31.
Browse files Browse the repository at this point in the history
  • Loading branch information
igordejanovic committed May 25, 2018
1 parent 78d62a5 commit 204e239
Showing 1 changed file with 28 additions and 0 deletions.
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

0 comments on commit 204e239

Please sign in to comment.