|
@@ -68,7 +68,7 @@ class Reconstructor: |
|
|
return to_write |
|
|
return to_write |
|
|
|
|
|
|
|
|
d = defaultdict(list) |
|
|
d = defaultdict(list) |
|
|
for name, expansions in parser.rules.items(): |
|
|
|
|
|
|
|
|
for name, (expansions, options) in parser.rules.items(): |
|
|
for expansion, alias in expansions: |
|
|
for expansion, alias in expansions: |
|
|
if alias: |
|
|
if alias: |
|
|
d[alias].append(expansion) |
|
|
d[alias].append(expansion) |
|
@@ -77,8 +77,8 @@ class Reconstructor: |
|
|
d[name].append(expansion) |
|
|
d[name].append(expansion) |
|
|
|
|
|
|
|
|
rules = [] |
|
|
rules = [] |
|
|
expand1s = {name.lstrip('!').lstrip('?') for name in d |
|
|
|
|
|
if name.startswith(('?', '!?'))} # XXX Ugly code |
|
|
|
|
|
|
|
|
expand1s = {name for name, (_x, options) in parser.rules.items() |
|
|
|
|
|
if options and options.expand1} |
|
|
|
|
|
|
|
|
for name, expansions in d.items(): |
|
|
for name, expansions in d.items(): |
|
|
for expansion in expansions: |
|
|
for expansion in expansions: |
|
@@ -86,8 +86,6 @@ class Reconstructor: |
|
|
(MatchTerminal(sym) if is_terminal(sym) else MatchTree(sym),) |
|
|
(MatchTerminal(sym) if is_terminal(sym) else MatchTree(sym),) |
|
|
for sym in expansion if not is_discarded_terminal(sym)] |
|
|
for sym in expansion if not is_discarded_terminal(sym)] |
|
|
|
|
|
|
|
|
name = name.lstrip('!').lstrip('?') |
|
|
|
|
|
|
|
|
|
|
|
rules.append((name, reduced, WriteTokens(name, expansion).f)) |
|
|
rules.append((name, reduced, WriteTokens(name, expansion).f)) |
|
|
self.rules = rules |
|
|
self.rules = rules |
|
|
|
|
|
|
|
|