Пример #1
0
  /**
   * If the character producer has not been exhausted, ensures that there is a token on pending on
   * pending.
   */
  private void produce() throws ParseException {
    if (!pending.isEmpty()) {
      return;
    }
    if (!splitter.hasNext()) {
      return;
    }

    Token<CssTokenType> t = splitter.next();
    pending.add(t);
    if (t.type == CssTokenType.PUNCTUATION && splitter.hasNext()) {
      if ("!".equals(t.text)) { // Join !important
        // IMPORTANT_SYM        "!"({w}|{comment})*{I}{M}{P}{O}{R}{T}{A}{N}{T}
        Token<CssTokenType> t2 = splitter.next();
        while (t2 != null && (t2.type == CssTokenType.SPACE || t2.type == CssTokenType.COMMENT)) {
          pending.add(t2);
          t2 = splitter.hasNext() ? splitter.next() : null;
        }
        // The !important is significant regardless of case and whether or not a
        // letter is hex escaped.
        if (null != t2) {
          pending.add(t2);
          if (t2.type == CssTokenType.IDENT
              && Strings.eqIgnoreCase("important", decodeCssIdentifier(t2.text))) {
            reduce(CssTokenType.DIRECTIVE);
          }
        }
      } else if ("-".equals(t.text)) { // Join '-'{nmstart}{nmchar}*
        Token<CssTokenType> t2 = splitter.next();
        if (null != t2) {
          pending.add(t2);
          if (t2.type == CssTokenType.IDENT) {
            reduce(CssTokenType.IDENT);
          }
        }
      }
    }
  }
Пример #2
0
 /**
  * Changes the substitution policy for this lexer.
  *
  * @see #areSubstitutionsAllowed()
  */
 public void allowSubstitutions(boolean allow) {
   splitter.allowSubstitutions(allow);
 }
Пример #3
0
 /**
  * True iff ${...} style substitutions should be allowed as described at {@link
  * CssTokenType#SUBSTITUTION}
  *
  * @see #allowSubstitutions(boolean)
  */
 public boolean areSubstitutionsAllowed() {
   return splitter.areSubstitutionsAllowed();
 }
Пример #4
0
 public boolean hasNext() throws ParseException {
   return !pending.isEmpty() || splitter.hasNext();
 }