@@ -11,7 +11,7 @@ from .lexer import Token, TerminalDef, PatternStr, PatternRE
from .parse_tree_builder import ParseTreeBuilder
from .parser_frontends import LALR_TraditionalLexer
from .common import LexerConf, ParserConf
from .grammar import RuleOptions, Rule, Terminal, NonTerminal, Symbol, END
from .grammar import RuleOptions, Rule, Terminal, NonTerminal, Symbol
from .utils import classify, suppress, dedup_list, Str
from .exceptions import GrammarError, UnexpectedCharacters, UnexpectedToken
@@ -94,7 +94,6 @@ TERMINALS = {
'_DECLARE': r'%declare',
'_IMPORT': r'%import',
'NUMBER': r'[+-]?\d+',
'_END': r'\$',
}
RULES = {
@@ -131,8 +130,7 @@ RULES = {
'nonterminal',
'literal',
'range',
'template_usage',
'end'],
'template_usage'],
'terminal': ['TERMINAL'],
'nonterminal': ['RULE'],
@@ -141,7 +139,6 @@ RULES = {
'maybe': ['_LBRA expansions _RBRA'],
'range': ['STRING _DOTDOT STRING'],
'end': ['_END'],
'template_usage': ['RULE _LBRACE _template_args _RBRACE'],
'_template_args': ['value',
@@ -302,9 +299,6 @@ class CanonizeTree(Transformer_InPlace):
tokenmods, value = args
return tokenmods + [value]
def end(self):
return Token('TERMINAL', END)
class PrepareAnonTerminals(Transformer_InPlace):
"Create a unique list of anonymous terminals. Attempt to give meaningful names to them when we add them"
@@ -813,7 +807,6 @@ class GrammarLoader:
term_defs = [td if len(td)==3 else (td[0], 1, td[1]) for td in term_defs]
term_defs = [(name.value, (t, int(p))) for name, p, t in term_defs]
term_defs.append((END, (None, 0)))
rule_defs = [options_from_rule(*x) for x in rule_defs]
# Execute statements
@@ -906,7 +899,7 @@ class GrammarLoader:
raise GrammarError("Terminal '%s' defined more than once" % name)
terminal_names.add(name)
if set(ignore_names) - terminal_names:
if set(ignore_names) > terminal_names:
raise GrammarError("Terminals %s were marked to ignore but were not defined!" % (set(ignore_names) - terminal_names))
resolve_term_references(term_defs)