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