Beispiel #1
0
        protected virtual LiteralNode ParseNegativeNumericLiteralNode(ILiteralNodeParent parent, NegativeSignToken negativeSign)
        {
            // PARSE: <number> ::= integer | float | scaledDecimal
            Token token = this.GetNextTokenxx(Preference.NegativeSign);

            if (token is SmallIntegerToken)
            {
                return(new SmallIntegerLiteralNode(parent, (SmallIntegerToken)token, negativeSign));
            }
            if (token is LargeIntegerToken)
            {
                return(new LargeIntegerLiteralNode(parent, (LargeIntegerToken)token, negativeSign));
            }
            if (token is FloatEToken)
            {
                return(new FloatELiteralNode(parent, (FloatEToken)token, negativeSign));
            }
            if (token is FloatDToken)
            {
                return(new FloatDLiteralNode(parent, (FloatDToken)token, negativeSign));
            }
            if (token is ScaledDecimalToken)
            {
                return(new ScaledDecimalLiteralNode(parent, (ScaledDecimalToken)token, negativeSign));
            }

            // We don't know what that is.... the negative sign token thrown away and lost :-/
            this.ReportParserError(parent, SemanticErrors.UnrecognizedLiteral, token);
            this.ResidueToken = token;
            return(null);
        }
        protected override LiteralNode ParseLiteral(ILiteralNodeParent parent, Token token)
        {
            if ((parent is ArrayLiteralNode) && Parser.IsOpeningParenthesis(token))
            {
                // Stupid VSE allows declarations of arrays like: #( 1 2 ( 3 4 ) 5 6),
                // which is identical to: #( 1 2 #( 3 4 ) 5 6).
                // Only the inner (child) arrays may omit the hash prefix.
                // Here we emulate this and create a 'fake' hash token.
                // The fake hash token gets the same source positions and the parenthesis token.
                SpecialCharacterToken hash = new SpecialCharacterToken(SemanticConstants.LiteralArrayPrefix);
                hash.SetTokenValues(token.StartPosition, token.StopPosition, null);
                this.ResidueToken = token;
                return(this.ParseArrayLiteral(parent, hash));
            }

            if (!Parser.IsLiteralArrayPrefix(token))
            {
                return(base.ParseLiteral(parent, token));
            }

            Token token2 = this.GetNextTokenxx(Preference.Default);

            if (VseCompatibleParser.IsOpeningByteArrayBracket(token2))
            {
                return(this.ParseByteArrayLiteral(parent, (SpecialCharacterToken)token, (SpecialCharacterToken)token2));
            }

            this.ResidueToken = token2;
            return(base.ParseLiteral(parent, token));
        }
Beispiel #3
0
        /// <summary>
        /// Create and initialize a new literal node.
        /// </summary>
        /// <param name="parent">Parent node that defines the literal node.</param>
        protected LiteralNode(ILiteralNodeParent parent)
        {
#if DEBUG
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }
#endif
            this.Parent = parent;
        }
        /// <summary>
        /// Create and initialize a new identifier literal node.
        /// </summary>
        /// <param name="parent">Parent node that defines this literal node.</param>
        /// <param name="token">Token defining the value of the literal node.</param>
        protected internal IdentifierLiteralNode(ILiteralNodeParent parent, ILiteralArrayIdentifierToken token)
            : base(parent)
        {
#if DEBUG
            if (token == null)
            {
                throw new ArgumentNullException("token");
            }
#endif
            this.Token = token;
        }
