public List<Token> process() { while (this.pos < this.max) { char ch = this.charsToProcess[this.pos]; if (isAlphabetic(ch)) { lexIdentifier(); if (isTwoCharToken(TokenKind.INC)) { pushPairToken(TokenKind.INC); pushCharToken(TokenKind.PLUS); lexIdentifier(); break; case '-': if (isTwoCharToken(TokenKind.DEC)) { pushPairToken(TokenKind.DEC); pushCharToken(TokenKind.MINUS); pushCharToken(TokenKind.COLON); break; case '.': pushCharToken(TokenKind.DOT); break; case ',': pushCharToken(TokenKind.COMMA); break; case '*': pushCharToken(TokenKind.STAR); break;
while (isHexadecimalDigit(this.charsToProcess[this.pos])); if (isChar('L', 'l')) { pushHexIntToken(subarray(start + 2, this.pos), true, start, this.pos); this.pos++; pushHexIntToken(subarray(start + 2, this.pos), false, start, this.pos); while (isDigit(this.charsToProcess[this.pos])); while (isDigit(this.charsToProcess[this.pos])); if (this.pos == dotpos + 1) { pushIntToken(subarray(start, this.pos), false, start, this.pos); return; if (isChar('L', 'l')) { if (isReal) { // 3.4L - not allowed raiseParseException(start, SpelMessage.REAL_CANNOT_BE_LONG); pushIntToken(subarray(start, endOfNumber), true, start, endOfNumber); this.pos++; else if (isExponentChar(this.charsToProcess[this.pos])) { isReal = true; // if it wasn't before, it is now this.pos++; char possibleSign = this.charsToProcess[this.pos]; if (isSign(possibleSign)) { this.pos++;
private void lexQuotedStringLiteral() { int start = this.pos; boolean terminated = false; while (!terminated) { this.pos++; char ch = this.charsToProcess[this.pos]; if (ch == '\'') { // may not be the end if the char after is also a ' if (this.charsToProcess[this.pos + 1] == '\'') { this.pos++; // skip over that too, and continue } else { terminated = true; } } if (isExhausted()) { raiseParseException(start, SpelMessage.NON_TERMINATING_QUOTED_STRING); } } this.pos++; this.tokens.add(new Token(TokenKind.LITERAL_STRING, subarray(start, this.pos), start, this.pos)); }
private boolean isIdentifier(char ch) { return isAlphabetic(ch) || isDigit(ch) || ch == '_' || ch == '$'; }
private void lexIdentifier() { int start = this.pos; do { this.pos++; } while (isIdentifier(this.charsToProcess[this.pos])); char[] subarray = subarray(start, this.pos); // Check if this is the alternative (textual) representation of an operator (see // alternativeOperatorNames) if ((this.pos - start) == 2 || (this.pos - start) == 3) { String asString = new String(subarray).toUpperCase(); int idx = Arrays.binarySearch(ALTERNATIVE_OPERATOR_NAMES, asString); if (idx >= 0) { pushOneCharOrTwoCharToken(TokenKind.valueOf(asString), start, subarray); return; } } this.tokens.add(new Token(TokenKind.IDENTIFIER, subarray, start, this.pos)); }
@Override protected SpelExpression doParseExpression(String expressionString, @Nullable ParserContext context) throws ParseException { try { this.expressionString = expressionString; Tokenizer tokenizer = new Tokenizer(expressionString); this.tokenStream = tokenizer.process(); this.tokenStreamLength = this.tokenStream.size(); this.tokenStreamPointer = 0; this.constructedNodes.clear(); SpelNodeImpl ast = eatExpression(); Assert.state(ast != null, "No node"); Token t = peekToken(); if (t != null) { throw new SpelParseException(t.startPos, SpelMessage.MORE_INPUT, toString(nextToken())); } Assert.isTrue(this.constructedNodes.isEmpty(), "At least one node expected"); return new SpelExpression(expressionString, ast, this.configuration); } catch (InternalParseException ex) { throw ex.getCause(); } }
private void lexIdentifier() { int start = this.pos; do { this.pos++; } while (isIdentifier(this.charsToProcess[this.pos])); char[] subarray = subarray(start, this.pos); // Check if this is the alternative (textual) representation of an operator (see // alternativeOperatorNames) if ((this.pos - start) == 2 || (this.pos - start) == 3) { String asString = new String(subarray).toUpperCase(); int idx = Arrays.binarySearch(ALTERNATIVE_OPERATOR_NAMES, asString); if (idx >= 0) { pushOneCharOrTwoCharToken(TokenKind.valueOf(asString), start, subarray); return; } } this.tokens.add(new Token(TokenKind.IDENTIFIER, subarray, start, this.pos)); }
private boolean isIdentifier(char ch) { return isAlphabetic(ch) || isDigit(ch) || ch == '_' || ch == '$'; }
@Override protected SpelExpression doParseExpression(String expressionString, @Nullable ParserContext context) throws ParseException { try { this.expressionString = expressionString; Tokenizer tokenizer = new Tokenizer(expressionString); this.tokenStream = tokenizer.process(); this.tokenStreamLength = this.tokenStream.size(); this.tokenStreamPointer = 0; this.constructedNodes.clear(); SpelNodeImpl ast = eatExpression(); Assert.state(ast != null, "No node"); Token t = peekToken(); if (t != null) { throw new SpelParseException(t.startPos, SpelMessage.MORE_INPUT, toString(nextToken())); } Assert.isTrue(this.constructedNodes.isEmpty(), "At least one node expected"); return new SpelExpression(expressionString, ast, this.configuration); } catch (InternalParseException ex) { throw ex.getCause(); } }
while (isHexadecimalDigit(this.charsToProcess[this.pos])); if (isChar('L', 'l')) { pushHexIntToken(subarray(start + 2, this.pos), true, start, this.pos); this.pos++; pushHexIntToken(subarray(start + 2, this.pos), false, start, this.pos); while (isDigit(this.charsToProcess[this.pos])); while (isDigit(this.charsToProcess[this.pos])); if (this.pos == dotpos + 1) { pushIntToken(subarray(start, this.pos), false, start, this.pos); return; if (isChar('L', 'l')) { if (isReal) { // 3.4L - not allowed raiseParseException(start, SpelMessage.REAL_CANNOT_BE_LONG); pushIntToken(subarray(start, endOfNumber), true, start, endOfNumber); this.pos++; else if (isExponentChar(this.charsToProcess[this.pos])) { isReal = true; // if it wasn't before, it is now this.pos++; char possibleSign = this.charsToProcess[this.pos]; if (isSign(possibleSign)) { this.pos++;
public List<Token> process() { while (this.pos < this.max) { char ch = this.charsToProcess[this.pos]; if (isAlphabetic(ch)) { lexIdentifier(); if (isTwoCharToken(TokenKind.INC)) { pushPairToken(TokenKind.INC); pushCharToken(TokenKind.PLUS); lexIdentifier(); break; case '-': if (isTwoCharToken(TokenKind.DEC)) { pushPairToken(TokenKind.DEC); pushCharToken(TokenKind.MINUS); pushCharToken(TokenKind.COLON); break; case '.': pushCharToken(TokenKind.DOT); break; case ',': pushCharToken(TokenKind.COMMA); break; case '*': pushCharToken(TokenKind.STAR); break;
private void lexDoubleQuotedStringLiteral() { int start = this.pos; boolean terminated = false; while (!terminated) { this.pos++; char ch = this.charsToProcess[this.pos]; if (ch == '"') { // may not be the end if the char after is also a " if (this.charsToProcess[this.pos + 1] == '"') { this.pos++; // skip over that too, and continue } else { terminated = true; } } if (isExhausted()) { raiseParseException(start, SpelMessage.NON_TERMINATING_DOUBLE_QUOTED_STRING); } } this.pos++; this.tokens.add(new Token(TokenKind.LITERAL_STRING, subarray(start, this.pos), start, this.pos)); }
private void lexIdentifier() { int start = this.pos; do { this.pos++; } while (isIdentifier(this.charsToProcess[this.pos])); char[] subarray = subarray(start, this.pos); // Check if this is the alternative (textual) representation of an operator (see // alternativeOperatorNames) if ((this.pos - start) == 2 || (this.pos - start) == 3) { String asString = new String(subarray).toUpperCase(); int idx = Arrays.binarySearch(ALTERNATIVE_OPERATOR_NAMES, asString); if (idx >= 0) { pushOneCharOrTwoCharToken(TokenKind.valueOf(asString), start, subarray); return; } } this.tokens.add(new Token(TokenKind.IDENTIFIER, subarray, start, this.pos)); }
private boolean isIdentifier(char ch) { return isAlphabetic(ch) || isDigit(ch) || ch == '_' || ch == '$'; }
@Override protected SpelExpression doParseExpression(String expressionString, @Nullable ParserContext context) throws ParseException { try { this.expressionString = expressionString; Tokenizer tokenizer = new Tokenizer(expressionString); this.tokenStream = tokenizer.process(); this.tokenStreamLength = this.tokenStream.size(); this.tokenStreamPointer = 0; this.constructedNodes.clear(); SpelNodeImpl ast = eatExpression(); Assert.state(ast != null, "No node"); Token t = peekToken(); if (t != null) { throw new SpelParseException(t.startPos, SpelMessage.MORE_INPUT, toString(nextToken())); } Assert.isTrue(this.constructedNodes.isEmpty(), "At least one node expected"); return new SpelExpression(expressionString, ast, this.configuration); } catch (InternalParseException ex) { throw ex.getCause(); } }
while (isHexadecimalDigit(this.charsToProcess[this.pos])); if (isChar('L', 'l')) { pushHexIntToken(subarray(start + 2, this.pos), true, start, this.pos); this.pos++; pushHexIntToken(subarray(start + 2, this.pos), false, start, this.pos); while (isDigit(this.charsToProcess[this.pos])); while (isDigit(this.charsToProcess[this.pos])); if (this.pos == dotpos + 1) { pushIntToken(subarray(start, this.pos), false, start, this.pos); return; if (isChar('L', 'l')) { if (isReal) { // 3.4L - not allowed raiseParseException(start, SpelMessage.REAL_CANNOT_BE_LONG); pushIntToken(subarray(start, endOfNumber), true, start, endOfNumber); this.pos++; else if (isExponentChar(this.charsToProcess[this.pos])) { isReal = true; // if it wasn't before, it is now this.pos++; char possibleSign = this.charsToProcess[this.pos]; if (isSign(possibleSign)) { this.pos++;
public List<Token> process() { while (this.pos < this.max) { char ch = this.charsToProcess[this.pos]; if (isAlphabetic(ch)) { lexIdentifier(); if (isTwoCharToken(TokenKind.INC)) { pushPairToken(TokenKind.INC); pushCharToken(TokenKind.PLUS); lexIdentifier(); break; case '-': if (isTwoCharToken(TokenKind.DEC)) { pushPairToken(TokenKind.DEC); pushCharToken(TokenKind.MINUS); pushCharToken(TokenKind.COLON); break; case '.': pushCharToken(TokenKind.DOT); break; case ',': pushCharToken(TokenKind.COMMA); break; case '*': pushCharToken(TokenKind.STAR); break;
private void lexDoubleQuotedStringLiteral() { int start = this.pos; boolean terminated = false; while (!terminated) { this.pos++; char ch = this.charsToProcess[this.pos]; if (ch == '"') { // may not be the end if the char after is also a " if (this.charsToProcess[this.pos + 1] == '"') { this.pos++; // skip over that too, and continue } else { terminated = true; } } if (isExhausted()) { raiseParseException(start, SpelMessage.NON_TERMINATING_DOUBLE_QUOTED_STRING); } } this.pos++; this.tokens.add(new Token(TokenKind.LITERAL_STRING, subarray(start, this.pos), start, this.pos)); }
private void lexQuotedStringLiteral() { int start = this.pos; boolean terminated = false; while (!terminated) { this.pos++; char ch = this.charsToProcess[this.pos]; if (ch == '\'') { // may not be the end if the char after is also a ' if (this.charsToProcess[this.pos + 1] == '\'') { this.pos++; // skip over that too, and continue } else { terminated = true; } } if (isExhausted()) { raiseParseException(start, SpelMessage.NON_TERMINATING_QUOTED_STRING); } } this.pos++; this.tokens.add(new Token(TokenKind.LITERAL_STRING, subarray(start, this.pos), start, this.pos)); }
private void lexQuotedStringLiteral() { int start = this.pos; boolean terminated = false; while (!terminated) { this.pos++; char ch = this.charsToProcess[this.pos]; if (ch == '\'') { // may not be the end if the char after is also a ' if (this.charsToProcess[this.pos + 1] == '\'') { this.pos++; // skip over that too, and continue } else { terminated = true; } } if (isExhausted()) { raiseParseException(start, SpelMessage.NON_TERMINATING_QUOTED_STRING); } } this.pos++; this.tokens.add(new Token(TokenKind.LITERAL_STRING, subarray(start, this.pos), start, this.pos)); }