name = self[0].get_text()
if name in name_to_symbol:
symbol = name_to_symbol[name]
+ assert self.user_token != 0
+ elif self.user_token == 0:
+ # stupid exception following what bison does, because bison
+ # adds the $end token at the end if not already defined by
+ # user, but we need to define the $end token upfront to make
+ # it have internal token number 0 (and apparently they don't)
+ symbol = 0
+ name_to_symbol[name] = symbol
+ assert pyacc.symbols[symbol].name == '$end'
+ pyacc.symbols[symbol] = PYACC.Symbol(
+ name = name,
+ code_props = [None, None],
+ character_set = []
+ )
else:
symbol = len(pyacc.symbols)
name_to_symbol[name] = symbol
self.repr_serialize(params)
return 'ast.PYACC.Text.StackLocation({0:s})'.format(', '.join(params))
# GENERATE END
+ def get_text(self):
+ return '(yylsp[{0:d}])'.format(self.offset + self.index)
class StackReference(Item):
# GENERATE ELEMENT(str tag_name, int offset, int index) BEGIN
self.repr_serialize(params)
return 'ast.PYACC.Text.ValueLocation({0:s})'.format(', '.join(params))
# GENERATE END
+ def get_text(self):
+ return '(yyloc)'
class ValueReference(Item):
# GENERATE ELEMENT(str tag_name) BEGIN
self.precedences = 0
self.symbols = [
PYACC.Symbol(
- name = '$eof',
+ name = '$end',
code_props = [None, None],
_type = PYACC.Symbol.TYPE_TERMINAL,
character_set = [0, 1]
n_nonterminals,
translate_nonterminals
):
+ #numpy.set_printoptions(threshold = numpy.nan)
+ #print(translate_terminals)
+ #print(translate_nonterminals)
+
# translate is yytranslate
self.translate = translate_terminals
goto_table[nonterminal0:nonterminal1, i] = gotos[j]
nonterminal0 = nonterminal1
assert nonterminal0 == len(lr1dfa.productions)
+ assert numpy.all(action_table != 0)
+ assert numpy.all(goto_table != 0)
+ #print(action_table)
+ #print(goto_table)
# permute and combine columns/rows on the basis of the translate vectors
new_action_table = numpy.zeros(