Beispiel #5
0
        /// <summary>
        /// Create and initialize a new single value literal node.
        /// </summary>
        /// <param name="parent">The parent node that defines the literal node.</param>
        /// <param name="token">Token defining the literal node.</param>
        protected SingleValueLiteralNode(ILiteralNodeParent parent, TToken token)
            : base(parent)
        {
#if DEBUG
            if (token == null)
            {
                throw new ArgumentNullException("token");
            }
#endif
            this.Token = token;
        }
 /// <summary>
 /// Create and initialize a new literal array node.
 /// </summary>
 /// <param name="parent">Parent node that defines this literal node.</param>
 /// <param name="arrayToken">Hash token that defines the start of array literals.</param>
 /// <param name="leftParenthesis">Opening left parenthesis of the literal array.</param>
 protected internal ByteArrayLiteralNode(ILiteralNodeParent parent, SpecialCharacterToken arrayToken,
     SpecialCharacterToken leftBracket)
     : base(parent)
 {
     #if DEBUG
     if (!Parser.IsLiteralArrayPrefix(arrayToken))
         throw new ArgumentException("arrayToken");
     if (!VseCompatibleParser.IsOpeningByteArrayBracket(leftBracket))
         throw new ArgumentException("leftBracket");
     #endif
     this.ArrayToken = arrayToken;
     this.LeftBracket = leftBracket;
     this.Elements = new List<SmallIntegerLiteralNode>();
 }
 /// <summary>
 /// Create and initialize a new literal array node.
 /// </summary>
 /// <param name="parent">Parent node that defines this literal node.</param>
 /// <param name="arrayToken">Hash token that defines the start of array literals.</param>
 /// <param name="leftParenthesis">Opening left parenthesis of the literal array.</param>
 protected internal ArrayLiteralNode(ILiteralNodeParent parent, SpecialCharacterToken arrayToken,
     SpecialCharacterToken leftParenthesis)
     : base(parent)
 {
     #if DEBUG
     if (!Parser.IsLiteralArrayPrefix(arrayToken))
         throw new ArgumentException("arrayToken");
     if (!Parser.IsOpeningParenthesis(leftParenthesis))
         throw new ArgumentException("leftParenthesis");
     #endif
     this.ArrayToken = arrayToken;
     this.LeftParenthesis = leftParenthesis;
     this.Elements = new List<LiteralNode>();
 }
        /// <summary>
        /// Create and initialize a new literal array node.
        /// </summary>
        /// <param name="parent">Parent node that defines this literal node.</param>
        /// <param name="arrayToken">Hash token that defines the start of array literals.</param>
        /// <param name="leftParenthesis">Opening left parenthesis of the literal array.</param>
        protected internal ArrayLiteralNode(ILiteralNodeParent parent, SpecialCharacterToken arrayToken,
                                            SpecialCharacterToken leftParenthesis)
            : base(parent)
        {
#if DEBUG
            if (!Parser.IsLiteralArrayPrefix(arrayToken))
            {
                throw new ArgumentException("arrayToken");
            }
            if (!Parser.IsOpeningParenthesis(leftParenthesis))
            {
                throw new ArgumentException("leftParenthesis");
            }
#endif
            this.ArrayToken      = arrayToken;
            this.LeftParenthesis = leftParenthesis;
            this.Elements        = new List <LiteralNode>();
        }
        /// <summary>
        /// Create and initialize a new literal array node.
        /// </summary>
        /// <param name="parent">Parent node that defines this literal node.</param>
        /// <param name="arrayToken">Hash token that defines the start of array literals.</param>
        /// <param name="leftParenthesis">Opening left parenthesis of the literal array.</param>
        protected internal ByteArrayLiteralNode(ILiteralNodeParent parent, SpecialCharacterToken arrayToken,
                                                SpecialCharacterToken leftBracket)
            : base(parent)
        {
#if DEBUG
            if (!Parser.IsLiteralArrayPrefix(arrayToken))
            {
                throw new ArgumentException("arrayToken");
            }
            if (!VseCompatibleParser.IsOpeningByteArrayBracket(leftBracket))
            {
                throw new ArgumentException("leftBracket");
            }
#endif
            this.ArrayToken  = arrayToken;
            this.LeftBracket = leftBracket;
            this.Elements    = new List <SmallIntegerLiteralNode>();
        }
 /// <summary>
 /// Create and initialize a new identifier literal node.
 /// </summary>
 /// <param name="parent">Parent node that defines this literal node.</param>
 /// <param name="token">Token defining the value of the literal node.</param>
 protected internal IdentifierLiteralNode(ILiteralNodeParent parent, ILiteralArrayIdentifierToken token)
     : base(parent)
 {
     #if DEBUG
     if (token == null)
         throw new ArgumentNullException("token");
     #endif
     this.Token = token;
 }
