private void ParseSwtich() { Token token; CodeSwitch switch2 = new CodeSwitch(); this.ReadLeftParenthesis(); switch2.Condition = this.GetObject(); this.ReadRightParenthesis(); this.ReadLeftBrace(); List <TempCase> cases = new List <TempCase>(); Label_002A: token = this.ReadToken(); if (token.Type == Scorpio.Compiler.TokenType.Case) { List <CodeObject> allow = new List <CodeObject>(); this.ParseCase(allow); cases.Add(new TempCase(this.m_script, allow, this.ParseStatementBlock(Executable_Block.Switch, false, Scorpio.Compiler.TokenType.Break))); goto Label_002A; } if (token.Type == Scorpio.Compiler.TokenType.Default) { this.ReadColon(); switch2.Default = new TempCase(this.m_script, null, this.ParseStatementBlock(Executable_Block.Switch, false, Scorpio.Compiler.TokenType.Break)); goto Label_002A; } if (token.Type == Scorpio.Compiler.TokenType.SemiColon) { goto Label_002A; } this.UndoToken(); this.ReadRightBrace(); switch2.SetCases(cases); this.m_scriptExecutable.AddScriptInstruction(new ScriptInstruction(Opcode.CALL_SWITCH, switch2)); }
//解析swtich语句 private void ParseSwtich() { CodeSwitch ret = new CodeSwitch(); ReadLeftParenthesis(); ret.Condition = GetObject(); ReadRightParenthesis(); ReadLeftBrace(); List <TempCase> Cases = new List <TempCase>(); for (; ;) { Token token = ReadToken(); if (token.Type == TokenType.Case) { List <CodeObject> allow = new List <CodeObject>(); ParseCase(allow); Cases.Add(new TempCase(m_script, allow, ParseStatementBlock(Executable_Block.Switch, false, TokenType.Break))); } else if (token.Type == TokenType.Default) { ReadColon(); ret.Default = new TempCase(m_script, null, ParseStatementBlock(Executable_Block.Switch, false, TokenType.Break)); } else if (token.Type != TokenType.SemiColon) { UndoToken(); break; } } ReadRightBrace(); ret.SetCases(Cases); m_scriptExecutable.AddScriptInstruction(new ScriptInstruction(Opcode.CALL_SWITCH, ret)); }