private void skip_whitespace() throws IOException { Token t; while ( (t = next()) == Token.TK_S) { // skip } push(t); }
private void skip_whitespace_and_cdocdc() throws IOException { Token t; while (true) { t = next(); if (! (t == Token.TK_S || t == Token.TK_CDO || t == Token.TK_CDC)) { break; } } push(t); }
private Token la() throws IOException { Token result = next(); push(result); return result; }
private int unary_operator() throws IOException { //System.out.println("unary_operator()"); Token t = next(); if (! (t == Token.TK_MINUS || t == Token.TK_PLUS)) { push(t); throw new CSSParseException( t, new Token[] { Token.TK_MINUS, Token.TK_PLUS}, getCurrentLine()); } if (t == Token.TK_MINUS) { return -1; } else { /* t == Token.TK_PLUS */ return 1; } }
private void prio() throws IOException { //System.out.println("prio()"); Token t = next(); if (t == Token.TK_IMPORTANT_SYM) { skip_whitespace(); } else { push(t); throw new CSSParseException(t, Token.TK_IMPORTANT_SYM, getCurrentLine()); } }
private String pseudo_page() throws IOException { //System.out.println("pseudo_page()"); String result = null; Token t = next(); if (t == Token.TK_COLON) { t = next(); if (t == Token.TK_IDENT) { result = getTokenValue(t); if (! (result.equals("first") || result.equals("left") || result.equals("right"))) { throw new CSSParseException("Pseudo page must be one of first, left, or right", getCurrentLine()); } } else { push(t); throw new CSSParseException(t, Token.TK_IDENT, getCurrentLine()); } } else { push(t); throw new CSSParseException(t, Token.TK_COLON, getCurrentLine()); } return result; } // operator
private PropertyValue hexcolor() throws IOException { //System.out.println("hexcolor()"); PropertyValue result = null; Token t = next(); if (t == Token.TK_HASH) { String s = getTokenValue(t); if ((s.length() != 3 && s.length() != 6) || ! isHexString(s)) { push(t); throw new CSSParseException('#' + s + " is not a valid color definition", getCurrentLine()); } FSRGBColor color = null; if (s.length() == 3) { color = new FSRGBColor( convertToInteger(s.charAt(0), s.charAt(0)), convertToInteger(s.charAt(1), s.charAt(1)), convertToInteger(s.charAt(2), s.charAt(2))); } else { /* s.length == 6 */ color = new FSRGBColor( convertToInteger(s.charAt(0), s.charAt(1)), convertToInteger(s.charAt(2), s.charAt(3)), convertToInteger(s.charAt(4), s.charAt(5))); } result = new PropertyValue(color); skip_whitespace(); } else { push(t); throw new CSSParseException(t, Token.TK_HASH, getCurrentLine()); } return result; }
private Token combinator() throws IOException { //System.out.println("combinator()"); Token t = next(); if (t == Token.TK_PLUS || t == Token.TK_GREATER) { skip_whitespace(); } else if (t != Token.TK_S) { push(t); throw new CSSParseException( t, new Token[] { Token.TK_PLUS, Token.TK_GREATER, Token.TK_S }, getCurrentLine()); } return t; }
t = next(); } else { push(t); throw new CSSParseException(t, Token.TK_IDENT, getCurrentLine()); } catch (CSSParseException e) { e.setLine(getCurrentLine()); push(t); throw e; push(t); throw new CSSParseException(f + " is not a valid function in this context", getCurrentLine()); push(t); throw new CSSParseException(t, Token.TK_RPAREN, getCurrentLine());
private void class_selector(Selector selector) throws IOException { //System.out.println("class_selector()"); Token t = next(); if (t == Token.TK_PERIOD) { t = next(); if (t == Token.TK_IDENT) { selector.addClassCondition(getTokenValue(t, true)); } else { push(t); throw new CSSParseException(t, Token.TK_IDENT, getCurrentLine()); } } else { push(t); throw new CSSParseException(t, Token.TK_PERIOD, getCurrentLine()); } }
if (braces == 0) { if (stopBeforeBlockClose) { push(t); break LOOP;
private String medium() throws IOException { //System.out.println("medium()"); String result = null; Token t = next(); if (t == Token.TK_IDENT) { result = getTokenValue(t); skip_whitespace(); } else { push(t); throw new CSSParseException(t, Token.TK_IDENT, getCurrentLine()); } return result; }
private String property() throws IOException { //System.out.println("property()"); Token t = next(); String result; if (t == Token.TK_IDENT) { result = getTokenValue(t); skip_whitespace(); } else { push(t); throw new CSSParseException( t, Token.TK_IDENT, getCurrentLine()); } return result; }
private void pseudo(Selector selector) throws IOException { //System.out.println("pseudo()"); Token t = next(); if (t == Token.TK_COLON) { t = next(); switch (t.getType()) { case Token.COLON: t = next(); addPseudoElement(t, selector); break; case Token.IDENT: addPseudoClassOrElement(t, selector); break; case Token.FUNCTION: addPseudoClassOrElementFunction(t, selector); break; default: push(t); throw new CSSParseException(t, new Token[] { Token.TK_IDENT, Token.TK_FUNCTION }, getCurrentLine()); } } else { push(t); throw new CSSParseException(t, Token.TK_COLON, getCurrentLine()); } }
push(t); throw new CSSParseException(t, Token.TK_COLON, getCurrentLine());