from slicc.symbols import StateMachine, Type
class MachineAST(DeclAST):
- def __init__(self, slicc, idents, pairs_ast, config_parameters, decls):
+ def __init__(self, slicc, ident, pairs_ast, config_parameters, decls):
super(MachineAST, self).__init__(slicc, pairs_ast)
- self.ident = idents[0]
- self.machine_types = idents
+ self.ident = ident
self.pairs_ast = pairs_ast
self.config_parameters = config_parameters
self.decls = decls
self.symtab.popFrame()
def findMachines(self):
- # Add to MachineType enumeration
- for mtype in self.machine_types:
- machine_type = self.symtab.find("MachineType", Type)
- pairs = self.pairs_ast.pairs
+ mtype = self.ident
+ machine_type = self.symtab.find("MachineType", Type)
+ pairs = self.pairs_ast.pairs
- if mtype == self.ident:
- pairs["Primary"] = True
- else:
- pairs["Primary"] = False
-
- if not machine_type.addEnum(mtype, pairs):
- self.error("Duplicate machine name: %s:%s" % (
- machine_type, mtype))
+ pairs["Primary"] = True
+ if not machine_type.addEnum(mtype, pairs):
+ self.error("Duplicate machine name: %s:%s" % (machine_type, mtype))
# Generate code for all the internal decls
self.decls.findMachines()
p[0] = self.parse_file(filename)
def p_decl__machine0(self, p):
- "decl : MACHINE '(' idents ')' ':' obj_decls '{' decls '}'"
+ "decl : MACHINE '(' ident ')' ':' obj_decls '{' decls '}'"
p[0] = ast.MachineAST(self, p[3], [], p[7], p[9])
def p_decl__machine1(self, p):
- "decl : MACHINE '(' idents pairs ')' ':' obj_decls '{' decls '}'"
+ "decl : MACHINE '(' ident pairs ')' ':' obj_decls '{' decls '}'"
p[0] = ast.MachineAST(self, p[3], p[4], p[7], p[9])
def p_decl__action(self, p):