diff --git a/lark/__init__.py b/lark/__init__.py index e2b4c37..b892073 100644 --- a/lark/__init__.py +++ b/lark/__init__.py @@ -3,4 +3,4 @@ from .common import ParseError, GrammarError from .lark import Lark from .utils import inline_args -__version__ = "0.3.2" +__version__ = "0.3.3" diff --git a/lark/load_grammar.py b/lark/load_grammar.py index 803fee9..3f0da8d 100644 --- a/lark/load_grammar.py +++ b/lark/load_grammar.py @@ -500,7 +500,7 @@ def resolve_token_references(token_defs): # TODO Cycles detection # TODO Solve with transitive closure (maybe) - token_dict = dict(token_defs) + token_dict = {k:t for k, (t,_p) in token_defs} assert len(token_dict) == len(token_defs), "Same name defined twice?" while True: diff --git a/tests/test_parser.py b/tests/test_parser.py index 3de98c6..40b4a0f 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -690,12 +690,27 @@ def _make_parser_test(LEXER, PARSER): | "cd" """ - l = Lark(grammar, parser='earley', ambiguity='explicit', lexer=None) + # l = Lark(grammar, parser='earley', ambiguity='explicit', lexer=None) + l = _Lark(grammar, ambiguity='explicit') x = l.parse('cde') assert x.data == '_ambig' assert len(x.children) == 2 + def test_import(self): + grammar = """ + start: NUMBER WORD + + %import common.NUMBER + %import common.WORD + %import common.WS + %ignore WS + + """ + l = _Lark(grammar) + x = l.parse('12 elephants') + self.assertEqual(x.children, ['12', 'elephants']) + @unittest.skipIf(PARSER != 'earley', "Currently only Earley supports priority in rules") def test_earley_prioritization_sum(self): "Tests effect of priority on result"