Browse Source

Removed unused imports and variables

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.6.6
Jan Rydzewski 6 years ago
parent
commit
3ef84318b1
6 changed files with 4 additions and 14 deletions
  1. +0
    -3
      lark/lark.py
  2. +1
    -1
      lark/load_grammar.py
  3. +0
    -2
      lark/parse_tree_builder.py
  4. +1
    -1
      lark/parsers/resolve_ambig.py
  5. +1
    -4
      lark/reconstruct.py
  6. +1
    -3
      lark/tools/standalone.py

+ 0
- 3
lark/lark.py View File

@@ -112,9 +112,6 @@ class Lark:
self.source = grammar.name
except AttributeError:
self.source = '<string>'
cache_file = "larkcache_%s" % str(hash(grammar)%(2**32))
else:
cache_file = "larkcache_%s" % os.path.basename(self.source)

# Drain file-like objects to get their contents
try:


+ 1
- 1
lark/load_grammar.py View File

@@ -528,7 +528,7 @@ def import_grammar(grammar_path, base_paths=[]):
def import_from_grammar_into_namespace(grammar, namespace, aliases):
imported_terms = dict(grammar.term_defs)
imported_rules = {n:(n,t,o) for n,t,o in grammar.rule_defs}
term_defs = []
rule_defs = []



+ 0
- 2
lark/parse_tree_builder.py View File

@@ -1,7 +1,5 @@
from .exceptions import GrammarError
from .utils import suppress
from .lexer import Token
from .grammar import Rule
from .tree import Tree
from .visitors import InlineTransformer # XXX Deprecated



+ 1
- 1
lark/parsers/resolve_ambig.py View File

@@ -36,7 +36,7 @@ def _compare_drv(tree1, tree2):
except AttributeError:
rule2 = None

if None == rule1 == rule2:
if rule1 is None and rule2 is None:
return compare(tree1, tree2)
elif rule1 is None:
return -1


+ 1
- 4
lark/reconstruct.py View File

@@ -100,10 +100,8 @@ class Reconstructor:
for origin, rule_aliases in aliases.items():
for alias in rule_aliases:
yield Rule(origin, [Terminal(alias)], MakeMatchTree(origin.name, [NonTerminal(alias)]))
yield Rule(origin, [Terminal(origin.name)], MakeMatchTree(origin.name, [origin]))

yield Rule(origin, [Terminal(origin.name)], MakeMatchTree(origin.name, [origin]))

def _match(self, term, token):
if isinstance(token, Tree):
@@ -127,4 +125,3 @@ class Reconstructor:

def reconstruct(self, tree):
return ''.join(self._reconstruct(tree))


+ 1
- 3
lark/tools/standalone.py View File

@@ -45,9 +45,7 @@ from collections import defaultdict

import lark
from lark import Lark
from lark.parsers.lalr_analysis import Shift, Reduce

from ..grammar import Rule
from lark.parsers.lalr_analysis import Reduce

_dir = path.dirname(__file__)
_larkdir = path.join(_dir, path.pardir)


Loading…
Cancel
Save