Example #1
0
        private ScriptExecutable ParseStatementBlock(Executable_Block block, bool readLeftBrace, Scorpio.Compiler.TokenType finished)
        {
            this.BeginExecutable(block);
            if (readLeftBrace && (this.PeekToken().Type != Scorpio.Compiler.TokenType.LeftBrace))
            {
                this.ParseStatement();
                if (this.PeekToken().Type == Scorpio.Compiler.TokenType.SemiColon)
                {
                    this.ReadToken();
                }
            }
            else
            {
                if (readLeftBrace)
                {
                    this.ReadLeftBrace();
                }
                while (this.HasMoreTokens())
                {
                    if (this.ReadToken().Type == finished)
                    {
                        break;
                    }
                    this.UndoToken();
                    this.ParseStatement();
                }
            }
            ScriptExecutable scriptExecutable = this.m_scriptExecutable;

            scriptExecutable.EndScriptInstruction();
            this.EndExecutable();
            return(scriptExecutable);
        }
        //解析区域代码内容( {} 之间的内容)
        private ScriptExecutable ParseStatementBlock(Executable_Block block, bool readLeftBrace, TokenType finished)
        {
            BeginExecutable(block);
            if (readLeftBrace && PeekToken().Type != TokenType.LeftBrace)
            {
                ParseStatement();
                if (PeekToken().Type == TokenType.SemiColon)
                {
                    ReadToken();
                }
            }
            else
            {
                if (readLeftBrace)
                {
                    ReadLeftBrace();
                }
                TokenType tokenType;
                while (HasMoreTokens())
                {
                    tokenType = ReadToken().Type;
                    if (tokenType == finished)
                    {
                        break;
                    }
                    UndoToken();
                    ParseStatement();
                }
            }
            ScriptExecutable ret = m_scriptExecutable;

            ret.EndScriptInstruction();
            EndExecutable();
            return(ret);
        }