//解析if(判断语句)
        private void ParseIf()
        {
            CodeIf ret = new CodeIf();

            ret.If = ParseCondition(true, Executable_Block.If);
            List <TempCondition> ElseIf = new List <TempCondition>();

            for (; ;)
            {
                Token token = ReadToken();
                if (token.Type == TokenType.ElseIf)
                {
                    ElseIf.Add(ParseCondition(true, Executable_Block.If));
                }
                else if (token.Type == TokenType.Else)
                {
                    if (PeekToken().Type == TokenType.If)
                    {
                        ReadToken();
                        ElseIf.Add(ParseCondition(true, Executable_Block.If));
                    }
                    else
                    {
                        UndoToken();
                        break;
                    }
                }
                else
                {
                    UndoToken();
                    break;
                }
            }
            if (PeekToken().Type == TokenType.Else)
            {
                ReadToken();
                ret.Else = ParseCondition(false, Executable_Block.If);
            }
            ret.Init(ElseIf);
            m_scriptExecutable.AddScriptInstruction(new ScriptInstruction(Opcode.CALL_IF, ret));
        }
Beispiel #2
0
        private void ParseIf()
        {
            Token  token;
            CodeIf @if = new CodeIf {
                If = this.ParseCondition(true, Executable_Block.If)
            };
            List <TempCondition> elseIf = new List <TempCondition>();

Label_001A:
            token = this.ReadToken();
            if (token.Type == Scorpio.Compiler.TokenType.ElseIf)
            {
                elseIf.Add(this.ParseCondition(true, Executable_Block.If));
                goto Label_001A;
            }
            if (token.Type == Scorpio.Compiler.TokenType.Else)
            {
                if (this.PeekToken().Type == Scorpio.Compiler.TokenType.If)
                {
                    this.ReadToken();
                    elseIf.Add(this.ParseCondition(true, Executable_Block.If));
                    goto Label_001A;
                }
                this.UndoToken();
            }
            else
            {
                this.UndoToken();
            }
            if (this.PeekToken().Type == Scorpio.Compiler.TokenType.Else)
            {
                this.ReadToken();
                @if.Else = this.ParseCondition(false, Executable_Block.If);
            }
            @if.Init(elseIf);
            this.m_scriptExecutable.AddScriptInstruction(new ScriptInstruction(Opcode.CALL_IF, @if));
        }