void DECL(out AST e) { SymDeclaring e1; AST e2 = null; StructDcel es = null; AST idval; List <AST> el = new List <AST>(); DCL(out e1, out idval); if (la.kind == 3 || la.kind == 10 || la.kind == 12) { if (la.kind == 10 || la.kind == 12) { ASSIG(out e2, idval); } else { Get(); AST structid = new SymReferencing(t.val); string idofstruct = t.val; if (la.kind == 10) { Get(); STRUCTDECL(out el); } es = new StructDcel(idval, el); es.structId = structid; e2 = new Assigning(structid, es); e1.id = idofstruct; } } e = new Decl(e1, e2); Expect(11); }
void STRUCTDECL(out List <AST> eo) { AST e; List <AST> e2 = new List <AST>(); Expect(3); AST idval = new SymReferencing(t.val); ASSIG(out e, idval); e2.Add(e); while (la.kind == 14) { Get(); Expect(3); idval = new SymReferencing(t.val); ASSIG(out e, idval); e2.Add(e); } Expect(13); eo = e2; }
void IDENTIFIER(out AST e) { e = null; List <AST> elist = new List <AST>(); AST ei = null; Expect(3); string id = t.val; e = new SymReferencing(id); if (la.kind == 25 || la.kind == 26) { if (la.kind == 25) { Get(); IDENTIFIER(out ei); e = new DotReferencing(e, ei); } else { Get(); EXPR(out ei); Expect(27); elist.Add(ei); while (la.kind == 26) { Get(); EXPR(out ei); Expect(27); elist.Add(ei); } e = new ListReferencing(e, elist); if (la.kind == 25) { Get(); IDENTIFIER(out ei); e = new DotReferencing(e, ei); } } } }
public abstract void Visit(SymReferencing n);
void STMT(out AST e) { AST logi, n1, n2; List <AST> stm = new List <AST>(); List <AST> stm2 = new List <AST>(); string id; AST astid; e = null; switch (la.kind) { case 15: { Get(); IFELSTMT(out e); break; } case 16: { Get(); Expect(17); LOGI_EXPR(out logi); Expect(18); BLOCK(out stm); e = new WhileStmt(logi, stm); break; } case 19: { Get(); Expect(17); n1 = null; if (StartOf(1)) { DECL(out n1); } else if (la.kind == 3) { Get(); n1 = new SymReferencing(t.val); Expect(11); } else { SynErr(54); } LOGI_EXPR(out logi); Expect(11); Expect(3); astid = new SymReferencing(t.val); ASSIG(out n2, astid); Expect(18); BLOCK(out stm); e = new ForStmt(n1, logi, n2, stm); break; } case 20: { Get(); Expect(17); Expect(3); id = t.val; Expect(18); Expect(10); Expect(21); Expect(3); id = t.val; Expect(22); BLOCK(out stm2); stm.Add(new SwitchCase(id, stm2)); while (la.kind == 21) { Get(); Expect(3); id = t.val; Expect(22); BLOCK(out stm2); stm.Add(new SwitchCase(id, stm2)); } Expect(23); Expect(22); BLOCK(out stm2); stm.Add(new SwitchDefault(stm2)); Expect(13); e = new SwitchStmt(id, stm); break; } case 3: { IDENTIFIER(out e); CALL(e, out e); Expect(11); break; } case 43: case 44: case 45: case 46: case 47: case 48: case 49: { DECL(out e); break; } default: SynErr(55); break; } }
void DCL(out SymDeclaring e, out AST idval) { TYPE(out e); Expect(3); idval = new SymReferencing(t.val); e.id = t.val; }