Skip to content

Commit

Permalink
Small improvement suggested by review
Browse files Browse the repository at this point in the history
  • Loading branch information
erezsh committed Jun 22, 2024
1 parent f7c98bb commit efeb846
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lark/parsers/earley.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..lexer import Token
from ..tree import Tree
from ..exceptions import UnexpectedEOF, UnexpectedToken
from ..utils import logger, OrderedSet
from ..utils import logger, OrderedSet, dedup_list
from .grammar_analysis import GrammarAnalyzer
from ..grammar import NonTerminal
from .earley_common import Item
Expand Down Expand Up @@ -282,7 +282,7 @@ def parse(self, lexer, start):
# If the parse was successful, the start
# symbol should have been completed in the last step of the Earley cycle, and will be in
# this column. Find the item for the start_symbol, which is the root of the SPPF tree.
solutions = list(OrderedSet([n.node for n in columns[-1] if n.is_complete and n.node is not None and n.s == start_symbol and n.start == 0]))
solutions = dedup_list(n.node for n in columns[-1] if n.is_complete and n.node is not None and n.s == start_symbol and n.start == 0)
if not solutions:
expected_terminals = [t.expect.name for t in to_scan]
raise UnexpectedEOF(expected_terminals, state=frozenset(i.s for i in to_scan))
Expand Down

0 comments on commit efeb846

Please sign in to comment.