|
|
@@ -19,9 +19,9 @@ class TestStandalone(TestCase): |
|
|
|
def setUp(self): |
|
|
|
pass |
|
|
|
|
|
|
|
def _create_standalone(self, grammar): |
|
|
|
def _create_standalone(self, grammar, compress=False): |
|
|
|
code_buf = StringIO() |
|
|
|
standalone.gen_standalone(Lark(grammar, parser='lalr'), out=code_buf) |
|
|
|
standalone.gen_standalone(Lark(grammar, parser='lalr'), out=code_buf, compress=compress) |
|
|
|
code = code_buf.getvalue() |
|
|
|
|
|
|
|
context = {'__doc__': None} |
|
|
@@ -52,6 +52,11 @@ class TestStandalone(TestCase): |
|
|
|
self.assertRaises(context['UnexpectedToken'], l.parse, 'twelve') |
|
|
|
self.assertRaises(context['UnexpectedCharacters'], l.parse, '$ talks') |
|
|
|
|
|
|
|
context = self._create_standalone(grammar, compress=True) |
|
|
|
_Lark = context['Lark_StandAlone'] |
|
|
|
l = _Lark() |
|
|
|
x = l.parse('12 elephants') |
|
|
|
|
|
|
|
def test_contextual(self): |
|
|
|
grammar = """ |
|
|
|
start: a b |
|
|
|