self.repr_serialize(params)
return 'ast.PYACC.Production.Action({0:s})'.format(', '.join(params))
# GENERATE END
-
def post_process(
self,
pyacc,
pyacc.n_productions += int(last_action) # midrule action production
production.n_symbols += int(last_action) # midrule action symbol
return True
-
def add_to_symbols(
self,
pyacc,
)
for i in self[0]:
if isinstance(i, PYACC.Text.StackLocation):
- i.offset = -production.n_symbols
+ i.offset = -len(symbols)
elif isinstance(i, PYACC.Text.StackReference):
if (
len(i.tag_name) == 0 and
i.index <= len(tag_names)
):
i.tag_name = tag_names[i.index - 1]
- i.offset = -production.n_symbols
+ i.offset = -len(symbols)
return self[0]
class DPrec(Item):
# fill in token numbers that are not characters or overridden by user
token = 0x100
for i in self.symbols:
- if i._type == PYACC.Symbol.TYPE_TERMINAL and len(i.character_set) == 0:
- i.character_set = [token, token + 1]
- token += 1
+ if i._type == PYACC.Symbol.TYPE_TERMINAL:
+ if len(i.character_set) == 0:
+ i.character_set = [token, token + 1]
+ token += 1
+ elif i._type == PYACC.Symbol.TYPE_NONTERMINAL:
+ pass
+ else:
+ assert False
def to_lr1(self):
_lr1 = lr1.LR1(
| E '/' E { $$ = $1 / $3; }
| '(' E ')' { $$ = $2; }
/*| '-' E %prec UMINUS { $$ = -$2; }*/
- | '-' { printf("unary minus\n"); } E %prec UMINUS { $$ = -$3; }
+ | '-' { printf("unary minus %f\n", $1); } E %prec UMINUS { $$ = -$3; }
| NUM
;
%%