protected void skipWhitespace(LookaheadReader reader) { while (reader.current().isWhitepace()) { reader.consume(); } }
private boolean skipWhitespace(LookaheadReader reader) { boolean skipped = false; while (reader.current().isWhitepace()) { reader.consume(); skipped = true; } return skipped; }
@Override protected boolean isIdentifierChar(Char current) { if (super.isIdentifierChar(current)) { return true; } // CSS selectors can contain "-", "." or "#" as long as it is not the last character of the token return (current.is('-') || current.is('.') || current.is('#')) && !input.next().isWhitepace(); }
protected Tuple<String, String> parseFieldAndValue(LookaheadReader reader) { String field = defaultField; boolean couldBeFieldNameSoFar = true; StringBuilder valueBuilder = new StringBuilder(); while (!reader.current().isEndOfInput() && !reader.current().isWhitepace() && !reader.current().is(')')) { if (reader.current().is(':') && valueBuilder.length() > 0 && couldBeFieldNameSoFar) { field = valueBuilder.toString(); valueBuilder = new StringBuilder(); // Ignore : reader.consume(); couldBeFieldNameSoFar = false; } else { if (couldBeFieldNameSoFar) { couldBeFieldNameSoFar = reader.current().is('-', '_') || reader.current().isLetter() || reader.current().isDigit(); } valueBuilder.append(reader.consume().getValue()); } } return Tuple.create(field, valueBuilder.toString()); }
private boolean continueValue(boolean inQuotes) { if (reader.current().isEndOfInput()) { return false; } if (inQuotes) { return !reader.current().is('"'); } return !reader.current().is(')') && !reader.current().isWhitepace(); }
/** * Determines if the given Char is a symbol character. * <p> * By default these are all non-control characters, which don't match any other class (letter, digit, whitepsace) * * @param ch the character to check * @return <tt>true</tt> if the given character is a valid symbol character, <tt>false</tt> otherwise */ @SuppressWarnings("squid:S1067") protected boolean isSymbolCharacter(Char ch) { if (ch.isEndOfInput() || ch.isDigit() || ch.isLetter() || ch.isWhitepace()) { return false; } char c = ch.getValue(); if (Character.isISOControl(c)) { return false; } return !(isAtBracket(true) || isAtStartOfBlockComment(false) || isAtStartOfLineComment(false) || isAtStartOfNumber() || isAtStartOfIdentifier() || stringDelimiters.containsKey(ch.getValue())); }
/** * Determines if the given Char is a symbol character. * <p> * By default these are all non-control characters, which don't match any other class (letter, digit, whitepsace) * * @param ch the character to check * @return <tt>true</tt> if the given character is a valid symbol character, <tt>false</tt> otherwise */ @SuppressWarnings("squid:S1067") protected boolean isSymbolCharacter(Char ch) { if (ch.isEndOfInput() || ch.isDigit() || ch.isLetter() || ch.isWhitepace()) { return false; } char c = ch.getValue(); if (Character.isISOControl(c)) { return false; } return !(isAtBracket(true) || isAtStartOfBlockComment(false) || isAtStartOfLineComment(false) || isAtStartOfNumber() || isAtStartOfIdentifier() || stringDelimiters.containsKey(ch.getValue())); }
private boolean continueToken(boolean inQuotes) { if (reader.current().isEndOfInput()) { return false; } if (inQuotes) { return !reader.current().is('"'); } return !reader.current().is(')', ':') && !reader.current().isWhitepace() && !isAtOperator(); }
@Override protected Token fetch() { while (input.current().isWhitepace()) { input.consume();
@Override protected Token fetch() { while (input.current().isWhitepace()) { input.consume();