You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If + is used on the rule RHS in the imported grammar under some still uninvestigated circumstances KeyError is raised in the first sets calculation. It seems that dynamically produced symbol with _1 suffix is not unique.
Relevant part of the stacktrace:
/home/igor/repos/parglare/parglare/glr.py:72: in __init__
force_load_table=force_load_table, table=table, **kwargs)
/home/igor/repos/parglare/parglare/parser.py:101: in __init__
in_layout=self.in_layout)
/home/igor/repos/parglare/parglare/tables/__init__.py:88: in create_load_table
**kwargs)
/home/igor/repos/parglare/parglare/tables/__init__.py:116: in create_table
first_sets = first(grammar)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
grammar = <parglare.grammar.Grammar object at 0x7ff97b4e3470>
def first(grammar):
"""Calculates the sets of terminals that can start the sentence derived from
all grammar symbols.
The Dragon book p. 221.
Returns:
dict of sets of Terminal keyed by GrammarSymbol.
"""
assert isinstance(grammar, Grammar), \
"grammar parameter should be Grammar instance."
first_sets = {}
for t in grammar.terminals.values():
first_sets[t] = set([t])
for nt in grammar.nonterminals.values():
first_sets[nt] = set()
additions = True
while additions:
additions = False
for p in grammar.productions:
nonterm = p.symbol
for rhs_symbol in p.rhs:
> rhs_symbol_first = set(first_sets[rhs_symbol])
E KeyError: NonTerminal(c.unnumbered_paragraph_1)
/home/igor/repos/parglare/parglare/tables/__init__.py:748: KeyError
The text was updated successfully, but these errors were encountered:
Description
If
+
is used on the rule RHS in the imported grammar under some still uninvestigated circumstancesKeyError
is raised in thefirst
sets calculation. It seems that dynamically produced symbol with_1
suffix is not unique.Relevant part of the stacktrace:
The text was updated successfully, but these errors were encountered: