All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.netbeans.modules.css.parser.css.jj Maven / Gradle / Ivy

The newest version!
/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. /Volumes/Mercurial/hg/web-main/css.editor/src/org/netbeans/modules/css/parser/css.jj */
/*@egen*/options {
                        
	IGNORE_CASE = true;
	STATIC = false;
//    UNICODE_INPUT = false;
    USER_CHAR_STREAM = true;
}

PARSER_BEGIN(CssParser)

package org.netbeans.modules.css.parser;

import java.util.*;

public class CssParser/*@bgen(jjtree)*/implements CssParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/
  protected JJTCssParserState jjtree = new JJTCssParserState();

/*@egen*/

    private ArrayList errors = new ArrayList();

    public CssParser() {
       this((CharStream) null);
       // change manager to our patched one:
       token_source = new PatchedCssParserTokenManager(null);
    }

    public List errors() {
        return errors;
    }

}

PARSER_END(CssParser)

//TOKEN_MGR_DECLS :


 TOKEN :
{
    < S: ( " "|"\t"|"\r"|"\n"|"\f" )+ >
}

 MORE :
{
  < "/*" > : IN_COMMENT
}

 MORE :
{
 < ~[] >
}

 TOKEN :
{
  < COMMENT: "*/" > : DEFAULT
}

 MORE: 
{
  < "expression(" > : MS_EXPRESSION
}

 TOKEN :
{
//this is very simple identification of the end of the expression. The closing par. may be
//in a string or there might be some brackets in expressions inside.
  < MSE : ")" > : DEFAULT
}

 MORE :
{
  < ~[] > : MS_EXPRESSION
}


 TOKEN :
{
  < LBRACE: "{" >
| < RBRACE: "}" >
| < COMMA: "," >
| < DOT: "." >
| < SEMICOLON: ";" >
| < COLON: ":" >
| < ASTERISK: "*" >
| < SLASH: "/" >
| < PLUS: "+" >
| < MINUS: "-" >
| < EQUALS: "=" >
| < GT: ">" >
| < LSQUARE: "[" >
| < RSQUARE: "]" >
}

 TOKEN :
{
  < HASH: "#"  >
}

 TOKEN :
{
  < STRING:  |  > 
| < RROUND: ")" >
}

 TOKEN :
{
  < #URL: ["!","#","$","%","&","*"-"~"] |  |  >
| < URI: "url(" (  )* (  | (  )* ) (  )*  > 
}

 TOKEN : {
    < GENERATED: "@@@" >
}

 TOKEN :
{
  < CDO: "" >
| < INCLUDES: "~=" >
| < CSS3_BEGINS: "^=" >
| < CSS3_ENDS: "$=" >
| < CSS3_CONTAINS: "*=" >
| < DASHMATCH: "|=" >
| < IMPORT_SYM: "@import" >
| < PAGE_SYM: "@page" >
| < MEDIA_SYM: "@media" >
| < FONT_FACE_SYM: "@font-face" >
| < CHARSET_SYM: "@charset" >
| < ATKEYWORD: "@"  >
| < IMPORTANT_SYM: "!" (  )? "important" >
| < INHERIT: "inherit" >
| < EMS:  "em" > 
| < EXS:  "ex" > 
| < LENGTH_PX:  "px" > 
| < LENGTH_CM:  "cm" >
| < LENGTH_MM:  "mm" >
| < LENGTH_IN:  "in" >
| < LENGTH_PT:  "pt" >
| < LENGTH_PC:  "pc" >
| < ANGLE_DEG:  "deg" >
| < ANGLE_RAD:  "rad" >
| < ANGLE_GRAD:  "grad" >
| < TIME_MS:  "ms" >
| < TIME_S:  "s" > 
| < FREQ_HZ:  "Hz" >
| < FREQ_KHZ:  "kHz" >
| < DIMEN:   >
| < PERCENTAGE:  "%" >
| < NUMBER:  >
| < RGB: "rgb(" >
| < FUNCTION:  "(" >
| < IDENT: ()+ | (( "-" )?  (  )*) >
| < #NAME: (  )+ >
| < NUM: ( ["0"-"9"] )+ | ( ["0"-"9"] )* "." ( ["0"-"9"] )+ >

| < UNICODERANGE: "U+" (  | (  "-"  ) ) >
| < #RANGE:  |  ( ()? |  ( ()? |  ( ()? |  ( ()? |  ( ()? |  ) ) ) ) ) >
| < #Q16: "?" | "??" | "???" | "????" | "?????" | "??????" >
| < #Q15: "?" | "??" | "???" | "????" | "?????" >
| < #Q14: "?" | "??" | "???" | "????" >
| < #Q13: "?" | "??" | "???" >
| < #Q12: "?" | "??" >
| < #Q11: "?" >

| < #NMSTART: ["_"] | ["a"-"z"] |  |  >
| < #NMCHAR: ["_"] | ["a"-"z","0"-"9","-"] |  |  >
| < #STRING1: "\"" ( ["\t"," ","!","#","$","%","&","("-"~"] | "\\"  | "\'" |  |  )* "\"" >
| < #STRING2: "\'" ( ["\t"," ","!","#","$","%","&","("-"~"] | "\\"  | "\"" |  |  )* "\'" >
| < #NONASCII: ["\u0080"-"\uffff"] >
| < #ESCAPE:  | ( "\\" [" "-"~","\u0080"-"\uffff"] ) >
| < #NL: "\n" | "\r\n" | "\r" | "\f" >
| < #UNICODE: "\\"  ( " " | "\t" | "\r" | "\n" | "\f" )? >
| < #HNUM:  |  |  |  |  |  >
| < #H: ["0"-"9","a"-"f"] >
}

