Ejemplo n.º 1
0
        public static new EXPRESSION parse(Token first, iSCOPE context)
        {
            EXPRESSION result;
            Token      token = (first != null) ? first : get();

            switch (token.code)
            {
            case TokenCode.Plus:
            case TokenCode.Minus:
            case TokenCode.Tilde:
                forget();
                EXPRESSION second = UNARY.parse(null, context);
                result = new UNARY(token, second);
                result.setSpan(token.span, second.span);
                break;

            case TokenCode.New:
                forget();
                UNIT_REF unitRef = UNIT_REF.parse(null, false, context);
                result = new NEW(unitRef);
                result.setSpan(token.span, unitRef.span);
                break;

            default:
                result = POWER.parse(token, context);
                break;
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static new EXPRESSION parse(Token token, iSCOPE context)
        {
            EXPRESSION result = SECONDARY.parse(token, context);

            while (true)
            {
                token = get();
                if (token.code == TokenCode.Power)
                {
                    forget();
                    EXPRESSION right = UNARY.parse(null, context);
                    Span       begin = result.span;
                    result = new POWER(result, right);
                    result.setSpan(begin, right.span);
                }
                else
                {
                    goto Out;
                }
            }
Out:
            return(result);
        }