Beispiel #11
0
        protected virtual ArrayLiteralNode ParseArrayLiteral(ILiteralNodeParent parent, SpecialCharacterToken arrayToken)
        {
            // PARSE: <array literal> ::= '#(' <array element>* ')'
            // <array element> ::= <literal> | identifier

            Token token = this.GetNextTokenxx(Preference.Default);

            if (!Parser.IsOpeningParenthesis(token))
            {
                this.ReportParserError(parent, SemanticErrors.MissingLiteralArrayOpeningParenthesis, token);
                // The hash token is thrown away and lost :-/   ... only the current token is passed on.
                this.ResidueToken = token;
                return(null);
            }
            List <LiteralNode> elements = new List <LiteralNode>();
            ArrayLiteralNode   result   = new ArrayLiteralNode(parent, arrayToken, (SpecialCharacterToken)token);

            // Process tokens inside the array ...
            while (true)
            {
                // ... get next token in the array ...
                token = this.GetNextTokenxx(Preference.NegativeSign | Preference.UnquotedSelector);

                // Is this closing parenthesis?
                if (Parser.IsClosingParenthesis(token))
                {
                    // Closing parenthesis ... done with the array, return litral array node.
                    result.SetContents(elements, (SpecialCharacterToken)token);
                    this.ResidueToken = null;
                    return(result);
                }

                if (token is EofToken)
                {
                    // Unfinished source code ... return
                    result.SetContents(elements, null);
                    this.ReportParserError(parent, SemanticErrors.MissingLiteralArrayClosingParenthesis, token);
                    this.ResidueToken = token;
                    return(result);
                }

                // PARSE: <array element> ::= <literal> | identifier
                if (token is ILiteralArrayIdentifierToken)
                {
                    // identifier ... special case only inside arrays.
                    elements.Add(new IdentifierLiteralNode(result, (ILiteralArrayIdentifierToken)token));
                }
                else
                {
                    // ... it's not identifier, so it must be an literal
                    LiteralNode element = this.ParseLiteral(result, token);
                    if (element == null)
                    {
                        // Report error in source code ... here, it must be a literal
                        this.ReportParserError(result, SemanticErrors.UnrecognizedLiteral, token);
                        result.SetContents(elements, null);
                        return(result);
                    }
                    else
                    {
                        // ... add the child element to the array elements.
                        elements.Add(element);
                    }
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// Parse a literal node as described in X3J20 "3.4.6 Literals".
        /// </summary>
        /// <remarks>
        /// If the given token is not a legal token for a literal node,
        /// it is simply returned in the residueToken output parameter,
        /// and the function returns null.
        /// </remarks>
        /// <param name="parent">Parent node that defines the literal node.</param>
        /// <param name="token">First token of the literal node.</param>
        /// <returns>A literal node, or null in case of non-literal token.</returns>
        protected virtual LiteralNode ParseLiteral(ILiteralNodeParent parent, Token token)
        {
            // PARSE: <literal> ::= <number literal> | <string literal> | <character literal> |
            //      <symbol literal> | <selector literal> | <array literal>

            // <string literal> ::= quotedString
            if (token is StringToken)   // 'example'
            {
                return(new StringLiteralNode(parent, (StringToken)token));
            }
            // <symbol literal> ::= hashedString
            if (token is HashedStringToken) // #'example'
            {
                return(new SymbolLiteralNode(parent, (HashedStringToken)token));
            }
            // <character literal> ::= quotedCharacter
            if (token is CharacterToken)    // $e
            {
                return(new CharacterLiteralNode(parent, (CharacterToken)token));
            }
            // <selector literal> ::= quotedSelector
            if (token is QuotedSelectorToken)   // #example ..or.. #example: ..or.. #example:example: ..or.. #+
            {
                return(new SelectorLiteralNode(parent, (QuotedSelectorToken)token));
            }

            // <number literal> ::= ['-'] <number>
            if (token is NegativeSignToken)
            {
                return(this.ParseNegativeNumericLiteralNode(parent, (NegativeSignToken)token));
            }
            // <number> ::= integer | float | scaledDecimal
            if (token is SmallIntegerToken)
            {
                return(new SmallIntegerLiteralNode(parent, (SmallIntegerToken)token, null));
            }
            if (token is LargeIntegerToken)
            {
                return(new LargeIntegerLiteralNode(parent, (LargeIntegerToken)token, null));
            }
            if (token is FloatEToken)
            {
                return(new FloatELiteralNode(parent, (FloatEToken)token, null));
            }
            if (token is FloatDToken)
            {
                return(new FloatDLiteralNode(parent, (FloatDToken)token, null));
            }
            if (token is ScaledDecimalToken)
            {
                return(new ScaledDecimalLiteralNode(parent, (ScaledDecimalToken)token, null));
            }

            // <array literal> ::= '#(' <array element>* ')'
            // <array element> ::= <literal> | identifier
            if (Parser.IsLiteralArrayPrefix(token))
            {
                return(this.ParseArrayLiteral(parent, (SpecialCharacterToken)token));
            }

            this.ResidueToken = token;
            return(null);
        }
        protected ByteArrayLiteralNode ParseByteArrayLiteral(ILiteralNodeParent parent, SpecialCharacterToken arrayToken, SpecialCharacterToken leftBracket)
        {
            // PARSE: <array literal> ::= '#[' <number literal>* ']'

            List <SmallIntegerLiteralNode> elements = new List <SmallIntegerLiteralNode>();
            ByteArrayLiteralNode           result   = new ByteArrayLiteralNode(parent, arrayToken, leftBracket);

            // Process tokens inside the array ...
            while (true)
            {
                // ... get next token in the array ...
                Token token = this.GetNextTokenxx(Preference.NegativeSign);

                // Is this closing parenthesis?
                if (VseCompatibleParser.IsClosingByteArrayBracket(token))
                {
                    // Closing parenthesis ... done with the array, return litral array node.
                    result.SetContents(elements, (SpecialCharacterToken)token);
                    this.ResidueToken = null;
                    return(result);
                }

                if (token is EofToken)
                {
                    // Unfinished source code ... return
                    result.SetContents(elements, null);
                    this.ReportParserError(parent, "Missing literal byte array closing bracket.", token);
                    this.ResidueToken = token;
                    return(result);
                }

                // PARSE: <numeric liteal>
                if (token is SmallIntegerToken)
                {
                    elements.Add(new SmallIntegerLiteralNode(result, (SmallIntegerToken)token, null));
                }
                else if (token is NegativeSignToken)
                {
                    NegativeSignToken negativeSign = (NegativeSignToken)token;
                    token = this.GetNextTokenxx(Preference.NegativeSign);
                    if (token is SmallIntegerToken)
                    {
                        elements.Add(new SmallIntegerLiteralNode(result, (SmallIntegerToken)token, negativeSign));
                    }
                    else
                    {
                        this.ReportParserError(parent, "Unrecognized literal.", token);
                        this.ResidueToken = token;
                        result.SetContents(elements, null);
                        return(result);
                    }
                }
                else
                {
                    this.ReportParserError(parent, "Unrecognized literal.", token);
                    this.ResidueToken = token;
                    result.SetContents(elements, null);
                    return(result);
                }
            }
        }
Beispiel #14
0
        protected virtual LiteralNode ParseNegativeNumericLiteralNode(ILiteralNodeParent parent, NegativeSignToken negativeSign)
        {
            // PARSE: <number> ::= integer | float | scaledDecimal
            Token token = this.GetNextTokenxx(Preference.NegativeSign);

            if (token is SmallIntegerToken)
                return new SmallIntegerLiteralNode(parent, (SmallIntegerToken)token, negativeSign);
            if (token is LargeIntegerToken)
                return new LargeIntegerLiteralNode(parent, (LargeIntegerToken)token, negativeSign);
            if (token is FloatEToken)
                return new FloatELiteralNode(parent, (FloatEToken)token, negativeSign);
            if (token is FloatDToken)
                return new FloatDLiteralNode(parent, (FloatDToken)token, negativeSign);
            if (token is ScaledDecimalToken)
                return new ScaledDecimalLiteralNode(parent, (ScaledDecimalToken)token, negativeSign);

            // We don't know what that is.... the negative sign token thrown away and lost :-/
            this.ReportParserError(parent, SemanticErrors.UnrecognizedLiteral, token);
            this.ResidueToken = token;
            return null;
        }
 /// <summary>
 /// Create and initialize a new float literal node.
 /// </summary>
 /// <param name="parent">Parent node that defines this literal node.</param>
 /// <param name="token">Token defining the value of the literal node.</param>
 /// <param name="negativeSignToken">Optional negative sign token indicating a negative numeric value.</param>
 protected internal FloatDLiteralNode(ILiteralNodeParent parent, FloatDToken token, NegativeSignToken negativeSignToken)
     : base(parent, token, negativeSignToken)
 {
 }
 /// <summary>
 /// Create and initialize a new large integer literal node.
 /// </summary>
 /// <param name="parent">Parent node that defines this literal node.</param>
 /// <param name="token">Token defining the value of the literal node.</param>
 /// <param name="negativeSignToken">Optional negative sign token indicating a negative numeric value.</param>
 protected internal LargeIntegerLiteralNode(ILiteralNodeParent parent, LargeIntegerToken token, NegativeSignToken negativeSignToken)
     : base(parent, token, negativeSignToken)
 {
 }
Beispiel #17
0
        protected virtual ArrayLiteralNode ParseArrayLiteral(ILiteralNodeParent parent, SpecialCharacterToken arrayToken)
        {
            // PARSE: <array literal> ::= '#(' <array element>* ')'
            // <array element> ::= <literal> | identifier

            Token token = this.GetNextTokenxx(Preference.Default);
            if (!Parser.IsOpeningParenthesis(token))
            {
                this.ReportParserError(parent, SemanticErrors.MissingLiteralArrayOpeningParenthesis, token);
                // The hash token is thrown away and lost :-/   ... only the current token is passed on.
                this.ResidueToken = token;
                return null;
            }
            List<LiteralNode> elements = new List<LiteralNode>();
            ArrayLiteralNode result = new ArrayLiteralNode(parent, arrayToken, (SpecialCharacterToken)token);

            // Process tokens inside the array ...
            while (true)
            {
                // ... get next token in the array ...
                token = this.GetNextTokenxx(Preference.NegativeSign | Preference.UnquotedSelector);

                // Is this closing parenthesis?
                if (Parser.IsClosingParenthesis(token))
                {
                    // Closing parenthesis ... done with the array, return litral array node.
                    result.SetContents(elements, (SpecialCharacterToken)token);
                    this.ResidueToken = null;
                    return result;
                }

                if (token is EofToken)
                {
                    // Unfinished source code ... return
                    result.SetContents(elements, null);
                    this.ReportParserError(parent, SemanticErrors.MissingLiteralArrayClosingParenthesis, token);
                    this.ResidueToken = token;
                    return result;
                }

                // PARSE: <array element> ::= <literal> | identifier
                if (token is ILiteralArrayIdentifierToken)
                {
                    // identifier ... special case only inside arrays.
                    elements.Add(new IdentifierLiteralNode(result, (ILiteralArrayIdentifierToken)token));
                }
                else
                {
                    // ... it's not identifier, so it must be an literal
                    LiteralNode element = this.ParseLiteral(result, token);
                    if (element == null)
                    {
                        // Report error in souce code ... here, it must be a literal
                        this.ReportParserError(result, SemanticErrors.UnrecognizedLiteral, token);
                        result.SetContents(elements, null);
                        return result;
                    }
                    else
                    {
                        // ... add the child element to the array elements.
                        elements.Add(element);
                    }
                }
            }
        }
 /// <summary>
 /// Create and initialize a new string literal node.
 /// </summary>
 /// <param name="parent">Parent node that defines this literal node.</param>
 /// <param name="token">Token defining the value of the literal node.</param>
 protected internal StringLiteralNode(ILiteralNodeParent parent, StringToken token)
     : base(parent, token)
 {
 }
Beispiel #19
0
 /// <summary>
 /// Create and initialize a new symbol literal node.
 /// </summary>
 /// <param name="parent">Parent node that defines this literal node.</param>
 /// <param name="token">Token defining the value of the literal node.</param>
 protected internal SymbolLiteralNode(ILiteralNodeParent parent, HashedStringToken token)
     : base(parent, token)
 {
 }
 /// <summary>
 /// Create and initialize a new numeric literal node.
 /// </summary>
 /// <param name="parent">Parent node that defines this literal node.</param>
 /// <param name="token">Token defining the value of the literal node.</param>
 /// <param name="negativeSignToken">Optional negative sign token indicating a negative numeric value.</param>
 protected NumericLiteralNode(ILiteralNodeParent parent, TToken token, NegativeSignToken negativeSignToken)
     : base(parent, token)
 {
     this.NegativeSignToken = negativeSignToken; // OK with null.
 }
Beispiel #21
0
 /// <summary>
 /// Create and initialize a new character literal node.
 /// </summary>
 /// <param name="parent">Parent node that defines this literal node.</param>
 /// <param name="token">Token defining the value of the literal node.</param>
 protected internal CharacterLiteralNode(ILiteralNodeParent parent, CharacterToken token)
     : base(parent, token)
 {
 }
Beispiel #22
0
        /// <summary>
        /// Parse a literal node as described in X3J20 "3.4.6 Literals".
        /// </summary>
        /// <remarks>
        /// If the given token is not a legal token for a literal node,
        /// it is simply returned in the residueToken output parameter, 
        /// and the function returns null.
        /// </remarks>
        /// <param name="parent">Parent node that defines the literal node.</param>
        /// <param name="token">First token of the literal node.</param>
        /// <returns>A literal node, or null in case of non-literal token.</returns>
        protected virtual LiteralNode ParseLiteral(ILiteralNodeParent parent, Token token)
        {
            // PARSE: <literal> ::= <number literal> | <string literal> | <character literal> |
            //      <symbol literal> | <selector literal> | <array literal>

            // <string literal> ::= quotedString
            if (token is StringToken)   // 'example'
                return new StringLiteralNode(parent, (StringToken)token);
            // <symbol literal> ::= hashedString
            if (token is HashedStringToken) // #'example'
                return new SymbolLiteralNode(parent, (HashedStringToken)token);
            // <character literal> ::= quotedCharacter
            if (token is CharacterToken)    // $e
                return new CharacterLiteralNode(parent, (CharacterToken)token);
            // <selector literal> ::= quotedSelector
            if (token is QuotedSelectorToken)   // #example ..or.. #example: ..or.. #example:example: ..or.. #+
                return new SelectorLiteralNode(parent, (QuotedSelectorToken)token);

            // <number literal> ::= ['-'] <number>
            if (token is NegativeSignToken)
                return this.ParseNegativeNumericLiteralNode(parent, (NegativeSignToken)token);
            // <number> ::= integer | float | scaledDecimal
            if (token is SmallIntegerToken)
                return new SmallIntegerLiteralNode(parent, (SmallIntegerToken)token, null);
            if (token is LargeIntegerToken)
                return new LargeIntegerLiteralNode(parent, (LargeIntegerToken)token, null);
            if (token is FloatEToken)
                return new FloatELiteralNode(parent, (FloatEToken)token, null);
            if (token is FloatDToken)
                return new FloatDLiteralNode(parent, (FloatDToken)token, null);
            if (token is ScaledDecimalToken)
                return new ScaledDecimalLiteralNode(parent, (ScaledDecimalToken)token, null);

            // <array literal> ::= '#(' <array element>* ')'
            // <array element> ::= <literal> | identifier
            if (Parser.IsLiteralArrayPrefix(token))
                return this.ParseArrayLiteral(parent, (SpecialCharacterToken)token);

            this.ResidueToken = token;
            return null;
        }
 /// <summary>
 /// Create and initialize a new float literal node.
 /// </summary>
 /// <param name="parent">Parent node that defines this literal node.</param>
 /// <param name="token">Token defining the value of the literal node.</param>
 /// <param name="negativeSignToken">Optional negative sign token indicating a negative numeric value.</param>
 protected FloatLiteralNode(ILiteralNodeParent parent, TToken token, NegativeSignToken negativeSignToken)
     : base(parent, token, negativeSignToken)
 {
 }
        protected override LiteralNode ParseLiteral(ILiteralNodeParent parent, Token token)
        {
            if ((parent is ArrayLiteralNode) && Parser.IsOpeningParenthesis(token))
            {
                // Stupid VSE allows declarations of arrays like: #( 1 2 ( 3 4 ) 5 6),
                // which is identical to: #( 1 2 #( 3 4 ) 5 6).
                // Only the inner (child) arrays may omit the hash prefix.
                // Here we emulate this and create a 'fake' hash token.
                // The fake hash token gets the same source positions and the parenthesis token.
                SpecialCharacterToken hash = new SpecialCharacterToken(SemanticConstants.LiteralArrayPrefix);
                hash.SetTokenValues(token.StartPosition, token.StopPosition, null);
                this.ResidueToken = token;
                return this.ParseArrayLiteral(parent, hash);
            }

            if (!Parser.IsLiteralArrayPrefix(token))
                return base.ParseLiteral(parent, token);

            Token token2 = this.GetNextTokenxx(Preference.Default);
            if (VseCompatibleParser.IsOpeningByteArrayBracket(token2))
                return this.ParseByteArrayLiteral(parent, (SpecialCharacterToken) token, (SpecialCharacterToken)token2);

            this.ResidueToken = token2;
            return base.ParseLiteral(parent, token);
        }
 /// <summary>
 /// Create and initialize a new scaled decimal literal node.
 /// </summary>
 /// <param name="parent">Parent node that defines this literal node.</param>
 /// <param name="token">Token defining the value of the literal node.</param>
 /// <param name="negativeSignToken">Optional negative sign token indicating a negative numeric value.</param>
 protected internal ScaledDecimalLiteralNode(ILiteralNodeParent parent, ScaledDecimalToken token, NegativeSignToken negativeSignToken)
     : base(parent, token, negativeSignToken)
 {
 }
        protected ByteArrayLiteralNode ParseByteArrayLiteral(ILiteralNodeParent parent, SpecialCharacterToken arrayToken, SpecialCharacterToken leftBracket)
        {
            // PARSE: <array literal> ::= '#[' <number literal>* ']'

            List<SmallIntegerLiteralNode> elements = new List<SmallIntegerLiteralNode>();
            ByteArrayLiteralNode result = new ByteArrayLiteralNode(parent, arrayToken, leftBracket);

            // Process tokens inside the array ...
            while (true)
            {
                // ... get next token in the array ...
                Token token = this.GetNextTokenxx(Preference.NegativeSign);

                // Is this closing parenthesis?
                if (VseCompatibleParser.IsClosingByteArrayBracket(token))
                {
                    // Closing parenthesis ... done with the array, return litral array node.
                    result.SetContents(elements, (SpecialCharacterToken)token);
                    this.ResidueToken = null;
                    return result;
                }

                if (token is EofToken)
                {
                    // Unfinished source code ... return
                    result.SetContents(elements, null);
                    this.ReportParserError(parent, "Missing literal byte array closing bracket.", token);
                    this.ResidueToken = token;
                    return result;
                }

                // PARSE: <numeric liteal>
                if (token is SmallIntegerToken)
                {
                    elements.Add(new SmallIntegerLiteralNode(result, (SmallIntegerToken)token, null));
                }
                else if (token is NegativeSignToken)
                {
                    NegativeSignToken negativeSign = (NegativeSignToken)token;
                    token = this.GetNextTokenxx(Preference.NegativeSign);
                    if (token is SmallIntegerToken)
                    {
                        elements.Add(new SmallIntegerLiteralNode(result, (SmallIntegerToken)token, negativeSign));
                    }
                    else
                    {
                        this.ReportParserError(parent, "Unrecognized literal.", token);
                        this.ResidueToken = token;
                        result.SetContents(elements, null);
                        return result;
                    }
                }
                else
                {
                    this.ReportParserError(parent, "Unrecognized literal.", token);
                    this.ResidueToken = token;
                    result.SetContents(elements, null);
                    return result;
                }
            }
        }
 /// <summary>
 /// Create and initialize a new small integer literal node.
 /// </summary>
 /// <param name="parent">Parent node that defines this literal node.</param>
 /// <param name="token">Token defining the value of the literal node.</param>
 /// <param name="negativeSignToken">Optional negative sign token indicating a negative numeric value.</param>
 public SmallIntegerLiteralNode(ILiteralNodeParent parent, SmallIntegerToken token, NegativeSignToken negativeSignToken)
     : base(parent, token, negativeSignToken)
 {
 }
 /// <summary>
 /// Create and initialize a new selector literal node.
 /// </summary>
 /// <param name="parent">Parent node that defines this literal node.</param>
 /// <param name="token">Token defining the value of the literal node.</param>
 protected internal SelectorLiteralNode(ILiteralNodeParent parent, QuotedSelectorToken token)
     : base(parent, token)
 {
 }