Browse Source

Add missing elements in standalone parser

Add:
- missing imports
- __version__ variable

Additionally regenerated json parser example
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.10.0
Blank Spruce 4 years ago
parent
commit
5559b1a211
4 changed files with 134 additions and 55 deletions
  1. +126
    -52
      examples/standalone/json_parser.py
  2. +3
    -2
      lark/exceptions.py
  3. +2
    -0
      lark/tools/standalone.py
  4. +3
    -1
      lark/tree.py

+ 126
- 52
examples/standalone/json_parser.py
File diff suppressed because it is too large
View File


+ 3
- 2
lark/exceptions.py View File

@@ -1,8 +1,9 @@
import logging

from .utils import STRING_TYPE from .utils import STRING_TYPE


###{standalone ###{standalone
import logging


class LarkError(Exception): class LarkError(Exception):
pass pass




+ 2
- 0
lark/tools/standalone.py View File

@@ -88,6 +88,8 @@ def main(fobj, start):
lark_inst = Lark(fobj, parser="lalr", lexer="contextual", start=start) lark_inst = Lark(fobj, parser="lalr", lexer="contextual", start=start)


print('# The file was automatically generated by Lark v%s' % lark.__version__) print('# The file was automatically generated by Lark v%s' % lark.__version__)
print('__version__ = "%s"' % lark.__version__)
print()


for pyfile in EXTRACT_STANDALONE_FILES: for pyfile in EXTRACT_STANDALONE_FILES:
with open(os.path.join(_larkdir, pyfile)) as f: with open(os.path.join(_larkdir, pyfile)) as f:


+ 3
- 1
lark/tree.py View File

@@ -4,10 +4,12 @@ except ImportError:
pass pass


from copy import deepcopy from copy import deepcopy
from collections import OrderedDict




###{standalone ###{standalone
from collections import OrderedDict


class Meta: class Meta:
def __init__(self): def __init__(self):
self.empty = True self.empty = True


Loading…
Cancel
Save