} // NT_NotFact private static void NT_Fact(out Expr f) { Expr e = null; SrcPos sp = null; Symbol sy = null; int spix = 0; int number = 0; Type t = null; f = null; for (;;) { switch (Syn.Interpret()) { case 0: return; case 1: // SEM f = new LitOperand(Type.boolType, 0); break; case 2: // SEM f = new LitOperand(Type.boolType, 1); break; case 3: Lex.GETnumberAttr(out number); break; case 4: // SEM f = new LitOperand(Type.intType, number); break; case 5: Lex.GETidentAttr(out spix); break; case 6: // SEM sp = new SrcPos(); break; case 7: // SEM sy = SymTab.SymbolOf(spix, Symbol.Kind.constKind, Symbol.Kind.varKind, Symbol.Kind.parKind); f = new VarOperand(sy); break; case 8: // SEM sy = SymTab.SymbolOf(spix, Symbol.Kind.varKind, Symbol.Kind.parKind); break; case 9: // SEM sp = new SrcPos(); break; case 10: NT_Expr(out e); break; case 11: // SEM f = new ArrIdxOperator(sp, new VarOperand(sy), e); break; case 12: // SEM sy = SymTab.SymbolOf(spix, Symbol.Kind.funcKind); break; case 13: NT_ActParList(out e); break; case 14: // SEM f = new FuncCallOperator(sp, sy, e); break; case 15: // SEM sp = new SrcPos(); break; case 16: NT_Type(out t); break; case 17: NT_Expr(out e); break; case 18: // SEM f = new NewOperator(sp, t, e); break; case 19: NT_Expr(out e); break; case 20: // SEM f = e; break; } // switch } // for } // NT_Fact
} // NT_ConstDecl private static void NT_Init(out Stat s, ref Symbol sy) { int fact = 1, number = 0; s = null; for (;;) { switch (Syn.Interpret()) { case 0: return; case 1: // SEM if (sy.type != Type.boolType) { SemErr("invalid type"); } sy.val = 0; break; case 2: // SEM if (sy.type != Type.boolType) { SemErr("invalid type"); } sy.val = 1; break; case 3: // SEM fact = -1; break; case 4: Lex.GETnumberAttr(out number); break; case 5: // SEM if (sy.type.IsPtrType()) { if (number != 0) { SemErr("invalid value"); } } else if (sy.type.kind != Type.Kind.intKind) { SemErr("invalid type"); } sy.val = fact * number; break; case 6: // SEM if (sy.kind == Symbol.Kind.varKind && loopLevel > 0) { s = new AssignStat(new SrcPos(), new VarOperand(sy), new LitOperand(sy.type, sy.val)); } break; } // switch } // for } // NT_Init