<*> TOKEN:
{
    < UNKNOWN: ~[] >
    {
        //System.err.println("Illegal character : " + image.toString());
    }
}

SimpleNode styleSheet() :{/*@bgen(jjtree) styleSheet */
  SimpleNode jjtn000 = new SimpleNode(JJTSTYLESHEET);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/} {/*@bgen(jjtree) styleSheet */
  try {
/*@egen*/
  styleSheetRuleList()/*@bgen(jjtree)*/
  {
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    jjtn000.jjtSetLastToken(getToken(0));
  }
/*@egen*/
  { return jjtn000; }/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
      jjtn000.jjtSetLastToken(getToken(0));
    }
  }
/*@egen*/
}

void styleSheetRuleList() :{/*@bgen(jjtree) styleSheetRuleList */
  SimpleNode jjtn000 = new SimpleNode(JJTSTYLESHEETRULELIST);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/} {/*@bgen(jjtree) styleSheetRuleList */
  try {
/*@egen*/
  ( charsetRule() )?
  ( (  |  ) |  |  )*
  ( importRule() ( (  |  ) |  |  )* )*
  ( (  { return; } | rule() ) ( (  |  ) |  |  )* )*/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
      jjtn000.jjtSetLastToken(getToken(0));
    }
  }
/*@egen*/
}

