def p_type(p): """type : WORD | WORD OP_LT type OP_GT | OP_OPEN_BRACE typednames OP_CLOSE_BRACE | KW_ENUM OP_OPEN_BRACE enum_cases OP_CLOSE_BRACE | OP_OPEN_PAREN typelist OP_CLOSE_PAREN | KW_NATIVE STRINGLITERAL""" if len(p) == 2: p[0] = syntax.TNamed(p[1]) elif len(p) == 3: p[0] = syntax.TNative(p[2]) elif len(p) == 5: if p[1] == "enum": p[0] = syntax.TEnum(p[3]) else: p[0] = syntax.TApp(p[1], p[3]) elif len(p) == 4: if p[1] == "{": p[0] = syntax.TRecord(p[2]) elif p[1] == "(": p[0] = syntax.TTuple(p[2])
def visit_ETuple(self, e): for ee in e.es: self.visit(ee) e.type = syntax.TTuple(tuple(ee.type for ee in e.es))
def visit_TTuple(self, t): return syntax.TTuple(tuple(self.visit(tt) for tt in t.ts))