string_to_symbol,
name_to_tag
):
- self[1].set_code_props(
- pyacc,
- section,
- character_to_symbol,
- name_to_symbol,
- string_to_symbol,
- name_to_tag,
- self._type,
- self[0]
- )
+ for i in self[1:]:
+ i.set_code_props(
+ pyacc,
+ section,
+ character_to_symbol,
+ name_to_symbol,
+ string_to_symbol,
+ name_to_tag,
+ self._type, # _type
+ self[0] # code
+ )
class DefaultPrec(Item):
# GENERATE ELEMENT() BEGIN
self.repr_serialize(params)
return 'ast.PYACC.Section1Or2.NTerm({0:s})'.format(', '.join(params))
# GENERATE END
+ def post_process(
+ self,
+ pyacc,
+ section,
+ character_to_symbol,
+ name_to_symbol,
+ string_to_symbol,
+ name_to_tag
+ ):
+ _tag = -1
+ for i in self:
+ _tag = i.post_process(
+ pyacc,
+ section,
+ character_to_symbol,
+ name_to_symbol,
+ string_to_symbol,
+ name_to_tag,
+ _tag,
+ -1 # precedence
+ )
class Precedence(Item):
# GENERATE ELEMENT(int _type) BEGIN
string_to_symbol,
name_to_tag
):
- self[0].post_process(
- pyacc,
- section,
- character_to_symbol,
- name_to_symbol,
- string_to_symbol,
- name_to_tag,
- len(pyacc.associativities) # precedence
- )
+ _tag = -1
+ for i in self:
+ _tag = i.post_process(
+ pyacc,
+ section,
+ character_to_symbol,
+ name_to_symbol,
+ string_to_symbol,
+ name_to_tag,
+ _tag,
+ len(pyacc.associativities) # precedence
+ )
pyacc.associativities.append(self._type)
class Start(Item):
)
pyacc.start_nonterminal = self[0].symbol
- class TaggedSymbols(element.Element):
+ class Token(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1Or2_TaggedSymbols',
+ tag = 'PYACC_Section1Or2_Token',
attrib = {},
text = '',
children = []
):
- element.Element.__init__(
+ Item.__init__(
self,
tag,
attrib,
children
)
def copy(self, factory = None):
- result = element.Element.copy(
+ result = Item.copy(
self,
- TaggedSymbols if factory is None else factory
+ Token if factory is None else factory
)
return result
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1Or2.TaggedSymbols({0:s})'.format(', '.join(params))
+ return 'ast.PYACC.Section1Or2.Token({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
character_to_symbol,
name_to_symbol,
string_to_symbol,
- name_to_tag,
- precedence
+ name_to_tag
):
_tag = -1
for i in self:
string_to_symbol,
name_to_tag,
_tag,
- precedence
+ -1 # precedence
)
- def set_code_props(
- self,
- pyacc,
- section,
- character_to_symbol,
- name_to_symbol,
- string_to_symbol,
- name_to_tag,
- _type,
- code
- ):
- for i in self:
- i.set_code_props(
- pyacc,
- section,
- character_to_symbol,
- name_to_symbol,
- string_to_symbol,
- name_to_tag,
- _type,
- code
- )
-
- class Token(Item):
- # GENERATE ELEMENT() BEGIN
- def __init__(
- self,
- tag = 'PYACC_Section1Or2_Token',
- attrib = {},
- text = '',
- children = []
- ):
- Item.__init__(
- self,
- tag,
- attrib,
- text,
- children
- )
- def copy(self, factory = None):
- result = Item.copy(
- self,
- Token if factory is None else factory
- )
- return result
- def __repr__(self):
- params = []
- self.repr_serialize(params)
- return 'ast.PYACC.Section1Or2.Token({0:s})'.format(', '.join(params))
- # GENERATE END
- def post_process(
- self,
- pyacc,
- section,
- character_to_symbol,
- name_to_symbol,
- string_to_symbol,
- name_to_tag
- ):
- self[0].post_process(
- pyacc,
- section,
- character_to_symbol,
- name_to_symbol,
- string_to_symbol,
- name_to_tag,
- -1 # precedence
- )
class Type(Item):
# GENERATE ELEMENT() BEGIN
string_to_symbol,
name_to_tag
):
- self[0].post_process(
- pyacc,
- section,
- character_to_symbol,
- name_to_symbol,
- string_to_symbol,
- name_to_tag,
- -1 # precedence
- )
+ _tag = -1
+ for i in self:
+ _tag = i.post_process(
+ pyacc,
+ section,
+ character_to_symbol,
+ name_to_symbol,
+ string_to_symbol,
+ name_to_tag,
+ _tag,
+ -1 # precedence
+ )
class Union(Item):
# GENERATE ELEMENT() BEGIN
string_to_symbol,
name_to_tag
):
+ assert len(pyacc.union_name) == 0 # fix this later
pyacc.union_name = self[0].get_text()
+ assert pyacc.union_code is None # fix this later
pyacc.union_code = self[1]
# GENERATE ELEMENT() BEGIN
'PYACC_Section1Or2_NTerm': PYACC.Section1Or2.NTerm,
'PYACC_Section1Or2_Precedence': PYACC.Section1Or2.Precedence,
'PYACC_Section1Or2_Start': PYACC.Section1Or2.Start,
- 'PYACC_Section1Or2_TaggedSymbols': PYACC.Section1Or2.TaggedSymbols,
'PYACC_Section1Or2_Token': PYACC.Section1Or2.Token,
'PYACC_Section1Or2_Type': PYACC.Section1Or2.Type,
'PYACC_Section1Or2_Union': PYACC.Section1Or2.Union,