void rule() :{/*@bgen(jjtree) rule */
  SimpleNode jjtn000 = new SimpleNode(JJTRULE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/} {/*@bgen(jjtree) rule */
    try {
/*@egen*/
    styleRule() | mediaRule() | pageRule() | fontFaceRule() | unknownRule() | error_skip_to_whitespace()/*@bgen(jjtree)*/
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
        jjtc000 = false;
      } else {
        jjtree.popNode();
      }
      if (jjte000 instanceof RuntimeException) {
        throw (RuntimeException)jjte000;
      }
      if (jjte000 instanceof ParseException) {
        throw (ParseException)jjte000;
      }
      throw (Error)jjte000;
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

//
// This is used by ASTStyleSheet.insertRule to parse a single rule
//
void styleSheetRuleSingle() :{/*@bgen(jjtree) styleSheetRuleSingle */
  SimpleNode jjtn000 = new SimpleNode(JJTSTYLESHEETRULESINGLE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/} {/*@bgen(jjtree) styleSheetRuleSingle */
  try {
/*@egen*/
  ( charsetRule() | importRule() | styleRule() | mediaRule() | pageRule() | fontFaceRule() | unknownRule() )/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
      jjtn000.jjtSetLastToken(getToken(0));
    }
  }
/*@egen*/
}

void charsetRule() : {/*@bgen(jjtree) charsetRule */
  SimpleNode jjtn000 = new SimpleNode(JJTCHARSETRULE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/} {/*@bgen(jjtree) charsetRule */
  try {
/*@egen*/
   ( (  |  ) )*
   ( (  |  ) )*
  /*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
      jjtn000.jjtSetLastToken(getToken(0));
    }
  }
/*@egen*/
}

void unknownRule() :{/*@bgen(jjtree) unknownRule */
  SimpleNode jjtn000 = new SimpleNode(JJTUNKNOWNRULE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/} {/*@bgen(jjtree) unknownRule */
    try {
/*@egen*/
    
    skip()/*@bgen(jjtree)*/
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

void importRule() : {/*@bgen(jjtree) importRule */
  SimpleNode jjtn000 = new SimpleNode(JJTIMPORTRULE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/} {/*@bgen(jjtree) importRule */
    try {
/*@egen*/
     ( (  |  ) )*
    (
    |  ) ( (  |  ) )*
    ( mediaList() )?
    /*@bgen(jjtree)*/
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
        jjtc000 = false;
      } else {
        jjtree.popNode();
      }
      if (jjte000 instanceof RuntimeException) {
        throw (RuntimeException)jjte000;
      }
      if (jjte000 instanceof ParseException) {
        throw (ParseException)jjte000;
      }
      throw (Error)jjte000;
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

void mediaRule() : {/*@bgen(jjtree) mediaRule */
  SimpleNode jjtn000 = new SimpleNode(JJTMEDIARULE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/} {/*@bgen(jjtree) mediaRule */
    try {
/*@egen*/
    try {
         ( (  |  ) )*
        mediaList()
         ( (  |  ) )*
        ( mediaRuleList() )?
        
    } catch(ParseException e) {
        reportError(e);
        error_skipblock();
    }/*@bgen(jjtree)*/
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
        jjtc000 = false;
      } else {
        jjtree.popNode();
      }
      if (jjte000 instanceof RuntimeException) {
        throw (RuntimeException)jjte000;
      }
      if (jjte000 instanceof ParseException) {
        throw (ParseException)jjte000;
      }
      throw (Error)jjte000;
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

void mediaList() :{/*@bgen(jjtree) mediaList */
  SimpleNode jjtn000 = new SimpleNode(JJTMEDIALIST);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/} {/*@bgen(jjtree) mediaList */
    try {
/*@egen*/
    medium()
    (  ( (  |  ) )* medium() )*/*@bgen(jjtree)*/
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
        jjtc000 = false;
      } else {
        jjtree.popNode();
      }
      if (jjte000 instanceof RuntimeException) {
        throw (RuntimeException)jjte000;
      }
      if (jjte000 instanceof ParseException) {
        throw (ParseException)jjte000;
      }
      throw (Error)jjte000;
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

void mediaRuleList() : {/*@bgen(jjtree) mediaRuleList */
  SimpleNode jjtn000 = new SimpleNode(JJTMEDIARULELIST);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/} {/*@bgen(jjtree) mediaRuleList */
  try {
/*@egen*/
  ( ( styleRule() | pageRule() | unknownRule() ) ( (  |  ) )* )+/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
      jjtn000.jjtSetLastToken(getToken(0));
    }
  }
/*@egen*/
}

void mediaRuleSingle() :
{/*@bgen(jjtree) mediaRuleSingle */
  SimpleNode jjtn000 = new SimpleNode(JJTMEDIARULESINGLE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) mediaRuleSingle */
  try {
/*@egen*/
  ( styleRule() | pageRule() | unknownRule() )/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
      jjtn000.jjtSetLastToken(getToken(0));
    }
  }
/*@egen*/
}

void medium() :
{/*@bgen(jjtree) medium */
  SimpleNode jjtn000 = new SimpleNode(JJTMEDIUM);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) medium */
  try {
/*@egen*/
  (  |  ) ( (  |  ) )*/*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
      jjtn000.jjtSetLastToken(getToken(0));
    }
  }
/*@egen*/
}

void pageRule() :
{/*@bgen(jjtree) pageRule */
    SimpleNode jjtn000 = new SimpleNode(JJTPAGERULE);
    boolean jjtc000 = true;
    jjtree.openNodeScope(jjtn000);
    jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
    Token t = null;
    String s = null;
    boolean start = false;
}
{/*@bgen(jjtree) pageRule */
        try {
/*@egen*/
         ( (  |  ) )*

        ( LOOKAHEAD(2) ( t =  ( (  |  ) )* ) |
        (  pseudoPage() ( (  |  ) )* ) |
        ( pseudoPage() ( (  |  ) )* ) )?

         ( (  |  ) )*
        ( declaration() )?
        (  ( (  |  ) )* ( declaration() )? )*
        /*@bgen(jjtree)*/
        } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            throw (RuntimeException)jjte000;
          }
          if (jjte000 instanceof ParseException) {
            throw (ParseException)jjte000;
          }
          throw (Error)jjte000;
        } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
            jjtn000.jjtSetLastToken(getToken(0));
          }
        }
/*@egen*/
}

//
// pseudoPage
//   : ':' IDENT
//   ;
//
void pseudoPage() :
{/*@bgen(jjtree) pseudoPage */
  SimpleNode jjtn000 = new SimpleNode(JJTPSEUDOPAGE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) pseudoPage */
  try {
/*@egen*/
   
  /*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
      jjtn000.jjtSetLastToken(getToken(0));
    }
  }
/*@egen*/ 
}

//
// font_face
//   : FONT_FACE_SYM S*
//     '{' S* declaration [ ';' S* declaration ]* '}' S*
//   ;
//
void fontFaceRule() :
{/*@bgen(jjtree) fontFaceRule */
  SimpleNode jjtn000 = new SimpleNode(JJTFONTFACERULE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) fontFaceRule */
        try {
/*@egen*/
         ( (  |  ) )*
         ( (  |  ) )*
        ( declaration() )?
        (  ( (  |  ) )* ( declaration() )? )*
        /*@bgen(jjtree)*/
        } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            throw (RuntimeException)jjte000;
          }
          if (jjte000 instanceof ParseException) {
            throw (ParseException)jjte000;
          }
          throw (Error)jjte000;
        } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
            jjtn000.jjtSetLastToken(getToken(0));
          }
        }
/*@egen*/
}

//
// operator
//   : '/' S* | ',' S* |
//   ;
//
void operator() :
{/*@bgen(jjtree) operator */
  SimpleNode jjtn000 = new SimpleNode(JJTOPERATOR);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) operator */
  try {
/*@egen*/
   ( (  |  ) )* |   ( (  |  ) )*/*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
      jjtn000.jjtSetLastToken(getToken(0));
    }
  }
/*@egen*/
}

//
// combinator
//   : '+' S* | '>' S* |
//   ;
//
void combinator() :
{/*@bgen(jjtree) combinator */
  SimpleNode jjtn000 = new SimpleNode(JJTCOMBINATOR);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) combinator */
  try {
/*@egen*/
  (  ( (  |  ) )*
  |  ( (  |  ) )*
  | (  |  ) ( (  |  ) ( (  |  ) )* )? )/*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
      jjtn000.jjtSetLastToken(getToken(0));
    }
  }
/*@egen*/

}

//
// unary_operator
//   : '-' | '+'
//   ;
//
void unaryOperator() :
{/*@bgen(jjtree) unaryOperator */
  SimpleNode jjtn000 = new SimpleNode(JJTUNARYOPERATOR);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) unaryOperator */
  try {
/*@egen*/
  (  |  )/*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
      jjtn000.jjtSetLastToken(getToken(0));
    }
  }
/*@egen*/
}

//
// property
//   : IDENT S*
//   ;
//
void property() :
{/*@bgen(jjtree) property */
  SimpleNode jjtn000 = new SimpleNode(JJTPROPERTY);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) property */
    try {
/*@egen*/
    ( |  | ) ( (  |  ) )*/*@bgen(jjtree)*/
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

//
// ruleset
//   : selector [ ',' S* selector ]*
//     '{' S* declaration [ ';' S* declaration ]* '}' S*
//   ;
//

//TODO marek: resolve the error reporting and recovery in styleRule()
void styleRule() :
{/*@bgen(jjtree) styleRule */
  SimpleNode jjtn000 = new SimpleNode(JJTSTYLERULE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) styleRule */
    try {
/*@egen*/
    try {
        selectorList()
         ( (  |  ) )*
        ( declaration() )?
        (  ( (  |  ) )* ( declaration() )? )*
        
    } catch(ParseException e) {
        reportError(e);
        error_skipblock();
    }/*@bgen(jjtree)*/
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
        jjtc000 = false;
      } else {
        jjtree.popNode();
      }
      if (jjte000 instanceof RuntimeException) {
        throw (RuntimeException)jjte000;
      }
      if (jjte000 instanceof ParseException) {
        throw (ParseException)jjte000;
      }
      throw (Error)jjte000;
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

void selectorList() :
{/*@bgen(jjtree) selectorList */
  SimpleNode jjtn000 = new SimpleNode(JJTSELECTORLIST);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) selectorList */
    try {
/*@egen*/
    try {
        selector()
        (  ( (  |  ) )*  selector() )*

    } catch (ParseException e) {
        reportError(e);
    }/*@bgen(jjtree)*/
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
        jjtc000 = false;
      } else {
        jjtree.popNode();
      }
      if (jjte000 instanceof RuntimeException) {
        throw (RuntimeException)jjte000;
      }
      if (jjte000 instanceof ParseException) {
        throw (ParseException)jjte000;
      }
      throw (Error)jjte000;
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

//
// selector
//   : simple_selector [ combinator simple_selector ]*
//   ;
//
void selector() :
{/*@bgen(jjtree) selector */
  SimpleNode jjtn000 = new SimpleNode(JJTSELECTOR);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) selector */
    try {
/*@egen*/
    try {
        simpleSelector()
        ( LOOKAHEAD(2) combinator() simpleSelector() )* ( (  |  ) )*
    } catch (ParseException e) {
        reportError(e);
        skipSelector();
    }/*@bgen(jjtree)*/
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
        jjtc000 = false;
      } else {
        jjtree.popNode();
      }
      if (jjte000 instanceof RuntimeException) {
        throw (RuntimeException)jjte000;
      }
      if (jjte000 instanceof ParseException) {
        throw (ParseException)jjte000;
      }
      throw (Error)jjte000;
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

//
// simple_selector
//   : element_name? [ HASH | class | attrib | pseudo ]* S*
//   ;
//
void simpleSelector() :
{/*@bgen(jjtree) simpleSelector */
  SimpleNode jjtn000 = new SimpleNode(JJTSIMPLESELECTOR);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) simpleSelector */
    try {
/*@egen*/
    (
        ( elementName()
            ( hash()
            | _class()
            | attrib()
            | pseudo()
            )*
        )
        |
        ( 
            ( hash()
            | _class()
            | attrib()
            | pseudo()
            )+
        )
    )/*@bgen(jjtree)*/
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
        jjtc000 = false;
      } else {
        jjtree.popNode();
      }
      if (jjte000 instanceof RuntimeException) {
        throw (RuntimeException)jjte000;
      }
      if (jjte000 instanceof ParseException) {
        throw (ParseException)jjte000;
      }
      throw (Error)jjte000;
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/

}

//
// class
//   : '.' IDENT
//   ;
//
void _class() :
{/*@bgen(jjtree) _class */
  SimpleNode jjtn000 = new SimpleNode(JJT_CLASS);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) _class */
    try {
/*@egen*/
     (  |  )/*@bgen(jjtree)*/
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

//
// element_name
//   : IDENT | '*'
//   ;
//
void elementName() :
{/*@bgen(jjtree) elementName */
  SimpleNode jjtn000 = new SimpleNode(JJTELEMENTNAME);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) elementName */
  try {
/*@egen*/
   |  | /*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
      jjtn000.jjtSetLastToken(getToken(0));
    }
  }
/*@egen*/
}

//
// attrib
//   : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S*
//     [ IDENT | STRING ] S* ]? ']'
//   ;
//
void attrib() :
{/*@bgen(jjtree) attrib */
  SimpleNode jjtn000 = new SimpleNode(JJTATTRIB);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) attrib */
    try {
/*@egen*/
     ( (  |  ) )*
    (  ) ( (  |  ) )*
    (
        (
            
            |
            
            |
            
            |
            
            |
            
            |
            
        )
        ( (  |  ) )*
        (
            (  )
            |
             
        )
        ( (  |  ) )*
    )?
    /*@bgen(jjtree)*/
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/

}

//
// pseudo
//   : ':' [ IDENT | FUNCTION S* IDENT S* ')' ]
//   ;
//
void pseudo() :
{/*@bgen(jjtree) pseudo */
  SimpleNode jjtn000 = new SimpleNode(JJTPSEUDO);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) pseudo */
    try {
/*@egen*/
    
    (
        (  |  )
        |
        (
             ( (  |  ) )*
            ( (()? ) |  ) ( (  |  ) )*
            
        )
    )/*@bgen(jjtree)*/
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

void hash() :
{/*@bgen(jjtree) hash */
  SimpleNode jjtn000 = new SimpleNode(JJTHASH);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) hash */
    try {
/*@egen*/
    /*@bgen(jjtree)*/
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

void styleDeclaration()  :
{/*@bgen(jjtree) styleDeclaration */
  SimpleNode jjtn000 = new SimpleNode(JJTSTYLEDECLARATION);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) styleDeclaration */
        try {
/*@egen*/
	 ( (  |  ) )*
	( declaration() )?
	(  ( (  |  ) )* ( declaration() )? )*
	/*@bgen(jjtree)*/
        } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            throw (RuntimeException)jjte000;
          }
          if (jjte000 instanceof ParseException) {
            throw (ParseException)jjte000;
          }
          throw (Error)jjte000;
        } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
            jjtn000.jjtSetLastToken(getToken(0));
          }
        }
/*@egen*/
}

//
// declaration
//   : property ':' S* expr prio?
//   |
//   ;
//
void declaration() :
{/*@bgen(jjtree) declaration */
  SimpleNode jjtn000 = new SimpleNode(JJTDECLARATION);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) declaration */
    try {
/*@egen*/
    try {
        (
        LOOKAHEAD(  (  |  )* ( | ))
             (  |  )*
            |
            (
                property()
                 ( (  |  ) )*
                expr()
                ( prio() )?
            )
        )
    } catch (ParseException e) {
        reportError(e);
        error_skipdecl(); //recovery
    }/*@bgen(jjtree)*/
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
        jjtc000 = false;
      } else {
        jjtree.popNode();
      }
      if (jjte000 instanceof RuntimeException) {
        throw (RuntimeException)jjte000;
      }
      if (jjte000 instanceof ParseException) {
        throw (ParseException)jjte000;
      }
      throw (Error)jjte000;
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

//
// prio
//   : IMPORTANT_SYM S*
//   ;
//
void prio() :
{/*@bgen(jjtree) prio */
  SimpleNode jjtn000 = new SimpleNode(JJTPRIO);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) prio */
  try {
/*@egen*/
   ( (  |  ) )*/*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
      jjtn000.jjtSetLastToken(getToken(0));
    }
  }
/*@egen*/
}

//
// expr
//   : term [ operator term ]*
//   ;
//
// TODO: Deal with the operator
//
void expr() :
{/*@bgen(jjtree) expr */
  SimpleNode jjtn000 = new SimpleNode(JJTEXPR);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) expr */
   try {
/*@egen*/
   term()
   ( (  operator() |  )? (term() |  |  ) )*/*@bgen(jjtree)*/
   } catch (Throwable jjte000) {
     if (jjtc000) {
       jjtree.clearNodeScope(jjtn000);
       jjtc000 = false;
     } else {
       jjtree.popNode();
     }
     if (jjte000 instanceof RuntimeException) {
       throw (RuntimeException)jjte000;
     }
     if (jjte000 instanceof ParseException) {
       throw (ParseException)jjte000;
     }
     throw (Error)jjte000;
   } finally {
     if (jjtc000) {
       jjtree.closeNodeScope(jjtn000, true);
       jjtn000.jjtSetLastToken(getToken(0));
     }
   }
/*@egen*/
}

//
// term
//   : unary_operator?
//     [ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* |
//       TIME S* | FREQ S* | function ]
//   | STRING S* | IDENT S* | URI S* | RGB S* | UNICODERANGE S* | hexcolor
//   ;
//
void term() :
{/*@bgen(jjtree) term */
  SimpleNode jjtn000 = new SimpleNode(JJTTERM);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) term */
    try {
/*@egen*/
    ( unaryOperator() )?
    (
        (      
        | 
        | 
        | 
        | 
        | 
        | 
        | 
        |       
        |       
        | 
        | 
        | 
        |    
        |     
        |    
        |   
        | 
        | function()
        )
    |         
    | 
    | 
    |          
    | 
    | rgb()
    | hexcolor()
    | 
    |   
    )
    ( (  |  ) )*/*@bgen(jjtree)*/
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
        jjtc000 = false;
      } else {
        jjtree.popNode();
      }
      if (jjte000 instanceof RuntimeException) {
        throw (RuntimeException)jjte000;
      }
      if (jjte000 instanceof ParseException) {
        throw (ParseException)jjte000;
      }
      throw (Error)jjte000;
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

//
// function
//   : FUNCTION S* expr ')' S*
//   ;
//
void function() :
{/*@bgen(jjtree) function */
  SimpleNode jjtn000 = new SimpleNode(JJTFUNCTION);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) function */
    try {
/*@egen*/
     ( (  |  ) )*
    expr()
    /*@bgen(jjtree)*/
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
        jjtc000 = false;
      } else {
        jjtree.popNode();
      }
      if (jjte000 instanceof RuntimeException) {
        throw (RuntimeException)jjte000;
      }
      if (jjte000 instanceof ParseException) {
        throw (ParseException)jjte000;
      }
      throw (Error)jjte000;
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

//
// rgb
//   : RGB S* expr ')' S*
//   ;
//
void rgb() :
{/*@bgen(jjtree) rgb */
  SimpleNode jjtn000 = new SimpleNode(JJTRGB);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) rgb */
    try {
/*@egen*/
     ( (  |  ) )*
    expr()
    /*@bgen(jjtree)*/
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
        jjtc000 = false;
      } else {
        jjtree.popNode();
      }
      if (jjte000 instanceof RuntimeException) {
        throw (RuntimeException)jjte000;
      }
      if (jjte000 instanceof ParseException) {
        throw (ParseException)jjte000;
      }
      throw (Error)jjte000;
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}

