Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
erezsh committed Oct 19, 2021
1 parent 4c1cfb2 commit 5471f88
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 74 deletions.
54 changes: 1 addition & 53 deletions lark/parsers/earley.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,59 +170,7 @@ def is_quasi_complete(item):
return True

# def create_leo_transitives(origin, start):
# visited = set()
# to_create = []
# trule = None
# previous = None

# ### Recursively walk backwards through the Earley sets until we find the
# # first transitive candidate. If this is done continuously, we shouldn't
# # have to walk more than 1 hop.
# while True:
# if origin in transitives[start]:
# previous = trule = transitives[start][origin]
# break

# is_empty_rule = not self.FIRST[origin]
# if is_empty_rule:
# break

# candidates = [ candidate for candidate in columns[start] if candidate.expect is not None and origin == candidate.expect ]
# if len(candidates) != 1:
# break
# originator = next(iter(candidates))

# if originator is None or originator in visited:
# break

# visited.add(originator)
# if not is_quasi_complete(originator):
# break

# trule = originator.advance()
# if originator.start != start:
# visited.clear()

# to_create.append((origin, start, originator))
# origin = originator.rule.origin
# start = originator.start

# # If a suitable Transitive candidate is not found, bail.
# if trule is None:
# return

# #### Now walk forwards and create Transitive Items in each set we walked through; and link
# # each transitive item to the next set forwards.
# while to_create:
# origin, start, originator = to_create.pop()
# titem = None
# if previous is not None:
# titem = previous.next_titem = TransitiveItem(origin, trule, originator, previous.column)
# else:
# titem = TransitiveItem(origin, trule, originator, start)
# previous = transitives[start][origin] = titem


# ... # removed at commit 4c1cfb2faf24e8f8bff7112627a00b94d261b420

def scan(i, token, to_scan):
"""The core Earley Scanner.
Expand Down
22 changes: 1 addition & 21 deletions lark/parsers/earley_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,4 @@ def __repr__(self):


# class TransitiveItem(Item):
# __slots__ = ('recognized', 'reduction', 'column', 'next_titem')
# def __init__(self, recognized, trule, originator, start):
# super(TransitiveItem, self).__init__(trule.rule, trule.ptr, trule.start)
# self.recognized = recognized
# self.reduction = originator
# self.column = start
# self.next_titem = None
# self._hash = hash((self.s, self.start, self.recognized))

# def __eq__(self, other):
# if not isinstance(other, TransitiveItem):
# return False
# return self is other or (type(self.s) == type(other.s) and self.s == other.s and self.start == other.start and self.recognized == other.recognized)

# def __hash__(self):
# return self._hash

# def __repr__(self):
# before = ( expansion.name for expansion in self.rule.expansion[:self.ptr] )
# after = ( expansion.name for expansion in self.rule.expansion[self.ptr:] )
# return '{} : {} -> {}* {} ({}, {})'.format(self.recognized.name, self.rule.origin.name, ' '.join(before), ' '.join(after), self.column, self.start)
# ... # removed at commit 4c1cfb2faf24e8f8bff7112627a00b94d261b420

0 comments on commit 5471f88

Please sign in to comment.