Esempio n. 1
0
        public static new EXPRESSION parse(Token first, iSCOPE context)
        {
            EXPRESSION result = ADDITIVE.parse(first, context);
            Token      token  = get();

            switch (token.code)
            {
            case TokenCode.Less:
            case TokenCode.LessEqual:
            case TokenCode.Greater:
            case TokenCode.GreaterEqual:
            case TokenCode.Equal:
            case TokenCode.NotEqual:
            case TokenCode.EqualEqual:
            case TokenCode.NotEqualDeep:
                forget(); break;

            case TokenCode.In:
                forget();
                EXPRESSION left = EXPRESSION.parse(null, context);
                token = get();
                if (token.code == TokenCode.DotDot)
                {
                    forget();
                    EXPRESSION right = EXPRESSION.parse(null, context);
                    RANGE_TYPE range = new RANGE_TYPE(left, right);
                    range.setSpan(left.span, right.span);
                    Span          start = result.span;
                    IN_EXPRESSION r     = new IN_EXPRESSION(token, result, range);
                    result.parent = r;
                    result        = r;
                    result.setSpan(start, range.span);
                    goto Out;
                }
                else
                {
                    // Something's wrong: right part of the in-expression
                    // should always be a range-type
                    goto Out;
                }

            default:
                goto Out;
            }
            EXPRESSION second = ADDITIVE.parse(null, context);
            Span       start2 = result.span;

            result = new RELATIONAL(token, result, second);
            result.setSpan(start2, second.span);
Out:
            return(result);
        }
Esempio n. 2
0
        public static new EXPRESSION parse(Token first, iSCOPE context)
        {
            EXPRESSION result = RELATIONAL.parse(first, context);

            if (result == null)
            {
                return(null);
            }
            Span begin = result.span;

            while (true)
            {
                Token token = get();
                switch (token.code)
                {
                case TokenCode.Ampersand:
                case TokenCode.AmpAmp:
                case TokenCode.Vertical:
                case TokenCode.VertVert:
                    forget(); break;

                case TokenCode.Identifier:
                    Category cat = new Category(CategoryCode.operatorr);
                    if (token.image == "or")
                    {
                        forget(); Token second = get();
                        if (second.code == TokenCode.Else)
                        {
                            forget();
                            token = new Token(new Span(token, second), TokenCode.Vertical, "or else", cat);
                        }
                        else
                        {
                            token = new Token(token.span, TokenCode.VertVert, "or", cat);
                        }
                        break;
                    }
                    else if (token.image == "and")
                    {
                        forget(); Token second = get();
                        if (second.code == TokenCode.Then)
                        {
                            forget();
                            token = new Token(new Span(token, second), TokenCode.Ampersand, "and then", cat);
                        }
                        else
                        {
                            token = new Token(token.span, TokenCode.AmpAmp, "and", cat);
                        }
                        break;
                    }
                    else
                    {
                        goto Out;
                    }

                default:
                    goto Out;
                }
                EXPRESSION right = RELATIONAL.parse(null, context);
                result = new LOGICAL(token, result, right);
                result.setSpan(begin, right.span);
            }
Out:
            return(result);
        }