//
// hexcolor
//   : HASH S*
//   ;
//
void hexcolor() :
{/*@bgen(jjtree) hexcolor */
  SimpleNode jjtn000 = new SimpleNode(JJTHEXCOLOR);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));
/*@egen*/
}
{/*@bgen(jjtree) hexcolor */
    try {
/*@egen*/
     ( (  |  ) )*/*@bgen(jjtree)*/
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
        jjtn000.jjtSetLastToken(getToken(0));
      }
    }
/*@egen*/
}
JAVACODE 
void reportError(ParseException pe) {/*@bgen(jjtree) reportError */
 SimpleNode jjtn000 = new SimpleNode(JJTREPORTERROR);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);
 jjtn000.jjtSetFirstToken(getToken(1));
 try {
/*@egen*/
    errors.add(pe);/*@bgen(jjtree)*/
 } finally {
   if (jjtc000) {
     jjtree.closeNodeScope(jjtn000, true);
     jjtn000.jjtSetLastToken(getToken(0));
   }
 }
/*@egen*/
}

JAVACODE
void skipSelector() {/*@bgen(jjtree) skipSelector */
 SimpleNode jjtn000 = new SimpleNode(JJTSKIPSELECTOR);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);
 jjtn000.jjtSetFirstToken(getToken(1));
 try {
/*@egen*/
    Token t = getToken(1);
    while (t.kind != COMMA && t.kind != SEMICOLON && t.kind != LBRACE && t.kind != EOF ) {
        getNextToken();
        t = getToken(1);
    }/*@bgen(jjtree)*/
 } finally {
   if (jjtc000) {
     jjtree.closeNodeScope(jjtn000, true);
     jjtn000.jjtSetLastToken(getToken(0));
   }
 }
