コード例 #1
0
        private IExpression Consume_Expression()
        {
            IExpression result = Consume_Term();

            while (currentToken.Type == TokenType.PLUS || currentToken.Type == TokenType.MINUS)
            {
                Token token = currentToken;
                Consume(TokenType.PLUS, TokenType.MINUS);

                result = ExpressionFactory.CreateBinary(result, Consume_Term(), token.Type, currentToken);
            }

            return(result);
        }
コード例 #2
0
        private IExpression Consume_DialogueMember()
        {
            Token token = currentToken;

            if (currentToken.Type == TokenType.L_PAREN)
            {
                IExpression condition = Consume_Expression();

                token = currentToken;
                Consume(TokenType.CONDITION);

                IExpression member = Consume_DialogueMember();

                return(ExpressionFactory.CreateBinary(condition, member, token.Type, token));
            }

            IDialogueMember dialogueMember = null;

            Consume(TokenType.MEMBERDELIMITER_LEFT);

            switch (currentToken.Type)
            {
            case TokenType.ACTOR:
                Consume(TokenType.ACTOR);
                Consume(TokenType.ASSIGN);
                dialogueMember = ExpressionFactory.CreateDialogueActorExpression(Consume_Factor(), token);
                break;

            case TokenType.MOOD:
                Consume(TokenType.MOOD);
                Consume(TokenType.ASSIGN);
                dialogueMember = ExpressionFactory.CreateDialogueMoodExpression(Consume_Factor(), token);
                break;

            case TokenType.CHOICE_MEMBER:
                dialogueMember = Consume_ChoiceExpression();
                break;
            }

            Consume(TokenType.MEMBERDELIMITER_RIGHT);

            return(dialogueMember);
        }
コード例 #3
0
        private IExpression Consume_Term()
        {
            IExpression term = Consume_Factor();

            Token token = currentToken;

            while (IsOperator())
            {
                switch (token.Type)
                {
                case TokenType.MUL:
                    Consume(TokenType.MUL);
                    break;

                case TokenType.DIV:
                    Consume(TokenType.DIV);
                    break;

                case TokenType.EQUALS:
                    Consume(TokenType.EQUALS);
                    break;

                case TokenType.SMALLER:
                    Consume(TokenType.SMALLER);
                    break;

                case TokenType.GREATER:
                    Consume(TokenType.GREATER);
                    break;

                case TokenType.SMALLEREQUALS:
                    Consume(TokenType.SMALLEREQUALS);
                    break;

                case TokenType.GREATEREQUALS:
                    Consume(TokenType.GREATEREQUALS);
                    break;
                }
                term = ExpressionFactory.CreateBinary(term, Consume_Factor(), token.Type, token);
            }
            return(term);
        }