예제 #1
0
        private void PowFactor(out Expr e)
        {
            Expr e2;

            Factor(out e);
            while (la.kind == 29)
            {
                Get();
                Factor(out e2);
                e = FunCall.Make("^", new Expr[] { e, e2 });
            }
        }
예제 #2
0
        private void Term(out Expr e)
        {
            Expr   e2;
            String op;

            PowFactor(out e);
            while (la.kind == 32 || la.kind == 33)
            {
                MulOp(out op);
                PowFactor(out e2);
                e = FunCall.Make(op, new Expr[] { e, e2 });
            }
        }
예제 #3
0
        private void LogicalTerm(out Expr e)
        {
            Expr   e2;
            String op;

            e = null;
            Term(out e);
            while (la.kind == 17 || la.kind == 18 || la.kind == 19)
            {
                AddOp(out op);
                Term(out e2);
                e = FunCall.Make(op, new Expr[] { e, e2 });
            }
        }
예제 #4
0
        private void Expr(out Expr e)
        {
            Expr   e2;
            String op;

            e = null;
            LogicalTerm(out e);
            while (StartOf(1))
            {
                LogicalOp(out op);
                LogicalTerm(out e2);
                e = FunCall.Make(op, new Expr[] { e, e2 });
            }
        }
예제 #5
0
        private void Application(out Expr e)
        {
            String s;

            Expr[] es;
            e = null;
            Name(out s);
            Expect(27);
            if (la.kind == 28)
            {
                Get();
                e = FunCall.Make(s.ToUpper(), new Expr[0]);
            }
            else if (StartOf(4))
            {
                Exprs1(out es);
                Expect(28);
                e = FunCall.Make(s.ToUpper(), es);
            }
            else
            {
                SynErr(39);
            }
        }
예제 #6
0
        private void Factor(out Expr e)
        {
            RARef  r1, r2;
            Sheet  s1 = null;
            double d;
            bool   sheetError = false;

            e = null;
            switch (la.kind)
            {
            case 1: {
                Application(out e);
                break;
            }

            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14: {
                if (StartOf(2))
                {
                }
                else
                {
                    Get();
                    s1 = workbook[t.val.Substring(0, t.val.Length - 1)];
                    if (s1 == null)
                    {
                        sheetError = true;
                    }
                }
                Raref(out r1);
                if (StartOf(3))
                {
                    if (sheetError)
                    {
                        e = new Error(ErrorValue.refError);
                    }
                    else
                    {
                        e = new CellRef(s1, r1);
                    }
                }
                else if (la.kind == 26)
                {
                    Get();
                    Raref(out r2);
                    if (sheetError)
                    {
                        e = new Error(ErrorValue.refError);
                    }
                    else
                    {
                        e = new CellArea(s1, r1, r2);
                    }
                }
                else
                {
                    SynErr(37);
                }
                break;
            }

            case 2: {
                Number(out d);
                e = new NumberConst(d);
                break;
            }

            case 18: {
                Get();
                Factor(out e);
                if (e is NumberConst)
                {
                    e = new NumberConst(-((NumberConst)e).value.value);
                }
                else
                {
                    e = FunCall.Make("NEG", new Expr[] { e });
                }

                break;
            }

            case 15: {
                Get();
                e = new TextConst(t.val.Substring(1, t.val.Length - 2));
                break;
            }

            case 27: {
                Get();
                Expr(out e);
                Expect(28);
                break;
            }

            default:
                SynErr(38);
                break;
            }
        }