Пример #1
0
        static void AssignmentOrCall()
        {
            int     expType;
            DesType des;

            if (IsCall(out des))
            {
                Expect(identifier_Sym);
                CodeGen.FrameHeader();
                Expect(lparen_Sym);
                Arguments(des);
                Expect(rparen_Sym);
                CodeGen.Call(des.entry.entryPoint);
            }
            else if (la.kind == identifier_Sym)
            {
                Designator(out des);
                if (des.entry.kind != Kinds.Var)
                {
                    SemError("cannot assign to " + Kinds.kindNames[des.entry.kind]);
                }
                AssignOp();
                Expression(out expType);
                if (!Assignable(des.type, expType))
                {
                    SemError("incompatible types in assignment");
                }
                CodeGen.Assign(des.type);
            }
            else
            {
                SynErr(48);
            }
            ExpectWeak(semicolon_Sym, 6);
        }
Пример #2
0
 static void Parva()
 {
     CodeGen.FrameHeader();
     // no arguments
     CodeGen.Call(mainEntryPoint);
     // forward, incomplete
     CodeGen.LeaveProgram();
     while (la.kind == void_Sym)
     {
         FuncDeclaration();
     }
     Expect(EOF_SYM);
     if
     (!mainEntryPoint.IsDefined())
     {
         SemError("missing Main function");
     }
 }