diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_grammar.py b/tests/test_grammar.py new file mode 100644 index 0000000..3845990 --- /dev/null +++ b/tests/test_grammar.py @@ -0,0 +1,18 @@ +import parser +import pytest + + +def test_conflicting_names(): + """Terminals and nonterminals can have the same name.""" + + IDENTIFIER = parser.Terminal("Identifier") + + class TestGrammar(parser.Grammar): + start = "Identifier" + + @parser.rule("Identifier") + def identifier(self): + return IDENTIFIER + + with pytest.raises(ValueError): + TestGrammar().build_table()