# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
):
raise NotImplementedError
-class PYACC(element.Element):
+class AST(element.Element):
# internal classes
class TagOrSymbol(element.Element):
# GENERATE ELEMENT(str name, list(ref) code_props) BEGIN
def __init__(
self,
- tag = 'PYACC_TagOrSymbol',
+ tag = 'AST_TagOrSymbol',
attrib = {},
text = '',
children = [],
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.TagOrSymbol({0:s})'.format(', '.join(params))
+ return 'ast.AST.TagOrSymbol({0:s})'.format(', '.join(params))
# GENERATE END
class Tag(TagOrSymbol):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Tag',
+ tag = 'AST_Tag',
attrib = {},
text = '',
children = [],
name = '',
code_props = []
):
- PYACC.TagOrSymbol.__init__(
+ AST.TagOrSymbol.__init__(
self,
tag,
attrib,
code_props
)
def copy(self, factory = None):
- result = PYACC.TagOrSymbol.copy(
+ result = AST.TagOrSymbol.copy(
self,
Tag if factory is None else factory
)
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Tag({0:s})'.format(', '.join(params))
+ return 'ast.AST.Tag({0:s})'.format(', '.join(params))
# GENERATE END
class Symbol(TagOrSymbol):
# GENERATE ELEMENT(int _type, int _tag, int precedence, list(int) character_set) BEGIN
def __init__(
self,
- tag = 'PYACC_Symbol',
+ tag = 'AST_Symbol',
attrib = {},
text = '',
children = [],
precedence = -1,
character_set = []
):
- PYACC.TagOrSymbol.__init__(
+ AST.TagOrSymbol.__init__(
self,
tag,
attrib,
character_set
)
def serialize(self, ref_list):
- PYACC.TagOrSymbol.serialize(self, ref_list)
+ AST.TagOrSymbol.serialize(self, ref_list)
self.set('_type', element.serialize_int(self._type))
self.set('_tag', element.serialize_int(self._tag))
self.set('precedence', element.serialize_int(self.precedence))
' '.join([element.serialize_int(i) for i in self.character_set])
)
def deserialize(self, ref_list):
- PYACC.TagOrSymbol.deserialize(self, ref_list)
+ AST.TagOrSymbol.deserialize(self, ref_list)
self._type = element.deserialize_int(self.get('_type', '-1'))
self._tag = element.deserialize_int(self.get('_tag', '-1'))
self.precedence = element.deserialize_int(self.get('precedence', '-1'))
for i in self.get('character_set', '').split()
]
def copy(self, factory = None):
- result = PYACC.TagOrSymbol.copy(
+ result = AST.TagOrSymbol.copy(
self,
Symbol if factory is None else factory
)
result.character_set = self.character_set
return result
def repr_serialize(self, params):
- PYACC.TagOrSymbol.repr_serialize(self, params)
+ AST.TagOrSymbol.repr_serialize(self, params)
if self._type != -1:
params.append(
'_type = {0:s}'.format(repr(self._type))
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Symbol({0:s})'.format(', '.join(params))
+ return 'ast.AST.Symbol({0:s})'.format(', '.join(params))
# GENERATE END
# syntax classes
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_BracedPredicate',
+ tag = 'AST_BracedPredicate',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.BracedPredicate({0:s})'.format(', '.join(params))
+ return 'ast.AST.BracedPredicate({0:s})'.format(', '.join(params))
# GENERATE END
class Char(element.Element):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Char',
+ tag = 'AST_Char',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Char({0:s})'.format(', '.join(params))
+ return 'ast.AST.Char({0:s})'.format(', '.join(params))
# GENERATE END
class Int(element.Element):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Int',
+ tag = 'AST_Int',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Int({0:s})'.format(', '.join(params))
+ return 'ast.AST.Int({0:s})'.format(', '.join(params))
# GENERATE END
class Production(element.Element):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Production_Item',
+ tag = 'AST_Production_Item',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Production.Item({0:s})'.format(', '.join(params))
+ return 'ast.AST.Production.Item({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
production,
character_to_symbol,
raise NotImplementedError
def add_to_symbols(
self,
- pyacc,
+ _ast,
production,
last_action,
_lr1,
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Production_Action',
+ tag = 'AST_Production_Action',
attrib = {},
text = '',
children = []
):
- PYACC.Production.Item.__init__(
+ AST.Production.Item.__init__(
self,
tag,
attrib,
children
)
def copy(self, factory = None):
- result = PYACC.Production.Item.copy(
+ result = AST.Production.Item.copy(
self,
Action if factory is None else factory
)
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Production.Action({0:s})'.format(', '.join(params))
+ return 'ast.AST.Production.Action({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
production,
character_to_symbol,
name_to_tag,
last_action
):
- pyacc.n_productions += int(last_action) # midrule action production
+ _ast.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,
+ _ast,
production,
last_action,
_lr1,
last_action
)
)
- assert isinstance(self[0], PYACC.Text) # temporary
+ assert isinstance(self[0], AST.Text) # temporary
for i in self[0]:
- if isinstance(i, PYACC.Text.StackLocation):
+ if isinstance(i, AST.Text.StackLocation):
i.offset = -len(symbols)
- elif isinstance(i, PYACC.Text.StackReference):
+ elif isinstance(i, AST.Text.StackReference):
if (
len(i.tag_name) == 0 and
i.index >= 1 and
# GENERATE ELEMENT(int value) BEGIN
def __init__(
self,
- tag = 'PYACC_Production_DPrec',
+ tag = 'AST_Production_DPrec',
attrib = {},
text = '',
children = [],
value = -1
):
- PYACC.Production.Item.__init__(
+ AST.Production.Item.__init__(
self,
tag,
attrib,
value
)
def serialize(self, ref_list):
- PYACC.Production.Item.serialize(self, ref_list)
+ AST.Production.Item.serialize(self, ref_list)
self.set('value', element.serialize_int(self.value))
def deserialize(self, ref_list):
- PYACC.Production.Item.deserialize(self, ref_list)
+ AST.Production.Item.deserialize(self, ref_list)
self.value = element.deserialize_int(self.get('value', '-1'))
def copy(self, factory = None):
- result = PYACC.Production.Item.copy(
+ result = AST.Production.Item.copy(
self,
DPrec if factory is None else factory
)
result.value = self.value
return result
def repr_serialize(self, params):
- PYACC.Production.Item.repr_serialize(self, params)
+ AST.Production.Item.repr_serialize(self, params)
if self.value != -1:
params.append(
'value = {0:s}'.format(repr(self.value))
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Production.DPrec({0:s})'.format(', '.join(params))
+ return 'ast.AST.Production.DPrec({0:s})'.format(', '.join(params))
# GENERATE END
class Empty(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Production_Empty',
+ tag = 'AST_Production_Empty',
attrib = {},
text = '',
children = []
):
- PYACC.Production.Item.__init__(
+ AST.Production.Item.__init__(
self,
tag,
attrib,
children
)
def copy(self, factory = None):
- result = PYACC.Production.Item.copy(
+ result = AST.Production.Item.copy(
self,
Empty if factory is None else factory
)
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Production.Empty({0:s})'.format(', '.join(params))
+ return 'ast.AST.Production.Empty({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
production,
character_to_symbol,
def add_to_symbols(
self,
- pyacc,
+ _ast,
production,
last_action,
_lr1,
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Production_Merge',
+ tag = 'AST_Production_Merge',
attrib = {},
text = '',
children = []
):
- PYACC.Production.Item.__init__(
+ AST.Production.Item.__init__(
self,
tag,
attrib,
children
)
def copy(self, factory = None):
- result = PYACC.Production.Item.copy(
+ result = AST.Production.Item.copy(
self,
Merge if factory is None else factory
)
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Production.Merge({0:s})'.format(', '.join(params))
+ return 'ast.AST.Production.Merge({0:s})'.format(', '.join(params))
# GENERATE END
class Prec(Item):
# GENERATE ELEMENT(int symbol) BEGIN
def __init__(
self,
- tag = 'PYACC_Production_Prec',
+ tag = 'AST_Production_Prec',
attrib = {},
text = '',
children = [],
symbol = -1
):
- PYACC.Production.Item.__init__(
+ AST.Production.Item.__init__(
self,
tag,
attrib,
symbol
)
def serialize(self, ref_list):
- PYACC.Production.Item.serialize(self, ref_list)
+ AST.Production.Item.serialize(self, ref_list)
self.set('symbol', element.serialize_int(self.symbol))
def deserialize(self, ref_list):
- PYACC.Production.Item.deserialize(self, ref_list)
+ AST.Production.Item.deserialize(self, ref_list)
self.symbol = element.deserialize_int(self.get('symbol', '-1'))
def copy(self, factory = None):
- result = PYACC.Production.Item.copy(
+ result = AST.Production.Item.copy(
self,
Prec if factory is None else factory
)
result.symbol = self.symbol
return result
def repr_serialize(self, params):
- PYACC.Production.Item.repr_serialize(self, params)
+ AST.Production.Item.repr_serialize(self, params)
if self.symbol != -1:
params.append(
'symbol = {0:s}'.format(repr(self.symbol))
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Production.Prec({0:s})'.format(', '.join(params))
+ return 'ast.AST.Production.Prec({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
production,
character_to_symbol,
):
assert production.precedence_terminal == -1
_, production.precedence_terminal = self[0].post_process(
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
string_to_symbol,
name_to_tag,
- PYACC.Symbol.TYPE_TERMINAL, # _type
+ AST.Symbol.TYPE_TERMINAL, # _type
-1, # _tag
-1 # precedence
)
# GENERATE ELEMENT(int symbol) BEGIN
def __init__(
self,
- tag = 'PYACC_Production_SymbolRef',
+ tag = 'AST_Production_SymbolRef',
attrib = {},
text = '',
children = [],
symbol = -1
):
- PYACC.Production.Item.__init__(
+ AST.Production.Item.__init__(
self,
tag,
attrib,
symbol
)
def serialize(self, ref_list):
- PYACC.Production.Item.serialize(self, ref_list)
+ AST.Production.Item.serialize(self, ref_list)
self.set('symbol', element.serialize_int(self.symbol))
def deserialize(self, ref_list):
- PYACC.Production.Item.deserialize(self, ref_list)
+ AST.Production.Item.deserialize(self, ref_list)
self.symbol = element.deserialize_int(self.get('symbol', '-1'))
def copy(self, factory = None):
- result = PYACC.Production.Item.copy(
+ result = AST.Production.Item.copy(
self,
SymbolRef if factory is None else factory
)
result.symbol = self.symbol
return result
def repr_serialize(self, params):
- PYACC.Production.Item.repr_serialize(self, params)
+ AST.Production.Item.repr_serialize(self, params)
if self.symbol != -1:
params.append(
'symbol = {0:s}'.format(repr(self.symbol))
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Production.SymbolRef({0:s})'.format(', '.join(params))
+ return 'ast.AST.Production.SymbolRef({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
production,
character_to_symbol,
name_to_tag,
last_action
):
- pyacc.n_productions += int(last_action) # midrule action production
+ _ast.n_productions += int(last_action) # midrule action production
production.n_symbols += int(last_action) + 1 # midrule action symbol
_, self.symbol = self[0].post_process(
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
-1, # _tag
-1 # precedence
)
- if pyacc.symbols[self.symbol]._type == PYACC.Symbol.TYPE_TERMINAL:
+ if _ast.symbols[self.symbol]._type == AST.Symbol.TYPE_TERMINAL:
production.last_terminal = self.symbol
return False
def add_to_symbols(
self,
- pyacc,
+ _ast,
production,
last_action,
_lr1,
)
)
symbols.append(
- (pyacc.symbols[self.symbol].character_set, [])
- if pyacc.symbols[self.symbol]._type == PYACC.Symbol.TYPE_TERMINAL else
- ([], pyacc.symbols[self.symbol].character_set)
+ (_ast.symbols[self.symbol].character_set, [])
+ if _ast.symbols[self.symbol]._type == AST.Symbol.TYPE_TERMINAL else
+ ([], _ast.symbols[self.symbol].character_set)
)
tag_names.append(
''
- if pyacc.symbols[self.symbol]._tag == -1 else
- pyacc.tags[pyacc.symbols[self.symbol]._tag].name
+ if _ast.symbols[self.symbol]._tag == -1 else
+ _ast.tags[_ast.symbols[self.symbol]._tag].name
)
return None
# GENERATE ELEMENT(int lhs_nonterminal, int n_symbols, int last_terminal, int precedence_terminal) BEGIN
def __init__(
self,
- tag = 'PYACC_Production',
+ tag = 'AST_Production',
attrib = {},
text = '',
children = [],
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Production({0:s})'.format(', '.join(params))
+ return 'ast.AST.Production({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
lhs_nonterminal,
character_to_symbol,
last_action = False
for i in self:
last_action = i.post_process(
- pyacc,
+ _ast,
section,
self,
character_to_symbol,
last_action
)
- i = pyacc.symbols[self.lhs_nonterminal]
- if len(i.character_set) and i.character_set[-1] == pyacc.n_productions:
- i.character_set[-1] = pyacc.n_productions + 1
+ i = _ast.symbols[self.lhs_nonterminal]
+ if len(i.character_set) and i.character_set[-1] == _ast.n_productions:
+ i.character_set[-1] = _ast.n_productions + 1
else:
- i.character_set.extend([pyacc.n_productions, pyacc.n_productions + 1])
- pyacc.n_productions += 1
- pyacc.productions.append(self)
+ i.character_set.extend([_ast.n_productions, _ast.n_productions + 1])
+ _ast.n_productions += 1
+ _ast.productions.append(self)
- def add_to_lr1(self, pyacc, _lr1):
+ def add_to_lr1(self, _ast, _lr1):
last_action = None
symbols = []
tag_names = []
for i in self:
last_action = i.add_to_symbols(
- pyacc,
+ _ast,
self,
last_action,
_lr1,
if last_action is not None:
for i in last_action:
if (
- isinstance(i, PYACC.Text.ValueReference) and
+ isinstance(i, AST.Text.ValueReference) and
len(i.tag_name) == 0
):
i.tag_name = (
''
- if pyacc.symbols[self.lhs_nonterminal]._tag == -1 else
- pyacc.tags[pyacc.symbols[self.lhs_nonterminal]._tag].name
+ if _ast.symbols[self.lhs_nonterminal]._tag == -1 else
+ _ast.tags[_ast.symbols[self.lhs_nonterminal]._tag].name
)
_lr1.productions.append(
)
precedence = (
- pyacc.symbols[self.precedence_terminal].precedence
+ _ast.symbols[self.precedence_terminal].precedence
if self.precedence_terminal != -1 else
- pyacc.symbols[self.last_terminal].precedence
+ _ast.symbols[self.last_terminal].precedence
if self.last_terminal != -1 else
-1
)
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1Or2_Code',
+ tag = 'AST_Section1Or2_Code',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1Or2.Code({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1Or2.Code({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
name = self[0].get_text()
if len(name) == 0: # do the same as Section1.Prologue
(
- pyacc.before_union_text
- if len(pyacc.union_text) == 0 else
- pyacc.after_union_text
+ _ast.before_union_text
+ if len(_ast.union_text) == 0 else
+ _ast.after_union_text
).append(self[1][0])
elif name == 'top':
- pyacc.top_text.append(self[1][0])
+ _ast.top_text.append(self[1][0])
elif name == 'requires':
- pyacc.requires_text.append(self[1][0])
+ _ast.requires_text.append(self[1][0])
else:
assert False
# GENERATE ELEMENT(int _type) BEGIN
def __init__(
self,
- tag = 'PYACC_Section1Or2_CodeProps',
+ tag = 'AST_Section1Or2_CodeProps',
attrib = {},
text = '',
children = [],
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1Or2.CodeProps({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1Or2.CodeProps({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
):
for i in self[1:]:
_, j = i.post_process(
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
-1, # _tag
-1 # precedence
)
- tag_or_symbol = pyacc.symbols[j] if j >= 0 else pyacc.tags[~j]
+ tag_or_symbol = _ast.symbols[j] if j >= 0 else _ast.tags[~j]
assert tag_or_symbol.code_props[self._type] is None
tag_or_symbol.code_props[self._type] = self[0]
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1Or2_DefaultPrec',
+ tag = 'AST_Section1Or2_DefaultPrec',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1Or2.DefaultPrec({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1Or2.DefaultPrec({0:s})'.format(', '.join(params))
# GENERATE END
class NTerm(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1Or2_NTerm',
+ tag = 'AST_Section1Or2_NTerm',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1Or2.NTerm({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1Or2.NTerm({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
_tag = -1
for i in self:
_tag, _ = i.post_process(
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
string_to_symbol,
name_to_tag,
- PYACC.Symbol.TYPE_NONTERMINAL, # _type
+ AST.Symbol.TYPE_NONTERMINAL, # _type
_tag,
-1 # precedence
)
# GENERATE ELEMENT(int _type) BEGIN
def __init__(
self,
- tag = 'PYACC_Section1Or2_Precedence',
+ tag = 'AST_Section1Or2_Precedence',
attrib = {},
text = '',
children = [],
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1Or2.Precedence({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1Or2.Precedence({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
_tag = -1
for i in self:
_tag, _ = i.post_process(
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
string_to_symbol,
name_to_tag,
- PYACC.Symbol.TYPE_TERMINAL, # _type
+ AST.Symbol.TYPE_TERMINAL, # _type
_tag,
- len(pyacc.associativities) # precedence
+ len(_ast.associativities) # precedence
)
- pyacc.associativities.append(self._type)
+ _ast.associativities.append(self._type)
class Start(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1Or2_Start',
+ tag = 'AST_Section1Or2_Start',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1Or2.Start({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1Or2.Start({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
string_to_symbol,
name_to_tag
):
- _, pyacc.start_nonterminal = self[0].post_process(
- pyacc,
+ _, _ast.start_nonterminal = self[0].post_process(
+ _ast,
section,
character_to_symbol,
name_to_symbol,
string_to_symbol,
name_to_tag,
- PYACC.Symbol.TYPE_NONTERMINAL, # _type
+ AST.Symbol.TYPE_NONTERMINAL, # _type
-1, # _tag
-1 # precedence
)
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1Or2_Token',
+ tag = 'AST_Section1Or2_Token',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1Or2.Token({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1Or2.Token({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
_tag = -1
for i in self:
_tag, _ = i.post_process(
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
string_to_symbol,
name_to_tag,
- PYACC.Symbol.TYPE_TERMINAL, # _type
+ AST.Symbol.TYPE_TERMINAL, # _type
_tag,
-1 # precedence
)
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1Or2_Type',
+ tag = 'AST_Section1Or2_Type',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1Or2.Type({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1Or2.Type({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
_tag = -1
for i in self:
_tag, _ = i.post_process(
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1Or2_Union',
+ tag = 'AST_Section1Or2_Union',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1Or2.Union({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1Or2.Union({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
):
name = self[0].get_text()
if len(name):
- assert len(pyacc.union_name) == 0
- pyacc.union_name = name
- pyacc.union_text.append(self[1][0])
+ assert len(_ast.union_name) == 0
+ _ast.union_name = name
+ _ast.union_text.append(self[1][0])
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1Or2',
+ tag = 'AST_Section1Or2',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1Or2({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1Or2({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
character_to_symbol,
name_to_symbol,
string_to_symbol,
):
for i in self:
i.post_process(
- pyacc,
+ _ast,
self,
character_to_symbol,
name_to_symbol,
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_Debug',
+ tag = 'AST_Section1_Debug',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.Debug({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.Debug({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_Define',
+ tag = 'AST_Section1_Define',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.Define({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.Define({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
if len(self) < 2 else
(
self[1]
- if isinstance(self[1], PYACC.ID) else
+ if isinstance(self[1], AST.ID) else
self[1][0] # String or BracedCode
).get_text()
)
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_Defines',
+ tag = 'AST_Section1_Defines',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.Defines({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.Defines({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_ErrorVerbose',
+ tag = 'AST_Section1_ErrorVerbose',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.ErrorVerbose({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.ErrorVerbose({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
# GENERATE ELEMENT(int value) BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_Expect',
+ tag = 'AST_Section1_Expect',
attrib = {},
text = '',
children = [],
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.Expect({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.Expect({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
# GENERATE ELEMENT(int value) BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_ExpectRR',
+ tag = 'AST_Section1_ExpectRR',
attrib = {},
text = '',
children = [],
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.ExpectRR({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.ExpectRR({0:s})'.format(', '.join(params))
# GENERATE END
class FilePrefix(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_FilePrefix',
+ tag = 'AST_Section1_FilePrefix',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.FilePrefix({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.FilePrefix({0:s})'.format(', '.join(params))
# GENERATE END
class GLRParser(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_GLRParser',
+ tag = 'AST_Section1_GLRParser',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.GLRParser({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.GLRParser({0:s})'.format(', '.join(params))
# GENERATE END
class InitialAction(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_InitialAction',
+ tag = 'AST_Section1_InitialAction',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.InitialAction({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.InitialAction({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
string_to_symbol,
name_to_tag
):
- assert isinstance(self[0], PYACC.Text) # temporary
- pyacc.initial_action_text.append(self[0])
+ assert isinstance(self[0], AST.Text) # temporary
+ _ast.initial_action_text.append(self[0])
class Language(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_Language',
+ tag = 'AST_Section1_Language',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.Language({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.Language({0:s})'.format(', '.join(params))
# GENERATE END
class Lines(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_Lines',
+ tag = 'AST_Section1_Lines',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.Lines({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.Lines({0:s})'.format(', '.join(params))
# GENERATE END
class Locations(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_Locations',
+ tag = 'AST_Section1_Locations',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.Locations({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.Locations({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_NamePrefix',
+ tag = 'AST_Section1_NamePrefix',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.NamePrefix({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.NamePrefix({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_NonDeterministicParser',
+ tag = 'AST_Section1_NonDeterministicParser',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.NonDeterministicParser({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.NonDeterministicParser({0:s})'.format(', '.join(params))
# GENERATE END
class Output(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_Output',
+ tag = 'AST_Section1_Output',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.Output({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.Output({0:s})'.format(', '.join(params))
# GENERATE END
class Param(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_Param',
+ tag = 'AST_Section1_Param',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.Param({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.Param({0:s})'.format(', '.join(params))
# GENERATE END
class Prologue(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_Prologue',
+ tag = 'AST_Section1_Prologue',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.Prologue({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.Prologue({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
name_to_tag
):
(
- pyacc.before_union_text
- if len(pyacc.union_text) == 0 else
- pyacc.after_union_text
+ _ast.before_union_text
+ if len(_ast.union_text) == 0 else
+ _ast.after_union_text
).append(self[0])
class PureParser(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_PureParser',
+ tag = 'AST_Section1_PureParser',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.PureParser({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.PureParser({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_Require',
+ tag = 'AST_Section1_Require',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.Require({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.Require({0:s})'.format(', '.join(params))
# GENERATE END
class Skeleton(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_Skeleton',
+ tag = 'AST_Section1_Skeleton',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.Skeleton({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.Skeleton({0:s})'.format(', '.join(params))
# GENERATE END
class TokenTable(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_TokenTable',
+ tag = 'AST_Section1_TokenTable',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.TokenTable({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.TokenTable({0:s})'.format(', '.join(params))
# GENERATE END
class Verbose(Item):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_Verbose',
+ tag = 'AST_Section1_Verbose',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.Verbose({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.Verbose({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section1_YACC',
+ tag = 'AST_Section1_YACC',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1.YACC({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1.YACC({0:s})'.format(', '.join(params))
# GENERATE END
# GENERATE ELEMENT(str type_prefix, str name_prefix, int api_pure, bool locations, bool error_verbose, str parse_lac, bool debug, bool defines, int expect, bool verbose) BEGIN
def __init__(
self,
- tag = 'PYACC_Section1',
+ tag = 'AST_Section1',
attrib = {},
text = '',
children = [],
expect = -1,
verbose = False
):
- PYACC.Section1Or2.__init__(
+ AST.Section1Or2.__init__(
self,
tag,
attrib,
verbose
)
def serialize(self, ref_list):
- PYACC.Section1Or2.serialize(self, ref_list)
+ AST.Section1Or2.serialize(self, ref_list)
self.set('type_prefix', element.serialize_str(self.type_prefix))
self.set('name_prefix', element.serialize_str(self.name_prefix))
self.set('api_pure', element.serialize_int(self.api_pure))
self.set('expect', element.serialize_int(self.expect))
self.set('verbose', element.serialize_bool(self.verbose))
def deserialize(self, ref_list):
- PYACC.Section1Or2.deserialize(self, ref_list)
+ AST.Section1Or2.deserialize(self, ref_list)
self.type_prefix = element.deserialize_str(self.get('type_prefix', ''))
self.name_prefix = element.deserialize_str(self.get('name_prefix', ''))
self.api_pure = element.deserialize_int(self.get('api_pure', '-1'))
self.expect = element.deserialize_int(self.get('expect', '-1'))
self.verbose = element.deserialize_bool(self.get('verbose', 'false'))
def copy(self, factory = None):
- result = PYACC.Section1Or2.copy(
+ result = AST.Section1Or2.copy(
self,
Section1 if factory is None else factory
)
result.verbose = self.verbose
return result
def repr_serialize(self, params):
- PYACC.Section1Or2.repr_serialize(self, params)
+ AST.Section1Or2.repr_serialize(self, params)
if self.type_prefix != '':
params.append(
'type_prefix = {0:s}'.format(repr(self.type_prefix))
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section1({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section1({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
character_to_symbol,
name_to_symbol,
string_to_symbol,
self.defines = False
self.expect = -1
self.verbose = False
- PYACC.Section1Or2.post_process(
+ AST.Section1Or2.post_process(
self,
- pyacc,
+ _ast,
character_to_symbol,
name_to_symbol,
string_to_symbol,
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section2_Rules',
+ tag = 'AST_Section2_Rules',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section2.Rules({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section2.Rules({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
name_to_tag
):
_, lhs_nonterminal = self[0].post_process(
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
string_to_symbol,
name_to_tag,
- PYACC.Symbol.TYPE_NONTERMINAL, # _type
+ AST.Symbol.TYPE_NONTERMINAL, # _type
-1, # _tag
-1 # precedence
)
- if pyacc.first_nonterminal == -1:
- pyacc.first_nonterminal = lhs_nonterminal
+ if _ast.first_nonterminal == -1:
+ _ast.first_nonterminal = lhs_nonterminal
for i in self[1:]:
i.post_process(
- pyacc,
+ _ast,
section,
lhs_nonterminal,
character_to_symbol,
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section2',
+ tag = 'AST_Section2',
attrib = {},
text = '',
children = []
):
- PYACC.Section1Or2.__init__(
+ AST.Section1Or2.__init__(
self,
tag,
attrib,
children
)
def copy(self, factory = None):
- result = PYACC.Section1Or2.copy(
+ result = AST.Section1Or2.copy(
self,
Section2 if factory is None else factory
)
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section2({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section2({0:s})'.format(', '.join(params))
# GENERATE END
class String(element.Element):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_String',
+ tag = 'AST_String',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.String({0:s})'.format(', '.join(params))
+ return 'ast.AST.String({0:s})'.format(', '.join(params))
# GENERATE END
class TagOrSymbolRef(element.Element):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_TagOrSymbolRef',
+ tag = 'AST_TagOrSymbolRef',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.TagOrSymbolRef({0:s})'.format(', '.join(params))
+ return 'ast.AST.TagOrSymbolRef({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_TagRef',
+ tag = 'AST_TagRef',
attrib = {},
text = '',
children = []
):
- PYACC.TagOrSymbolRef.__init__(
+ AST.TagOrSymbolRef.__init__(
self,
tag,
attrib,
children
)
def copy(self, factory = None):
- result = PYACC.TagOrSymbolRef.copy(
+ result = AST.TagOrSymbolRef.copy(
self,
TagRef if factory is None else factory
)
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.TagRef({0:s})'.format(', '.join(params))
+ return 'ast.AST.TagRef({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
if name in name_to_tag:
_tag = name_to_tag[name]
else:
- _tag = len(pyacc.tags)
+ _tag = len(_ast.tags)
name_to_tag[name] = _tag
- pyacc.tags.append(
- PYACC.Tag(name = name, code_props = [None, None])
+ _ast.tags.append(
+ AST.Tag(name = name, code_props = [None, None])
)
return (_tag, ~_tag)
# GENERATE ELEMENT(int user_token) BEGIN
def __init__(
self,
- tag = 'PYACC_SymbolRef',
+ tag = 'AST_SymbolRef',
attrib = {},
text = '',
children = [],
user_token = -1
):
- PYACC.TagOrSymbolRef.__init__(
+ AST.TagOrSymbolRef.__init__(
self,
tag,
attrib,
user_token
)
def serialize(self, ref_list):
- PYACC.TagOrSymbolRef.serialize(self, ref_list)
+ AST.TagOrSymbolRef.serialize(self, ref_list)
self.set('user_token', element.serialize_int(self.user_token))
def deserialize(self, ref_list):
- PYACC.TagOrSymbolRef.deserialize(self, ref_list)
+ AST.TagOrSymbolRef.deserialize(self, ref_list)
self.user_token = element.deserialize_int(self.get('user_token', '-1'))
def copy(self, factory = None):
- result = PYACC.TagOrSymbolRef.copy(
+ result = AST.TagOrSymbolRef.copy(
self,
SymbolRef if factory is None else factory
)
result.user_token = self.user_token
return result
def repr_serialize(self, params):
- PYACC.TagOrSymbolRef.repr_serialize(self, params)
+ AST.TagOrSymbolRef.repr_serialize(self, params)
if self.user_token != -1:
params.append(
'user_token = {0:s}'.format(repr(self.user_token))
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.SymbolRef({0:s})'.format(', '.join(params))
+ return 'ast.AST.SymbolRef({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
section,
character_to_symbol,
name_to_symbol,
_tag,
precedence
):
- if isinstance(self[0], PYACC.Char):
+ if isinstance(self[0], AST.Char):
character = ord(self[0][0].get_text())
assert character != 0 # would conflict with YYEOF
if character in character_to_symbol:
symbol = character_to_symbol[character]
else:
- symbol = len(pyacc.symbols)
+ symbol = len(_ast.symbols)
character_to_symbol[character] = symbol
- pyacc.symbols.append(
- PYACC.Symbol(
+ _ast.symbols.append(
+ AST.Symbol(
code_props = [None, None],
- _type = PYACC.Symbol.TYPE_TERMINAL,
+ _type = AST.Symbol.TYPE_TERMINAL,
character_set = [character, character + 1]
)
)
- elif isinstance(self[0], PYACC.ID):
+ elif isinstance(self[0], AST.ID):
name = self[0].get_text()
if name in name_to_symbol:
symbol = name_to_symbol[name]
# 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(
+ assert _ast.symbols[symbol].name == '$end'
+ _ast.symbols[symbol] = AST.Symbol(
name = name,
code_props = [None, None],
character_set = []
)
else:
- symbol = len(pyacc.symbols)
+ symbol = len(_ast.symbols)
name_to_symbol[name] = symbol
- pyacc.symbols.append(
- PYACC.Symbol(
+ _ast.symbols.append(
+ AST.Symbol(
name = name,
code_props = [None, None],
character_set = []
)
)
- elif isinstance(self[0], PYACC.String):
+ elif isinstance(self[0], AST.String):
string = self[0][0].get_text()
symbol = string_to_symbol[string] # must already exist
else:
# insert information from the SymbolRef element
if self.user_token != -1:
- assert len(pyacc.symbols[symbol].character_set) == 0
- pyacc.symbols[symbol].character_set = (
+ assert len(_ast.symbols[symbol].character_set) == 0
+ _ast.symbols[symbol].character_set = (
[self.user_token, self.user_token + 1]
)
if len(self) >= 2:
# insert information from the calling contexxt
if _type != -1:
- if pyacc.symbols[symbol]._type == -1:
- pyacc.symbols[symbol]._type = _type
+ if _ast.symbols[symbol]._type == -1:
+ _ast.symbols[symbol]._type = _type
else:
- assert pyacc.symbols[symbol]._type == _type
+ assert _ast.symbols[symbol]._type == _type
if _tag != -1:
- assert pyacc.symbols[symbol]._tag == -1
- pyacc.symbols[symbol]._tag = _tag
+ assert _ast.symbols[symbol]._tag == -1
+ _ast.symbols[symbol]._tag = _tag
if precedence != -1:
- assert pyacc.symbols[symbol].precedence == -1
- pyacc.symbols[symbol].precedence = precedence
+ assert _ast.symbols[symbol].precedence == -1
+ _ast.symbols[symbol].precedence = precedence
return (_tag, symbol)
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Text_Item',
+ tag = 'AST_Text_Item',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Text.Item({0:s})'.format(', '.join(params))
+ return 'ast.AST.Text.Item({0:s})'.format(', '.join(params))
# GENERATE END
def get_text(self, python = False):
raise NotImplementedError
# GENERATE ELEMENT(int character) BEGIN
def __init__(
self,
- tag = 'PYACC_Text_Escape',
+ tag = 'AST_Text_Escape',
attrib = {},
text = '',
children = [],
character = -1
):
- PYACC.Text.Item.__init__(
+ AST.Text.Item.__init__(
self,
tag,
attrib,
character
)
def serialize(self, ref_list):
- PYACC.Text.Item.serialize(self, ref_list)
+ AST.Text.Item.serialize(self, ref_list)
self.set('character', element.serialize_int(self.character))
def deserialize(self, ref_list):
- PYACC.Text.Item.deserialize(self, ref_list)
+ AST.Text.Item.deserialize(self, ref_list)
self.character = element.deserialize_int(self.get('character', '-1'))
def copy(self, factory = None):
- result = PYACC.Text.Item.copy(
+ result = AST.Text.Item.copy(
self,
Escape if factory is None else factory
)
result.character = self.character
return result
def repr_serialize(self, params):
- PYACC.Text.Item.repr_serialize(self, params)
+ AST.Text.Item.repr_serialize(self, params)
if self.character != -1:
params.append(
'character = {0:s}'.format(repr(self.character))
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Text.Escape({0:s})'.format(', '.join(params))
+ return 'ast.AST.Text.Escape({0:s})'.format(', '.join(params))
# GENERATE END
def get_text(self, python = False):
return chr(self.character)
# GENERATE ELEMENT(int offset, int index) BEGIN
def __init__(
self,
- tag = 'PYACC_Text_StackLocation',
+ tag = 'AST_Text_StackLocation',
attrib = {},
text = '',
children = [],
offset = -1,
index = -1
):
- PYACC.Text.Item.__init__(
+ AST.Text.Item.__init__(
self,
tag,
attrib,
index
)
def serialize(self, ref_list):
- PYACC.Text.Item.serialize(self, ref_list)
+ AST.Text.Item.serialize(self, ref_list)
self.set('offset', element.serialize_int(self.offset))
self.set('index', element.serialize_int(self.index))
def deserialize(self, ref_list):
- PYACC.Text.Item.deserialize(self, ref_list)
+ AST.Text.Item.deserialize(self, ref_list)
self.offset = element.deserialize_int(self.get('offset', '-1'))
self.index = element.deserialize_int(self.get('index', '-1'))
def copy(self, factory = None):
- result = PYACC.Text.Item.copy(
+ result = AST.Text.Item.copy(
self,
StackLocation if factory is None else factory
)
result.index = self.index
return result
def repr_serialize(self, params):
- PYACC.Text.Item.repr_serialize(self, params)
+ AST.Text.Item.repr_serialize(self, params)
if self.offset != -1:
params.append(
'offset = {0:s}'.format(repr(self.offset))
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Text.StackLocation({0:s})'.format(', '.join(params))
+ return 'ast.AST.Text.StackLocation({0:s})'.format(', '.join(params))
# GENERATE END
def get_text(self, python = False):
return (
# GENERATE ELEMENT(str tag_name, int offset, int index) BEGIN
def __init__(
self,
- tag = 'PYACC_Text_StackReference',
+ tag = 'AST_Text_StackReference',
attrib = {},
text = '',
children = [],
offset = -1,
index = -1
):
- PYACC.Text.Item.__init__(
+ AST.Text.Item.__init__(
self,
tag,
attrib,
index
)
def serialize(self, ref_list):
- PYACC.Text.Item.serialize(self, ref_list)
+ AST.Text.Item.serialize(self, ref_list)
self.set('tag_name', element.serialize_str(self.tag_name))
self.set('offset', element.serialize_int(self.offset))
self.set('index', element.serialize_int(self.index))
def deserialize(self, ref_list):
- PYACC.Text.Item.deserialize(self, ref_list)
+ AST.Text.Item.deserialize(self, ref_list)
self.tag_name = element.deserialize_str(self.get('tag_name', ''))
self.offset = element.deserialize_int(self.get('offset', '-1'))
self.index = element.deserialize_int(self.get('index', '-1'))
def copy(self, factory = None):
- result = PYACC.Text.Item.copy(
+ result = AST.Text.Item.copy(
self,
StackReference if factory is None else factory
)
result.index = self.index
return result
def repr_serialize(self, params):
- PYACC.Text.Item.repr_serialize(self, params)
+ AST.Text.Item.repr_serialize(self, params)
if self.tag_name != '':
params.append(
'tag_name = {0:s}'.format(repr(self.tag_name))
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Text.StackReference({0:s})'.format(', '.join(params))
+ return 'ast.AST.Text.StackReference({0:s})'.format(', '.join(params))
# GENERATE END
def get_text(self, python = False):
return (
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Text_ValueLocation',
+ tag = 'AST_Text_ValueLocation',
attrib = {},
text = '',
children = []
):
- PYACC.Text.Item.__init__(
+ AST.Text.Item.__init__(
self,
tag,
attrib,
children
)
def copy(self, factory = None):
- result = PYACC.Text.Item.copy(
+ result = AST.Text.Item.copy(
self,
ValueLocation if factory is None else factory
)
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Text.ValueLocation({0:s})'.format(', '.join(params))
+ return 'ast.AST.Text.ValueLocation({0:s})'.format(', '.join(params))
# GENERATE END
def get_text(self, python = False):
return '(yyloc)'
# GENERATE ELEMENT(str tag_name) BEGIN
def __init__(
self,
- tag = 'PYACC_Text_ValueReference',
+ tag = 'AST_Text_ValueReference',
attrib = {},
text = '',
children = [],
tag_name = ''
):
- PYACC.Text.Item.__init__(
+ AST.Text.Item.__init__(
self,
tag,
attrib,
)
self.tag_name = tag_name
def serialize(self, ref_list):
- PYACC.Text.Item.serialize(self, ref_list)
+ AST.Text.Item.serialize(self, ref_list)
self.set('tag_name', element.serialize_str(self.tag_name))
def deserialize(self, ref_list):
- PYACC.Text.Item.deserialize(self, ref_list)
+ AST.Text.Item.deserialize(self, ref_list)
self.tag_name = element.deserialize_str(self.get('tag_name', ''))
def copy(self, factory = None):
- result = PYACC.Text.Item.copy(
+ result = AST.Text.Item.copy(
self,
ValueReference if factory is None else factory
)
result.tag_name = self.tag_name
return result
def repr_serialize(self, params):
- PYACC.Text.Item.repr_serialize(self, params)
+ AST.Text.Item.repr_serialize(self, params)
if self.tag_name != '':
params.append(
'tag_name = {0:s}'.format(repr(self.tag_name))
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Text.ValueReference({0:s})'.format(', '.join(params))
+ return 'ast.AST.Text.ValueReference({0:s})'.format(', '.join(params))
# GENERATE END
def get_text(self, python = False):
return (
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Text',
+ tag = 'AST_Text',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Text({0:s})'.format(', '.join(params))
+ return 'ast.AST.Text({0:s})'.format(', '.join(params))
# GENERATE END
def get_text(self, python = False):
return ''.join(
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_BracedCode',
+ tag = 'AST_BracedCode',
attrib = {},
text = '',
children = []
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.BracedCode({0:s})'.format(', '.join(params))
+ return 'ast.AST.BracedCode({0:s})'.format(', '.join(params))
# GENERATE END
class ID(Text):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_ID',
+ tag = 'AST_ID',
attrib = {},
text = '',
children = []
):
- PYACC.Text.__init__(
+ AST.Text.__init__(
self,
tag,
attrib,
children
)
def copy(self, factory = None):
- result = PYACC.Text.copy(
+ result = AST.Text.copy(
self,
ID if factory is None else factory
)
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.ID({0:s})'.format(', '.join(params))
+ return 'ast.AST.ID({0:s})'.format(', '.join(params))
# GENERATE END
class Section3(Text):
# GENERATE ELEMENT() BEGIN
def __init__(
self,
- tag = 'PYACC_Section3',
+ tag = 'AST_Section3',
attrib = {},
text = '',
children = []
):
- PYACC.Text.__init__(
+ AST.Text.__init__(
self,
tag,
attrib,
children
)
def copy(self, factory = None):
- result = PYACC.Text.copy(
+ result = AST.Text.copy(
self,
Section3 if factory is None else factory
)
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC.Section3({0:s})'.format(', '.join(params))
+ return 'ast.AST.Section3({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(
self,
- pyacc,
+ _ast,
character_to_symbol,
name_to_symbol,
string_to_symbol,
# GENERATE ELEMENT(list(ref) top_text, list(ref) before_union_text, list(ref) requires_text, str union_name, list(ref) union_text, list(ref) after_union_text, list(ref) initial_action_text, list(ref) tags, list(ref) symbols, int n_productions, list(ref) productions, int first_nonterminal, int start_nonterminal, list(int) associativities) BEGIN
def __init__(
self,
- tag = 'PYACC',
+ tag = 'AST',
attrib = {},
text = '',
children = [],
def copy(self, factory = None):
result = element.Element.copy(
self,
- PYACC if factory is None else factory
+ AST if factory is None else factory
)
result.top_text = self.top_text
result.before_union_text = self.before_union_text
def __repr__(self):
params = []
self.repr_serialize(params)
- return 'ast.PYACC({0:s})'.format(', '.join(params))
+ return 'ast.AST({0:s})'.format(', '.join(params))
# GENERATE END
def post_process(self):
self.initial_action_text = []
self.precedences = 0
self.symbols = [
- PYACC.Symbol(
+ AST.Symbol(
name = '$end',
code_props = [None, None],
- _type = PYACC.Symbol.TYPE_TERMINAL,
+ _type = AST.Symbol.TYPE_TERMINAL,
character_set = [0, 1]
),
- PYACC.Symbol(
+ AST.Symbol(
name = 'error',
- _type = PYACC.Symbol.TYPE_TERMINAL,
+ _type = AST.Symbol.TYPE_TERMINAL,
code_props = [None, None]
),
- PYACC.Symbol(
+ AST.Symbol(
name = '$undefined',
- _type = PYACC.Symbol.TYPE_TERMINAL,
+ _type = AST.Symbol.TYPE_TERMINAL,
code_props = [None, None]
)
]
# the following stores the destructor and printer for each tag
self.tags = [
- PYACC.Tag(name = '', code_props = [None, None]),
- PYACC.Tag(name = '*', code_props = [None, None]),
+ AST.Tag(name = '', code_props = [None, None]),
+ AST.Tag(name = '*', code_props = [None, None]),
]
self.n_productions = 1 # includes start and midrule action productions
self.productions = []
# 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:
+ if i._type == AST.Symbol.TYPE_TERMINAL:
if len(i.character_set) == 0:
i.character_set = [token, token + 1]
token += 1
- elif i._type == PYACC.Symbol.TYPE_NONTERMINAL:
+ elif i._type == AST.Symbol.TYPE_NONTERMINAL:
pass
else:
assert False
[
i.character_set[-1]
for i in self.symbols
- if i._type == PYACC.Symbol.TYPE_TERMINAL
+ if i._type == AST.Symbol.TYPE_TERMINAL
]
),
# eof_terminal
[
k
for i in self.symbols
- if i._type == PYACC.Symbol.TYPE_TERMINAL
+ if i._type == AST.Symbol.TYPE_TERMINAL
for j in range(0, len(i.character_set), 2)
for k in [
(i.character_set[j], True, -1),
# GENERATE FACTORY(element.Element) BEGIN
tag_to_class = {
'Item': Item,
- 'PYACC': PYACC,
- 'PYACC_TagOrSymbol': PYACC.TagOrSymbol,
- 'PYACC_Tag': PYACC.Tag,
- 'PYACC_Symbol': PYACC.Symbol,
- 'PYACC_BracedPredicate': PYACC.BracedPredicate,
- 'PYACC_Char': PYACC.Char,
- 'PYACC_Int': PYACC.Int,
- 'PYACC_Production': PYACC.Production,
- 'PYACC_Production_Item': PYACC.Production.Item,
- 'PYACC_Production_Action': PYACC.Production.Action,
- 'PYACC_Production_DPrec': PYACC.Production.DPrec,
- 'PYACC_Production_Empty': PYACC.Production.Empty,
- 'PYACC_Production_Merge': PYACC.Production.Merge,
- 'PYACC_Production_Prec': PYACC.Production.Prec,
- 'PYACC_Production_SymbolRef': PYACC.Production.SymbolRef,
- 'PYACC_Section1Or2': PYACC.Section1Or2,
- 'PYACC_Section1Or2_Code': PYACC.Section1Or2.Code,
- 'PYACC_Section1Or2_CodeProps': PYACC.Section1Or2.CodeProps,
- 'PYACC_Section1Or2_DefaultPrec': PYACC.Section1Or2.DefaultPrec,
- 'PYACC_Section1Or2_NTerm': PYACC.Section1Or2.NTerm,
- 'PYACC_Section1Or2_Precedence': PYACC.Section1Or2.Precedence,
- 'PYACC_Section1Or2_Start': PYACC.Section1Or2.Start,
- 'PYACC_Section1Or2_Token': PYACC.Section1Or2.Token,
- 'PYACC_Section1Or2_Type': PYACC.Section1Or2.Type,
- 'PYACC_Section1Or2_Union': PYACC.Section1Or2.Union,
- 'PYACC_Section1': PYACC.Section1,
- 'PYACC_Section1_Debug': PYACC.Section1.Debug,
- 'PYACC_Section1_Define': PYACC.Section1.Define,
- 'PYACC_Section1_Defines': PYACC.Section1.Defines,
- 'PYACC_Section1_ErrorVerbose': PYACC.Section1.ErrorVerbose,
- 'PYACC_Section1_Expect': PYACC.Section1.Expect,
- 'PYACC_Section1_ExpectRR': PYACC.Section1.ExpectRR,
- 'PYACC_Section1_FilePrefix': PYACC.Section1.FilePrefix,
- 'PYACC_Section1_GLRParser': PYACC.Section1.GLRParser,
- 'PYACC_Section1_InitialAction': PYACC.Section1.InitialAction,
- 'PYACC_Section1_Language': PYACC.Section1.Language,
- 'PYACC_Section1_Lines': PYACC.Section1.Lines,
- 'PYACC_Section1_Locations': PYACC.Section1.Locations,
- 'PYACC_Section1_NamePrefix': PYACC.Section1.NamePrefix,
- 'PYACC_Section1_NonDeterministicParser': PYACC.Section1.NonDeterministicParser,
- 'PYACC_Section1_Output': PYACC.Section1.Output,
- 'PYACC_Section1_Param': PYACC.Section1.Param,
- 'PYACC_Section1_Prologue': PYACC.Section1.Prologue,
- 'PYACC_Section1_PureParser': PYACC.Section1.PureParser,
- 'PYACC_Section1_Require': PYACC.Section1.Require,
- 'PYACC_Section1_Skeleton': PYACC.Section1.Skeleton,
- 'PYACC_Section1_TokenTable': PYACC.Section1.TokenTable,
- 'PYACC_Section1_Verbose': PYACC.Section1.Verbose,
- 'PYACC_Section1_YACC': PYACC.Section1.YACC,
- 'PYACC_Section2': PYACC.Section2,
- 'PYACC_Section2_Rules': PYACC.Section2.Rules,
- 'PYACC_String': PYACC.String,
- 'PYACC_TagOrSymbolRef': PYACC.TagOrSymbolRef,
- 'PYACC_TagRef': PYACC.TagRef,
- 'PYACC_SymbolRef': PYACC.SymbolRef,
- 'PYACC_Text': PYACC.Text,
- 'PYACC_Text_Item': PYACC.Text.Item,
- 'PYACC_Text_Escape': PYACC.Text.Escape,
- 'PYACC_Text_StackLocation': PYACC.Text.StackLocation,
- 'PYACC_Text_StackReference': PYACC.Text.StackReference,
- 'PYACC_Text_ValueLocation': PYACC.Text.ValueLocation,
- 'PYACC_Text_ValueReference': PYACC.Text.ValueReference,
- 'PYACC_BracedCode': PYACC.BracedCode,
- 'PYACC_ID': PYACC.ID,
- 'PYACC_Section3': PYACC.Section3
+ 'AST': AST,
+ 'AST_TagOrSymbol': AST.TagOrSymbol,
+ 'AST_Tag': AST.Tag,
+ 'AST_Symbol': AST.Symbol,
+ 'AST_BracedPredicate': AST.BracedPredicate,
+ 'AST_Char': AST.Char,
+ 'AST_Int': AST.Int,
+ 'AST_Production': AST.Production,
+ 'AST_Production_Item': AST.Production.Item,
+ 'AST_Production_Action': AST.Production.Action,
+ 'AST_Production_DPrec': AST.Production.DPrec,
+ 'AST_Production_Empty': AST.Production.Empty,
+ 'AST_Production_Merge': AST.Production.Merge,
+ 'AST_Production_Prec': AST.Production.Prec,
+ 'AST_Production_SymbolRef': AST.Production.SymbolRef,
+ 'AST_Section1Or2': AST.Section1Or2,
+ 'AST_Section1Or2_Code': AST.Section1Or2.Code,
+ 'AST_Section1Or2_CodeProps': AST.Section1Or2.CodeProps,
+ 'AST_Section1Or2_DefaultPrec': AST.Section1Or2.DefaultPrec,
+ 'AST_Section1Or2_NTerm': AST.Section1Or2.NTerm,
+ 'AST_Section1Or2_Precedence': AST.Section1Or2.Precedence,
+ 'AST_Section1Or2_Start': AST.Section1Or2.Start,
+ 'AST_Section1Or2_Token': AST.Section1Or2.Token,
+ 'AST_Section1Or2_Type': AST.Section1Or2.Type,
+ 'AST_Section1Or2_Union': AST.Section1Or2.Union,
+ 'AST_Section1': AST.Section1,
+ 'AST_Section1_Debug': AST.Section1.Debug,
+ 'AST_Section1_Define': AST.Section1.Define,
+ 'AST_Section1_Defines': AST.Section1.Defines,
+ 'AST_Section1_ErrorVerbose': AST.Section1.ErrorVerbose,
+ 'AST_Section1_Expect': AST.Section1.Expect,
+ 'AST_Section1_ExpectRR': AST.Section1.ExpectRR,
+ 'AST_Section1_FilePrefix': AST.Section1.FilePrefix,
+ 'AST_Section1_GLRParser': AST.Section1.GLRParser,
+ 'AST_Section1_InitialAction': AST.Section1.InitialAction,
+ 'AST_Section1_Language': AST.Section1.Language,
+ 'AST_Section1_Lines': AST.Section1.Lines,
+ 'AST_Section1_Locations': AST.Section1.Locations,
+ 'AST_Section1_NamePrefix': AST.Section1.NamePrefix,
+ 'AST_Section1_NonDeterministicParser': AST.Section1.NonDeterministicParser,
+ 'AST_Section1_Output': AST.Section1.Output,
+ 'AST_Section1_Param': AST.Section1.Param,
+ 'AST_Section1_Prologue': AST.Section1.Prologue,
+ 'AST_Section1_PureParser': AST.Section1.PureParser,
+ 'AST_Section1_Require': AST.Section1.Require,
+ 'AST_Section1_Skeleton': AST.Section1.Skeleton,
+ 'AST_Section1_TokenTable': AST.Section1.TokenTable,
+ 'AST_Section1_Verbose': AST.Section1.Verbose,
+ 'AST_Section1_YACC': AST.Section1.YACC,
+ 'AST_Section2': AST.Section2,
+ 'AST_Section2_Rules': AST.Section2.Rules,
+ 'AST_String': AST.String,
+ 'AST_TagOrSymbolRef': AST.TagOrSymbolRef,
+ 'AST_TagRef': AST.TagRef,
+ 'AST_SymbolRef': AST.SymbolRef,
+ 'AST_Text': AST.Text,
+ 'AST_Text_Item': AST.Text.Item,
+ 'AST_Text_Escape': AST.Text.Escape,
+ 'AST_Text_StackLocation': AST.Text.StackLocation,
+ 'AST_Text_StackReference': AST.Text.StackReference,
+ 'AST_Text_ValueLocation': AST.Text.ValueLocation,
+ 'AST_Text_ValueReference': AST.Text.ValueReference,
+ 'AST_BracedCode': AST.BracedCode,
+ 'AST_ID': AST.ID,
+ 'AST_Section3': AST.Section3
}
def factory(tag, attrib = {}, *args, **kwargs):
return tag_to_class.get(tag, element.Element)(tag, attrib, *args, **kwargs)