/bundles/plugins-trunk/XML/sidekick/css/parser/CSS3Parser.java
# · Java · 2410 lines · 2249 code · 69 blank · 92 comment · 327 complexity · 8c8ca35dbd5612f39d14638901fadf4b MD5 · raw file
Large files are truncated click here to view the full file
- /* Generated By:JavaCC: Do not edit this line. CSS3Parser.java */
- package sidekick.css.parser;
- import java.io.*;
- import java.net.*;
- import java.text.MessageFormat;
- import java.util.*;
- import java.util.regex.*;
- import sidekick.util.*;
- import org.gjt.sp.jedit.jEdit;
- /**
- * A CSS3 parser
- *
- * @author Philippe Le Hegaret and Sijtsche Smeman
- * @author Dale Anson, major modifications for jEdit Sidekick
- * @version Revision: 1.71 (W3C version)
- */
- public class CSS3Parser implements CSS3ParserConstants {
- private List<ParseError> parseErrors = new ArrayList<ParseError>();
- private List<ParseError> parseWarnings = new ArrayList<ParseError>();
- private boolean proprietaryAsError = true;
- private static char hexdigits[] = { '0' ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'a' ,'b' ,'c' ,'d' ,'e' ,'f' } ;
- /**
- * The line offset is used when the css to be parsed is only part of a file,
- * for example when the css is the contents of a style block contained within
- * an html document.
- * @param lineOffset The line number of the first line of the css.
- * @param columnOffset The column number of the first character of the css.
- */
- public CSS3Parser(Reader in, int lineOffset, int columnOffset){
- this(in);
- jj_input_stream.ReInit(in,lineOffset,columnOffset);
- }
- /**
- * Set the tab size on the input stream. This should be set to the same
- * tab size as used in the buffer being parsed, otherwise, locations will
- * be off.
- */
- public void setTabSize(int size) {
- jj_input_stream.setTabSize(size);
- }
- /**
- * @return the current tab size used by the input stream.
- */
- public int getTabSize() {
- return jj_input_stream.getTabSize(0);
- }
- /**
- * If set to true, then a warning will be generated when proprietary
- * CSS markup is used.
- * @param b If set to true, then a warning will be generated when proprietary
- * CSS markup is used.
- */
- public void setProprietaryAsError(boolean b) {
- proprietaryAsError = b;
- }
- /**
- * Adds a parse exception to the list of parse exceptions. It is intended
- * that a complete file will be parsed and accumulate the exceptions rather
- * than quitting on the first exception.
- * @param pe A parse exception to add to the list.
- */
- private void addException(ParseException pe) {
- Range range = getExceptionLocation( pe );
- parseErrors.add(new ParseError(pe.getMessage(), range));
- //pe.printStackTrace();
- }
- private void addWarning(ParseError pe) {
- parseWarnings.add(pe);
- }
- /**
- * @return The list of parse exceptions found during parsing of a file.
- */
- public List<ParseError> getParseErrors() {
- //System.out.println("getParserErrors, there are " + parseErrors.size() + " errors");
- return parseErrors;
- }
- public List<ParseError> getParseWarnings() {
- return parseWarnings;
- }
- // regex to extract line and colun from a ParseException message
- // ParseException message look like: "Parse error at line 116, column 5. Encountered: }"
- private Pattern pePattern = Pattern.compile( "(.*?)(\u005c\u005cd+)(.*?)(\u005c\u005cd+)(.*?)" );
- /**
- * @return attempts to return a Location indicating the location of a parser
- * exception. If the ParseException contains a Token reference, all is well,
- * otherwise, this method attempts to parse the message string for the
- * exception.
- */
- private Range getExceptionLocation( ParseException pe ) {
- Token t = pe.currentToken;
- if ( t != null ) {
- return new Range( new Location( t.next.beginLine, t.next.beginColumn-1 ), new Location( t.next.endLine, t.next.endColumn ) );
- }
- // ParseException message look like: "Parse error at line 116, column 5. Encountered: }"
- try {
- Matcher m = pePattern.matcher( pe.getMessage() );
- if ( m.matches() ) {
- String ln = m.group( 2 );
- String cn = m.group( 4 );
- int line_number = -1;
- int column_number = 0;
- if ( ln != null )
- line_number = Integer.parseInt( ln );
- if ( cn != null )
- column_number = Integer.parseInt( cn );
- return line_number > -1 ? new Range( new Location( line_number - 1, column_number - 1 ), new Location( line_number - 1, column_number ) ) : null;
- }
- return new Range();
- } catch ( Exception e ) {
- //e.printStackTrace();
- return new Range();
- }
- }
- public void error_skipto(int kind) {
- Token t = null;
- int i = 0;
- do {
- i++;
- if (i > 100) {
- break;
- }
- t = getNextToken();
- } while (t != null && t.kind != kind);
- }
- /**
- * @param t A token to create a location from.
- * @return A location representing the start of the token.
- */
- public Location getStartLocation(Token t) {
- if (t == null)
- return new Location(0, 0);
- return new Location(t.beginLine + 1, t.beginColumn);
- }
- /**
- * @param t A token to create a location from.
- * @return A location representing the end of the token.
- */
- public Location getEndLocation(Token t) {
- if (t == null)
- return new Location(0, 0);
- return new Location(t.endLine + 1, t.endColumn + 1);
- }
- /**
- * Creates a CSSNode from a token using the token image as the node name
- * and the token start and end for node start and end locations.
- */
- public CSSNode createNode(Token t) {
- if (t == null) {
- return new CSSNode();
- }
- CSSNode node = new CSSNode(t.image);
- node.setStartLocation(getStartLocation(t));
- node.setEndLocation(getEndLocation(t));
- return node;
- }
- /**
- * Simple check to verify that all arguments are not null.
- */
- public boolean notNull(Object... args) {
- for (Object o : args) {
- if (o == null) {
- return false;
- }
- }
- return true;
- }
- // these property names are defined in CSS3, but are supported by at most
- // one browser.
- static final String[] invalidProperties = new String[]{
- "alignment-adjust",
- "alignment-baseline",
- "backface-visibility",
- "baseline-shift",
- "bookmark-label",
- "bookmark-level",
- "bookmark-target",
- "border-image-outset",
- "border-image-repeat",
- "border-image-slice",
- "border-image-source",
- "border-image-width",
- "box-decoration-break",
- "box-flex-group",
- "box-lines",
- "color-profile",
- "column-fill",
- "crop",
- "dominant-baseline",
- "drop-initial-after-adjust",
- "drop-initial-after-align",
- "drop-initial-before-adjust",
- "drop-initial-before-align",
- "drop-initial-size",
- "drop-initial-value",
- "fit",
- "fit-position",
- "float-offset",
- "font-stretch",
- "font-size-adjust",
- "grid-columns",
- "grid-rows",
- "hanging-punctuation",
- "hyphenate-after",
- "hyphenate-before",
- "hyphenate-characters",
- "hyphenate-lines",
- "hyphenate-resource",
- "hyphens",
- "icon",
- "image-orientation",
- "image-resolution",
- "inline-box-align",
- "line-stacking",
- "line-stacking-ruby",
- "line-stacking-shift",
- "line-stacking-strategy",
- "mark",
- "mark-after",
- "mark-before",
- "marks",
- "marquee-direction",
- "marquee-play-count",
- "marquee-speed",
- "marquee-style",
- "move-to",
- "nav-down",
- "nav-index",
- "nav-left",
- "nav-right",
- "nav-up",
- "overflow-style",
- "page",
- "page-policy",
- "phonemes",
- "punctuation-trim",
- "rest",
- "rest-after",
- "rest-before",
- "rotation",
- "rotation-point",
- "ruby-align",
- "ruby-overhang",
- "ruby-position",
- "ruby-span",
- "size",
- "string-set",
- "target",
- "target-name",
- "target-new",
- "target-position",
- "text-align-last",
- "text-emphasis",
- "text-height",
- "text-outline",
- "text-wrap",
- "voice-balance",
- "voice-duration",
- "voice-pitch",
- "voice-pitch-range",
- "voice-rate",
- "voice-stress",
- "voice-volume"};
- public boolean isUnsupported(String propertyName) {
- return unsupportedPropertyNames.contains(propertyName);
- }
- public final static HashSet<String> unsupportedPropertyNames;
- static {
- unsupportedPropertyNames = new HashSet<String>();
- for (String name : invalidProperties) {
- unsupportedPropertyNames.add(name);
- }
- }
- // For testing. Usage: java CSS3Parser < inputfile
- public static void main(String[] args) {
- try {
- CSS3Parser parser = new CSS3Parser(System.in);
- parser.styleSheet();
- }
- catch(Exception e) {
- e.printStackTrace();
- }
- }
- //<DEFAULT, IN_COMMENT>
- //TOKEN :
- //{ /* avoid token manager error */
- // < UNKNOWN : ~[] >
- //}
- /*
- * The grammar for CSS2 and CSS3 starts here.
- */
- /**
- * The main entry for the parser. The W3C version called this method "parserUnit".
- * I changed the name so it matches up with the older CSS2 parser.
- *
- * @exception ParseException exception during the parse
- */
- final public CSSNode styleSheet() throws ParseException {
- CSSNode rootNode = new CSSNode("style");
- CSSNode firstNode = null;
- CSSNode childNode = null;
- List<CSSNode> children = null;
- try {
- label_1:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case HTMLSTARTTAG:
- case HTMLENDTAG:
- ;
- break;
- default:
- jj_la1[0] = jj_gen;
- break label_1;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case HTMLSTARTTAG:
- jj_consume_token(HTMLSTARTTAG);
- break;
- case HTMLENDTAG:
- jj_consume_token(HTMLENDTAG);
- break;
- default:
- jj_la1[1] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- addException ( new ParseException (jEdit.getProperty("sidekick.css.parser.CSS3Parser.dont-html")));
- }
- label_2:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case CHARSET_SYM:
- ;
- break;
- default:
- jj_la1[2] = jj_gen;
- break label_2;
- }
- childNode = charset();
- if (childNode != null) {
- rootNode.addChild(childNode);
- if (firstNode == null) {
- firstNode = childNode;
- rootNode.setStartLocation(firstNode.getStartLocation());
- }
- }
- }
- label_3:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- case CDO:
- case CDC:
- ;
- break;
- default:
- jj_la1[3] = jj_gen;
- break label_3;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- jj_consume_token(S);
- break;
- case CDO:
- jj_consume_token(CDO);
- break;
- case CDC:
- jj_consume_token(CDC);
- break;
- default:
- jj_la1[4] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- label_4:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IMPORT_SYM:
- ;
- break;
- default:
- jj_la1[5] = jj_gen;
- break label_4;
- }
- childNode = importDeclaration();
- if (childNode != null) {
- rootNode.addChild(childNode);
- if (firstNode == null) {
- firstNode = childNode;
- rootNode.setStartLocation(firstNode.getStartLocation());
- }
- }
- ignoreStatement();
- }
- label_5:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case NAMESPACE_SYM:
- ;
- break;
- default:
- jj_la1[6] = jj_gen;
- break label_5;
- }
- childNode = namespaceDeclaration();
- if (childNode != null) {
- rootNode.addChild(childNode);
- if (firstNode == null) {
- firstNode = childNode;
- rootNode.setStartLocation(firstNode.getStartLocation());
- }
- }
- ignoreStatement();
- }
- children = afterImportDeclaration();
- if (children != null && children.size() > 0) {
- rootNode.setEndLocation(children.get(children.size() - 1).getEndLocation());
- rootNode.addChildren(children);
- }
- jj_consume_token(0);
- } catch (TokenMgrError err) {
- addException ( new ParseException ("Unrecognized token, " + err.getMessage()));
- }
- {if (true) return rootNode;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode charset() throws ParseException {
- Token start = null;
- Token middle = null;
- Token end = null;
- CSSNode node = null;
- try {
- start = jj_consume_token(CHARSET_SYM);
- label_6:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[7] = jj_gen;
- break label_6;
- }
- jj_consume_token(S);
- }
- middle = jj_consume_token(STRING);
- label_7:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[8] = jj_gen;
- break label_7;
- }
- jj_consume_token(S);
- }
- end = jj_consume_token(SEMICOLON);
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return null;}
- }
- if (notNull(start, middle, end)) {
- String name = start.image + " " + middle.image;
- node = new CSSNode(name);
- node.setStartLocation(getStartLocation(start));
- node.setEndLocation(getEndLocation(end));
- }
- {if (true) return node;}
- throw new Error("Missing return statement in function");
- }
- final public List<CSSNode> afterImportDeclaration() throws ParseException {
- CSSNode node = null;
- List<CSSNode> list = new ArrayList<CSSNode>();
- String skip = null;
- try {
- label_8:
- while (true) {
- ;
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IDENT:
- case HASHIDENT:
- case HASH:
- case LBRACKET:
- case ANY:
- case COLON:
- case LENGTH:
- case EMS:
- case EXS:
- case ANGLE:
- case TIME:
- case FREQ:
- case RESOLUTION:
- case DIMEN:
- case PSEUDOELEMENT_SYM:
- case CLASS:
- case FUNCTIONNOT:
- case 98:
- node = ruleSet();
- if (node != null) list.add(node);
- break;
- case MEDIA_SYM:
- node = media();
- if (node != null) list.add(node);
- break;
- case PAGE_SYM:
- node = page();
- if (node != null) list.add(node);
- break;
- case FONT_FACE_SYM:
- node = fontFace();
- if (node != null) list.add(node);
- break;
- case PREF_SYM:
- node = preference();
- if (node != null) list.add(node);
- break;
- case COLOR_PROFILE:
- node = colorprofile();
- if (node != null) list.add(node);
- break;
- case PHONETIC_ALPHABET_SYM:
- node = phoneticAlphabet();
- if (node != null) list.add(node);
- break;
- default:
- jj_la1[9] = jj_gen;
- skip = skipStatement();
- if (skip == null || skip.length() == 0) {
- {if (true) return list;}
- }
- }
- ignoreStatement();
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return null;}
- }
- {if (true) return list;}
- throw new Error("Missing return statement in function");
- }
- final public void ignoreStatement() throws ParseException {
- label_9:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case CDO:
- case CDC:
- case ATKEYWORD:
- ;
- break;
- default:
- jj_la1[10] = jj_gen;
- break label_9;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case CDO:
- jj_consume_token(CDO);
- break;
- case CDC:
- jj_consume_token(CDC);
- break;
- case ATKEYWORD:
- atRuleDeclaration();
- break;
- default:
- jj_la1[11] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- label_10:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[12] = jj_gen;
- break label_10;
- }
- jj_consume_token(S);
- }
- }
- }
- final public CSSNode namespaceDeclaration() throws ParseException {
- CSSNode node = null;
- Token start = null;
- Token ident = null;
- Token uri = null;
- Token end = null;
- try {
- start = jj_consume_token(NAMESPACE_SYM);
- label_11:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[13] = jj_gen;
- break label_11;
- }
- jj_consume_token(S);
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IDENT:
- ident = jj_consume_token(IDENT);
- label_12:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[14] = jj_gen;
- break label_12;
- }
- jj_consume_token(S);
- }
- break;
- default:
- jj_la1[15] = jj_gen;
- ;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case STRING:
- uri = jj_consume_token(STRING);
- break;
- case URL:
- uri = jj_consume_token(URL);
- break;
- default:
- jj_la1[16] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- label_13:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[17] = jj_gen;
- break label_13;
- }
- jj_consume_token(S);
- }
- end = jj_consume_token(SEMICOLON);
- label_14:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[18] = jj_gen;
- break label_14;
- }
- jj_consume_token(S);
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(SEMICOLON);
- {if (true) return null;}
- }
- if (notNull(start, uri, end)) {
- String name = start.image + " " + (ident != null ? ident.image : "") + uri.image;
- node = new CSSNode(name);
- node.setStartLocation(getStartLocation(start));
- node.setEndLocation(getEndLocation(end));
- }
- {if (true) return node;}
- throw new Error("Missing return statement in function");
- }
- /**
- * The import statement
- *
- * @exception ParseException exception during the parse
- */
- final public CSSNode importDeclaration() throws ParseException {
- Token start = null;
- CSSNode medium = null;
- List<CSSNode> mediumList = new ArrayList<CSSNode>();
- Token uri = null;
- Token end = null;
- CSSNode node = null;
- try {
- start = jj_consume_token(IMPORT_SYM);
- label_15:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[19] = jj_gen;
- break label_15;
- }
- jj_consume_token(S);
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case STRING:
- uri = jj_consume_token(STRING);
- break;
- case URL:
- uri = jj_consume_token(URL);
- break;
- default:
- jj_la1[20] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- label_16:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[21] = jj_gen;
- break label_16;
- }
- jj_consume_token(S);
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IDENT:
- medium = medium();
- if (medium != null) mediumList.add(medium);
- label_17:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case COMMA:
- ;
- break;
- default:
- jj_la1[22] = jj_gen;
- break label_17;
- }
- jj_consume_token(COMMA);
- label_18:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[23] = jj_gen;
- break label_18;
- }
- jj_consume_token(S);
- }
- medium = medium();
- if (medium != null) mediumList.add(medium);
- }
- break;
- default:
- jj_la1[24] = jj_gen;
- ;
- }
- end = jj_consume_token(SEMICOLON);
- label_19:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[25] = jj_gen;
- break label_19;
- }
- jj_consume_token(S);
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(SEMICOLON);
- {if (true) return null;}
- }
- if (notNull(start, end)) {
- StringBuilder sb = new StringBuilder();
- for (CSSNode m : mediumList) {
- sb.append(m).append(',');
- }
- String mediumNames = sb.substring(0, Math.max(0, sb.length() - 1)); // trims the trailing comma
- String name = start.image + (uri != null ? " " + uri.image : "") + (mediumNames.length() > 0 ? " " + mediumNames : "");
- node = new CSSNode(name);
- node.setStartLocation(getStartLocation(start));
- node.setEndLocation(getEndLocation(end));
- }
- {if (true) return node;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode media() throws ParseException {
- Token start = null;
- Token mr = null;
- CSSNode medium = null;
- List<CSSNode> mlist = new ArrayList<CSSNode>();
- CSSNode mdecl = null;
- List<CSSNode> mdeclList = new ArrayList<CSSNode>();
- CSSNode ruleset = null;
- Token end = null;
- try {
- start = jj_consume_token(MEDIA_SYM);
- label_20:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[26] = jj_gen;
- break label_20;
- }
- jj_consume_token(S);
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case MEDIARESTRICTOR:
- mr = jj_consume_token(MEDIARESTRICTOR);
- label_21:
- while (true) {
- jj_consume_token(S);
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[27] = jj_gen;
- break label_21;
- }
- }
- break;
- default:
- jj_la1[28] = jj_gen;
- ;
- }
- // </CSS3>
-
- medium = medium();
- if (medium != null) mlist.add(medium);
- label_22:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case COMMA:
- ;
- break;
- default:
- jj_la1[29] = jj_gen;
- break label_22;
- }
- jj_consume_token(COMMA);
- label_23:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[30] = jj_gen;
- break label_23;
- }
- jj_consume_token(S);
- }
- medium = medium();
- if (medium != null) mlist.add(medium);
- }
- label_24:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case AND:
- ;
- break;
- default:
- jj_la1[31] = jj_gen;
- break label_24;
- }
- jj_consume_token(AND);
- label_25:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[32] = jj_gen;
- break label_25;
- }
- jj_consume_token(S);
- }
- jj_consume_token(LPARAN);
- label_26:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[33] = jj_gen;
- break label_26;
- }
- jj_consume_token(S);
- }
- mdecl = mediadeclaration();
- if(mdecl != null) mdeclList.add(mdecl);
- jj_consume_token(RPARAN);
- label_27:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[34] = jj_gen;
- break label_27;
- }
- jj_consume_token(S);
- }
- }
- jj_consume_token(LBRACE);
- label_28:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[35] = jj_gen;
- break label_28;
- }
- jj_consume_token(S);
- }
- label_29:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IDENT:
- case HASHIDENT:
- case HASH:
- case LBRACKET:
- case ANY:
- case COLON:
- case LENGTH:
- case EMS:
- case EXS:
- case ANGLE:
- case TIME:
- case FREQ:
- case RESOLUTION:
- case DIMEN:
- case PSEUDOELEMENT_SYM:
- case CLASS:
- case FUNCTIONNOT:
- case 98:
- ;
- break;
- default:
- jj_la1[36] = jj_gen;
- break label_29;
- }
- ruleset = ruleSet();
- }
- end = jj_consume_token(RBRACE);
- label_30:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[37] = jj_gen;
- break label_30;
- }
- jj_consume_token(S);
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return null;}
- }
- if (notNull(start, end)) {
- CSSNode node = new CSSNode(start.image);
- if (mr != null) {
- node.addChild(createNode(mr));
- }
- node.addChildren(mlist);
- node.addChildren(mdeclList);
- node.setStartLocation(getStartLocation(start));
- node.setEndLocation(getEndLocation(end));
- {if (true) return node;}
- }
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode medium() throws ParseException {
- Token t = null;
- t = jj_consume_token(IDENT);
- label_31:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[38] = jj_gen;
- break label_31;
- }
- jj_consume_token(S);
- }
- if (notNull(t)) {
- {if (true) return createNode(t);}
- }
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode unused_production_generic_syntax() throws ParseException {
- Token start = null;
- CSSNode term = null;
- Token end = null;
- try {
- start = jj_consume_token(LPARAN);
- label_32:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[39] = jj_gen;
- break label_32;
- }
- jj_consume_token(S);
- }
- term = term();
- end = jj_consume_token(RPARAN);
- } catch (ParseException e) {
- addException(e);
- error_skipto(RPARAN);
- {if (true) return null;}
- }
- if (notNull(start, term, end)) {
- CSSNode node = new CSSNode('[' + term.getName() + ']');
- node.addChildren(term.getChildren());
- node.setStartLocation(getStartLocation(start));
- node.setEndLocation(getEndLocation(end));
- {if (true) return node;}
- }
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode definition() throws ParseException {
- Token start = null;
- CSSNode term = null;
- Token end = null;
- try {
- start = jj_consume_token(LBRACKET);
- label_33:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[40] = jj_gen;
- break label_33;
- }
- jj_consume_token(S);
- }
- term = term();
- end = jj_consume_token(RBRACKET);
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACKET);
- {if (true) return null;}
- }
- if (notNull(start, term, end)) {
- CSSNode node = new CSSNode('[' + term.getName() + ']');
- node.addChildren(term.getChildren());
- node.setStartLocation(getStartLocation(start));
- node.setEndLocation(getEndLocation(end));
- }
- throw new Error("Missing return statement in function");
- }
- final public CSSNode page() throws ParseException {
- CSSNode node = new CSSNode();
- CSSNode child = null;
- List<CSSNode> contents = null;
- Token start = null;
- Token i = null;
- Token end = null;
- try {
- start = jj_consume_token(PAGE_SYM);
- if (start != null) node.setName(start.image);
- label_34:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[41] = jj_gen;
- break label_34;
- }
- jj_consume_token(S);
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IDENT:
- i = jj_consume_token(IDENT);
- if (i != null) node.setName(node.getName() + ' ' + i.image);
- label_35:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[42] = jj_gen;
- break label_35;
- }
- jj_consume_token(S);
- }
- break;
- default:
- jj_la1[43] = jj_gen;
- ;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case COLON:
- child = pseudo_page();
- if (child != null) node.addChild(child);
- break;
- default:
- jj_la1[44] = jj_gen;
- ;
- }
- jj_consume_token(LBRACE);
- label_36:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[45] = jj_gen;
- break label_36;
- }
- jj_consume_token(S);
- }
- contents = pageContent();
- if (contents != null) node.addChildren(contents);
- end = jj_consume_token(RBRACE);
- label_37:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[46] = jj_gen;
- break label_37;
- }
- jj_consume_token(S);
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return null;}
- }
- if (notNull(start, end)) {
- node.setStartLocation(getStartLocation(start));
- node.setEndLocation(getEndLocation(end));
- {if (true) return node;}
- }
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
- final public List<CSSNode> pageContent() throws ParseException {
- CSSNode node = null;
- List<CSSNode> list = null;
- try {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case ATTOP:
- case ATRIGHT:
- case ATBOTTOM:
- case ATLEFT:
- node = prefAtRule();
- break;
- default:
- jj_la1[47] = jj_gen;
- list = declarations();
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return null;}
- }
- if (node != null) {
- list = new ArrayList<CSSNode>();
- list.add(node);
- {if (true) return list;}
- }
- else if (list != null) {
- {if (true) return list;}
- }
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode prefAtRule() throws ParseException {
- Token start = null;
- List<CSSNode> decls = null;
- Token end = null;
- try {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case ATTOP:
- start = jj_consume_token(ATTOP);
- break;
- case ATBOTTOM:
- start = jj_consume_token(ATBOTTOM);
- break;
- case ATLEFT:
- start = jj_consume_token(ATLEFT);
- break;
- case ATRIGHT:
- start = jj_consume_token(ATRIGHT);
- break;
- default:
- jj_la1[48] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- label_38:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[49] = jj_gen;
- break label_38;
- }
- jj_consume_token(S);
- }
- jj_consume_token(LBRACE);
- label_39:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[50] = jj_gen;
- break label_39;
- }
- jj_consume_token(S);
- }
- decls = declarations();
- end = jj_consume_token(RBRACE);
- label_40:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[51] = jj_gen;
- break label_40;
- }
- jj_consume_token(S);
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return null;}
- }
- if (notNull(start, decls, end)) {
- CSSNode node = new CSSNode(start.image);
- node.addChildren(decls);
- node.setStartLocation(getStartLocation(start));
- node.setEndLocation(getEndLocation(end));
- {if (true) return node;}
- }
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode pseudo_page() throws ParseException {
- Token start = null;
- Token t = null;
- try {
- start = jj_consume_token(COLON);
- t = jj_consume_token(IDENT);
- label_41:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[52] = jj_gen;
- break label_41;
- }
- jj_consume_token(S);
- }
- } catch (ParseException e) {
- addException(e);
- {if (true) return null;}
- }
- if (notNull(t)) {
- CSSNode node = new CSSNode(':' + t.image);
- node.setStartLocation(getStartLocation(start));
- node.setEndLocation(getEndLocation(start));
- {if (true) return node;}
- }
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode fontFace() throws ParseException {
- Token start = null;
- List<CSSNode> decls = null;
- Token end = null;
- try {
- start = jj_consume_token(FONT_FACE_SYM);
- label_42:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[53] = jj_gen;
- break label_42;
- }
- jj_consume_token(S);
- }
- jj_consume_token(LBRACE);
- label_43:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[54] = jj_gen;
- break label_43;
- }
- jj_consume_token(S);
- }
- decls = declarations();
- end = jj_consume_token(RBRACE);
- label_44:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[55] = jj_gen;
- break label_44;
- }
- jj_consume_token(S);
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return null;}
- }
- if (notNull(start, decls, end)) {
- CSSNode node = new CSSNode(start.image);
- node.addChildren(decls);
- node.setStartLocation(getStartLocation(start));
- node.setEndLocation(getEndLocation(end));
- {if (true) return node;}
- }
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode colorprofile() throws ParseException {
- Token start = null;
- List<CSSNode> decls = null;
- Token end = null;
- try {
- start = jj_consume_token(COLOR_PROFILE);
- label_45:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[56] = jj_gen;
- break label_45;
- }
- jj_consume_token(S);
- }
- jj_consume_token(LBRACE);
- label_46:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[57] = jj_gen;
- break label_46;
- }
- jj_consume_token(S);
- }
- decls = declarations();
- end = jj_consume_token(RBRACE);
- label_47:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[58] = jj_gen;
- break label_47;
- }
- jj_consume_token(S);
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return null;}
- }
- if (notNull(start, decls, end)) {
- CSSNode node = new CSSNode(start.image);
- node.addChildren(decls);
- node.setStartLocation(getStartLocation(start));
- node.setEndLocation(getEndLocation(end));
- {if (true) return node;}
- }
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode preference() throws ParseException {
- Token start = null;
- List<CSSNode> decls = null;
- Token end = null;
- try {
- start = jj_consume_token(PREF_SYM);
- label_48:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[59] = jj_gen;
- break label_48;
- }
- jj_consume_token(S);
- }
- jj_consume_token(LBRACE);
- label_49:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[60] = jj_gen;
- break label_49;
- }
- jj_consume_token(S);
- }
- decls = declarations();
- end = jj_consume_token(RBRACE);
- label_50:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[61] = jj_gen;
- break label_50;
- }
- jj_consume_token(S);
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return null;}
- }
- if (notNull(start, decls, end)) {
- CSSNode node = new CSSNode(start.image);
- node.addChildren(decls);
- node.setStartLocation(getStartLocation(start));
- node.setEndLocation(getEndLocation(end));
- {if (true) return node;}
- }
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode phoneticAlphabet() throws ParseException {
- Token start = null;
- Token middle = null;
- Token end = null;
- try {
- start = jj_consume_token(PHONETIC_ALPHABET_SYM);
- label_51:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[62] = jj_gen;
- break label_51;
- }
- jj_consume_token(S);
- }
- middle = jj_consume_token(STRING);
- label_52:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[63] = jj_gen;
- break label_52;
- }
- jj_consume_token(S);
- }
- end = jj_consume_token(SEMICOLON);
- } catch (ParseException e) {
- addException(e);
- error_skipto(SEMICOLON);
- {if (true) return null;}
- }
- if (notNull(start, middle, end)) {
- StringBuilder name = new StringBuilder();
- name.append(start.image).append(' ').append(middle.image);
- CSSNode node = new CSSNode(name.toString());
- node.setStartLocation(getStartLocation(start));
- node.setEndLocation(getEndLocation(end));
- {if (true) return node;}
- }
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode atRuleDeclaration() throws ParseException {
- Token t = null;
- try {
- t = jj_consume_token(ATKEYWORD);
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return null;}
- }
- if (notNull(t)) {
- {if (true) return createNode(t);}
- }
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
- final public char operator() throws ParseException {
- char op = ' ';
- try {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case COMMA:
- case DIV:
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case DIV:
- jj_consume_token(DIV);
- op = '/';
- break;
- case COMMA:
- jj_consume_token(COMMA);
- op = ',';
- break;
- default:
- jj_la1[64] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- label_53:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[65] = jj_gen;
- break label_53;
- }
- jj_consume_token(S);
- }
- break;
- default:
- jj_la1[66] = jj_gen;
- ;
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return op;}
- }
- {if (true) return op;}
- throw new Error("Missing return statement in function");
- }
- final public char combinator() throws ParseException {
- char connector = ' ';
- try {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case PLUS:
- case GREATER:
- case TILDE:
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case PLUS:
- jj_consume_token(PLUS);
- connector = '+' ;
- break;
- case GREATER:
- jj_consume_token(GREATER);
- connector = '>' ;
- break;
- case TILDE:
- jj_consume_token(TILDE);
- connector = '~' ;
- break;
- default:
- jj_la1[67] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- label_54:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[68] = jj_gen;
- break label_54;
- }
- jj_consume_token(S);
- }
- break;
- case S:
- label_55:
- while (true) {
- jj_consume_token(S);
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[69] = jj_gen;
- break label_55;
- }
- }
- connector = ' ' ;
- break;
- default:
- jj_la1[70] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return connector;}
- }
- {if (true) return connector;}
- throw new Error("Missing return statement in function");
- }
- final public char unaryOperator() throws ParseException {
- char unary;
- try {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case MINUS:
- jj_consume_token(MINUS);
- unary = '-';
- break;
- case PLUS:
- jj_consume_token(PLUS);
- unary = '+';
- break;
- default:
- jj_la1[71] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return ' ';}
- }
- {if (true) return unary;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode property() throws ParseException {
- Token t = null;
- try {
- t = jj_consume_token(IDENT);
- label_56:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[72] = jj_gen;
- break label_56;
- }
- jj_consume_token(S);
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return null;}
- }
- if (notNull(t)) {
- if (isUnsupported(t.image)) {
- Range range = new Range( new Location( t.next.beginLine, t.next.beginColumn-1 ), new Location( t.next.endLine, t.next.endColumn ) );
- addWarning(new ParseError(t.image + " is not supported by most browsers.", range));
- }
- {if (true) return createNode(t);}
- }
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
- final public CSSNode ruleSet() throws ParseException {
- CSSNode sel = null;
- List<CSSNode> selectors = new ArrayList<CSSNode>();
- List<CSSNode> decls = null;
- Token end = null;
- try {
- sel = selector();
- if (sel != null) selectors.add(sel);
- label_57:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case COMMA:
- ;
- break;
- default:
- jj_la1[73] = jj_gen;
- break label_57;
- }
- jj_consume_token(COMMA);
- label_58:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[74] = jj_gen;
- break label_58;
- }
- jj_consume_token(S);
- }
- sel = selector();
- if (sel != null) selectors.add(sel);
- }
- jj_consume_token(LBRACE);
- label_59:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[75] = jj_gen;
- break label_59;
- }
- jj_consume_token(S);
- }
- decls = declarations();
- end = jj_consume_token(RBRACE);
- label_60:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case S:
- ;
- break;
- default:
- jj_la1[76] = jj_gen;
- break label_60;
- }
- jj_consume_token(S);
- }
- } catch (ParseException e) {
- addException(e);
- error_skipto(RBRACE);
- {if (true) return null;}
- }
- if (selectors.size() > 0 && notNull(decls, end)) {
- StringBuilder sb = new StringBuilder();
- for (CSSNode s : selectors) {
- sb.append(s.ge…