/*@egen*/
}

JAVACODE
String skip() {/*@bgen(jjtree) skip */
SimpleNode jjtn000 = new SimpleNode(JJTSKIP);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
jjtn000.jjtSetFirstToken(getToken(1));
try {
/*@egen*/
  StringBuffer sb = new StringBuffer();
  int nesting = 0;
  Token t = getToken(0);
  if (t.image != null) {
    sb.append(t.image);    
  }
  do {
    t = getNextToken();
    if (t.kind == EOF)
      break;
    sb.append(t.image);
    if (t.kind == LBRACE)
      nesting++;
    else if (t.kind == RBRACE)
      nesting--;
    else if (t.kind == SEMICOLON && nesting <= 0)
      break;
  }
  while ((t.kind != RBRACE) || (nesting > 0));

  return sb.toString();/*@bgen(jjtree)*/
} finally {
  if (jjtc000) {
    jjtree.closeNodeScope(jjtn000, true);
    jjtn000.jjtSetLastToken(getToken(0));
  }
}
/*@egen*/
}

JAVACODE
void error_skipblock() {/*@bgen(jjtree) error_skipblock */
 SimpleNode jjtn000 = new SimpleNode(JJTERROR_SKIPBLOCK);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);
 jjtn000.jjtSetFirstToken(getToken(1));
 try {
/*@egen*/
    ParseException e = generateParseException();
    //System.err.println( "** error_skipblock **\n" + e.toString() );

  Token t = getToken(0);
  int nesting = 0;
  while ((t.kind != RBRACE) || (nesting > 0)) {
    t = getNextToken();
    if( t.kind == LBRACE )
      nesting++;
    else if( t.kind == RBRACE )
      nesting--;
    else if( t.kind == EOF )
      break;
  }/*@bgen(jjtree)*/
 } finally {
   if (jjtc000) {
     jjtree.closeNodeScope(jjtn000, true);
     jjtn000.jjtSetLastToken(getToken(0));
   }
 }
