コード例 #1
0
ファイル: Expression.cs プロジェクト: Tubbz-alt/SLang-6
        public static new EXPRESSION parse(Token first, iSCOPE context)
        {
            EXPRESSION result = UNARY.parse(first, context);

            while (true)
            {
                Token token = get();
                switch (token.code)
                {
                case TokenCode.Multiply:
                case TokenCode.Divide:
                case TokenCode.Remainder:
                    forget(); break;

                default:
                    goto Out;
                }
                EXPRESSION second = UNARY.parse(null, context);
                Span       begin  = result.span;
                result = new MULTIPLICATIVE(token, result, second);
                result.setSpan(begin, second.span);
            }
Out:
            return(result);
        }
コード例 #2
0
ファイル: Expression.cs プロジェクト: Tubbz-alt/SLang-6
        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);
        }
コード例 #3
0
ファイル: Expression.cs プロジェクト: Tubbz-alt/SLang-6
        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);
        }