Ejemplo n.º 1
0
        private CodeArray GetArray()
        {
            this.ReadLeftBracket();
            Token     token = this.PeekToken();
            CodeArray array = new CodeArray();

            while (token.Type != Scorpio.Compiler.TokenType.RightBracket)
            {
                if (this.PeekToken().Type != Scorpio.Compiler.TokenType.RightBracket)
                {
                    array._Elements.Add(this.GetObject());
                    token = this.PeekToken();
                    if (token.Type == Scorpio.Compiler.TokenType.Comma)
                    {
                        this.ReadComma();
                        continue;
                    }
                    if (token.Type != Scorpio.Compiler.TokenType.RightBracket)
                    {
                        throw new ParserException("Comma ',' or right parenthesis ']' expected in array object.", token);
                    }
                }
                break;
            }
            this.ReadRightBracket();
            array.Init();
            return(array);
        }
Ejemplo n.º 2
0
        //返回数组
        private CodeArray GetArray()
        {
            ReadLeftBracket();
            Token     token = PeekToken();
            CodeArray ret   = new CodeArray();

            while (token.Type != TokenType.RightBracket)
            {
                if (PeekToken().Type == TokenType.RightBracket)
                {
                    break;
                }
                ret._Elements.Add(GetObject());
                token = PeekToken();
                if (token.Type == TokenType.Comma)
                {
                    ReadComma();
                }
                else if (token.Type == TokenType.RightBracket)
                {
                    break;
                }
                else
                {
                    throw new ParserException("Comma ',' or right parenthesis ']' expected in array object.", token);
                }
            }
            ReadRightBracket();
            ret.Init();
            return(ret);
        }