Exemple #1
0
        public void SetupExpr(Expression expr, bool eat)
        {
            if (Error)
            {
                return;
            }

            if (eat)
            {
                Eat();
            }

            expr.Position = CurToken.Position;
            expr.CurScope = CurScope;

            ParsePostfix();

            if (Error)
            {
                return;
            }

            while (CurPostfixStack.Count > 0)
            {
                var postfix = CurPostfixStack.Dequeue();
                postfix.Child = expr;
                expr          = postfix;
            }

            while (CurPrefixStack.Count > 0)
            {
                var prefix = CurPrefixStack.Dequeue();
                prefix.Child = expr;
                expr         = prefix;
            }

            CurExprStack.Enqueue(expr);
            ExpectPrefix = false;

            if (CurExprStack.Count != CurBinaryStack.Count + 1)
            {
                ReportError("Missing operator");
            }
        }
Exemple #2
0
        public void ParsePostfix()
        {
            while (Peek(TokenKind.SQUARE_START))
            {
                var args = ParseList();
                if (Error)
                {
                    return;
                }

                var op = new Call(args, CurScope);
                if (Error)
                {
                    return;
                }

                op.Position = CurToken.Position;
                op.CurScope = CurScope;
                CurPostfixStack.Enqueue(op);
            }
        }