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 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>(); }