mirror of
https://github.com/davidhalter/parso.git
synced 2026-05-24 17:28:53 +08:00
One instance of symbol -> terminal
This commit is contained in:
+6
-5
@@ -139,14 +139,15 @@ class ParserGenerator(object):
|
|||||||
# It's a string. We have finally found a possible first token.
|
# It's a string. We have finally found a possible first token.
|
||||||
totalset.add(nonterminal_or_string)
|
totalset.add(nonterminal_or_string)
|
||||||
overlapcheck[nonterminal_or_string] = set([nonterminal_or_string])
|
overlapcheck[nonterminal_or_string] = set([nonterminal_or_string])
|
||||||
|
|
||||||
inverse = {}
|
inverse = {}
|
||||||
for nonterminal_or_string, itsfirst in overlapcheck.items():
|
for nonterminal_or_string, first_set in overlapcheck.items():
|
||||||
for symbol in itsfirst:
|
for terminal in first_set:
|
||||||
if symbol in inverse:
|
if terminal in inverse:
|
||||||
raise ValueError("rule %s is ambiguous; %s is in the"
|
raise ValueError("rule %s is ambiguous; %s is in the"
|
||||||
" first sets of %s as well as %s" %
|
" first sets of %s as well as %s" %
|
||||||
(name, symbol, nonterminal_or_string, inverse[symbol]))
|
(name, terminal, nonterminal_or_string, inverse[terminal]))
|
||||||
inverse[symbol] = nonterminal_or_string
|
inverse[terminal] = nonterminal_or_string
|
||||||
self._first_terminals[name] = totalset
|
self._first_terminals[name] = totalset
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user