/*@egen*/
  }

JAVACODE
void error_skipdecl() {/*@bgen(jjtree) error_skipdecl */
 SimpleNode jjtn000 = new SimpleNode(JJTERROR_SKIPDECL);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);
 jjtn000.jjtSetFirstToken(getToken(1));
 try {
/*@egen*/
    ParseException e = generateParseException();
    //System.err.println("** error_skipdecl **\n" + e.toString());

  Token t = getNextToken();
  while (t.kind != SEMICOLON && t.kind != RBRACE && t.kind != EOF ) {
      getNextToken();
      t = getToken(1);
  }/*@bgen(jjtree)*/
 } finally {
   if (jjtc000) {
     jjtree.closeNodeScope(jjtn000, true);
     jjtn000.jjtSetLastToken(getToken(0));
   }
 }
/*@egen*/
}


JAVACODE
void error_skip_to_whitespace() {/*@bgen(jjtree) error_skip_to_whitespace */
SimpleNode jjtn000 = new SimpleNode(JJTERROR_SKIP_TO_WHITESPACE);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
jjtn000.jjtSetFirstToken(getToken(1));
try {
/*@egen*/
  Token t;
  do {
    t = getNextToken();
  } while (t != null && t.kind != S &&  t.kind != EOF );/*@bgen(jjtree)*/
} finally {
  if (jjtc000) {
    jjtree.closeNodeScope(jjtn000, true);
    jjtn000.jjtSetLastToken(getToken(0));
  }
}
/*@egen*/
}