void Factor(out Expression e)
        {
            string name; Expression e1; e = null; ListExpr list = new List <Expression>();

            if (la.kind == 1)
            {
                Ident(out name);
                e = new Variable(name);
                if (la.kind == 3)
                {
                    Get();
                    FormalExpr(out list);
                    Expect(4);
                    e = new FunctionCall(name, list);
                }
            }
            else if (la.kind == 2)
            {
                Get();
                e = new Constant(Convert.ToInt32(t.val),
                                 Type.IntegerType);
            }
            else if (la.kind == 25)
            {
                Get();
                Factor(out e1);
                e = new UnaryOperation(Operator.Neg, e1);
            }
            else if (la.kind == 3)
            {
                Get();
                Expr(out e1);
                Expect(4);
                e = e1;
            }
            else
            {
                SynErr(35);
            }
        }
示例#2
0
 void Factor(out Expression e)
 {
     string name; Expression e1; e = null;
     if (la.kind == 1) {
     Ident(out name);
     e = new Variable(name);
     if (la.kind == 3) {
         Get();
         Expr(out e1);
         Expect(4);
         e = new FunctionCall(name, e1);
     }
     } else if (la.kind == 2) {
     Get();
     e = new Constant(int.Parse(t.val), Type.IntegerType);
     } else if (la.kind == 18) {
     Get();
     Factor(out e1);
     e = new UnaryOperation(Operator.Neg, e1);
     } else if (la.kind == 3) {
     Get();
     Expr(out e1);
     Expect(4);
     e = e1;
     } else SynErr(25);
 }