@Override protected boolean handleStringEscape(char separator, char escapeChar, Token stringToken) { // All escaped characters will be kept in original form... stringToken.addToContent(input.consume()); return true; }
private boolean skipWhitespace(LookaheadReader reader) { boolean skipped = false; while (reader.current().isWhitepace()) { reader.consume(); skipped = true; } return skipped; }
protected void skipWhitespace(LookaheadReader reader) { while (reader.current().isWhitepace()) { reader.consume(); } }
private FieldValue readValue() { StringBuilder token = new StringBuilder(); boolean inQuotes = reader.current().is('"'); if (inQuotes) { reader.consume(); } while (continueValue(inQuotes)) { if (reader.current().is('\\')) { reader.consume(); } token.append(reader.consume()); } if (inQuotes && reader.current().is('"')) { reader.consume(); } return new FieldValue(token.toString(), inQuotes); }
private FieldValue readToken() { StringBuilder token = new StringBuilder(); boolean inQuotes = reader.current().is('"'); if (inQuotes) { reader.consume(); } while (continueToken(inQuotes)) { if (reader.current().is('\\')) { reader.consume(); } token.append(reader.consume()); } if (inQuotes && reader.current().is('"')) { reader.consume(); } return new FieldValue(token.toString(), inQuotes); }
@SuppressWarnings("unchecked") private C parseTag() { StringBuilder tag = new StringBuilder(); tag.append(reader.consume()); tag.append(reader.consume()); while (!reader.current().isEndOfInput() && !(reader.current().is('|') && reader.next().is('|'))) { tag.append(reader.consume()); } tag.append(reader.consume()); tag.append(reader.consume()); QueryTag queryTag = QueryTag.parse(tag.toString()); if (queryTag.getType() != null && Strings.isFilled(queryTag.getValue())) { QueryTagHandler<C> handler = ctx.getPart(queryTag.getType(), QueryTagHandler.class); if (handler != null) { return handler.generateConstraint(factory, descriptor, queryTag.getValue()); } } return null; }
private FieldValue parseValue() { skipWhitespace(reader); if (reader.current().is('"')) { reader.consume(); StringBuilder result = new StringBuilder(); while (!reader.current().isEndOfInput() && !reader.current().is('"')) { if (reader.current().is('\\')) { reader.consume(); } result.append(reader.consume()); } reader.consume(); return new FieldValue(result.toString(), true); } else { return new FieldValue(readValue().getValue(), false); } }
/** * Reads and returns a special id. * * @return the parsed special id as Token */ protected Token fetchSpecialId() { Token result = Token.create(Token.TokenType.SPECIAL_ID, input.current()); result.addToTrigger(input.consume()); while (isIdentifierChar(input.current())) { result.addToContent(input.consume()); } return handleKeywords(result); }
/** * Reads and returns a special id. * * @return the parsed special id as Token */ protected Token fetchSpecialId() { Token result = Token.create(Token.TokenType.SPECIAL_ID, input.current()); result.addToTrigger(input.consume()); while (isIdentifierChar(input.current())) { result.addToContent(input.consume()); } return handleKeywords(result); }
/** * Checks if we're looking at an end of block comment */ protected void skipBlockComment() { while (!input.current().isEndOfInput()) { if (isAtEndOfBlockComment()) { return; } input.consume(); } problemCollector.add(ParseError.error(input.current(), "Premature end of block comment")); }
/** * Checks if we're looking at an end of block comment */ protected void skipBlockComment() { while (!input.current().isEndOfInput()) { if (isAtEndOfBlockComment()) { return; } input.consume(); } problemCollector.add(ParseError.error(input.current(), "Premature end of block comment")); }
@Override protected Token fetchNumber() { Token token = super.fetchNumber(); // If a number is immediately followed by % or a text like "px" - this belongs to the numeric token. if (input.current().is('%')) { token.addToContent(input.consume()); return token; } while (input.current().isLetter()) { token.addToContent(input.consume()); } return token; }
/** * Read everything upon (and including) the next line break */ protected void skipToEndOfLine() { while (!input.current().isEndOfInput() && !input.current().isNewLine()) { input.consume(); } }
/** * Read everything upon (and including) the next line break */ protected void skipToEndOfLine() { while (!input.current().isEndOfInput() && !input.current().isNewLine()) { input.consume(); } }
private C parseOR() { List<C> constraints = new ArrayList<>(); while (!reader.current().isEndOfInput() && !reader.current().is(')')) { C inner = parseAND(); if (inner != null) { constraints.add(inner); } if (!isAtOR(reader)) { break; } else { reader.consume(2); } } if (constraints.isEmpty()) { return null; } else { return factory.or(constraints); } }
/** * Reads and returns a symbol. * <p> * A symbol are one or two characters, which don't match any other token type. In most cases, this will be * operators like + or *. * * @return the parsed symbol as Token */ @SuppressWarnings("squid:S1067") protected Token fetchSymbol() { Token result = Token.create(Token.TokenType.SYMBOL, input.current()); result.addToTrigger(input.consume()); if (result.isSymbol("*") && input.current().is('*') || result.isSymbol("&") && input.current().is('&') || result.isSymbol("|") && input.current().is('|') || result.isSymbol() && input.current().is('=')) { result.addToTrigger(input.consume()); } return result; }