2002/css-validator/org/w3c/css/parser/analyzer CssParser.java,1.19,1.20 CssParser.jj,1.17,1.18 CssParserConstants.java,1.6,1.7 CssParserTokenManager.java,1.12,1.13

Update of /sources/public/2002/css-validator/org/w3c/css/parser/analyzer
In directory hutz:/tmp/cvs-serv26855/org/w3c/css/parser/analyzer

Modified Files:
	CssParser.java CssParser.jj CssParserConstants.java 
	CssParserTokenManager.java 
Log Message:
Jean-Gui strikes back!
http://www.w3.org/Bugs/Public/show_bug.cgi?id=2560 -> @media case insensitive
http://www.w3.org/Bugs/Public/show_bug.cgi?id=3037 -> grammar correction
http://www.w3.org/Bugs/Public/show_bug.cgi?id=2920
http://www.w3.org/Bugs/Public/show_bug.cgi?id=2800
http://www.w3.org/Bugs/Public/show_bug.cgi?id=233
http://www.w3.org/Bugs/Public/show_bug.cgi?id=2919
http://www.w3.org/Bugs/Public/show_bug.cgi?id=2446
http://www.w3.org/Bugs/Public/show_bug.cgi?id=3099

output parameter bug fixed:
        accepted values :
            * text/html and html
            * application/xhtml+xml and xhtml
            * application/soap+xml and soap12
            * everything else: text/plain

fixed a bug with SOAP output



Index: CssParserTokenManager.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParserTokenManager.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- CssParserTokenManager.java	14 Sep 2005 15:14:18 -0000	1.12
+++ CssParserTokenManager.java	19 Apr 2006 11:28:05 -0000	1.13
@@ -62,153 +62,155 @@
    switch (pos)
    {
       case 0:
-         if ((active0 & 0xfe00000000000000L) != 0L || (active1 & 0x3fL) != 0L)
-            return 55;
-         if ((active0 & 0x2000000L) != 0L)
-            return 199;
+         if ((active0 & 0xfc00000000000000L) != 0L || (active1 & 0x7fL) != 0L)
+            return 56;
+         if ((active0 & 0x4000000L) != 0L)
+            return 219;
[...5460 lines suppressed...]
          }
          break;
      }
@@ -3975,14 +4061,14 @@
 {
    switch(jjmatchedKind)
    {
-      case 1 :
+      case 2 :
         if (image == null)
             image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
          else
             image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
            image = CssParser.SPACE;
          break;
-      default :
+      default : 
          break;
    }
 }

Index: CssParser.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParser.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- CssParser.java	14 Sep 2005 15:14:18 -0000	1.19
+++ CssParser.java	19 Apr 2006 11:28:05 -0000	1.20
@@ -88,7 +88,7 @@
     protected String currentProperty;
 
     /**
-     * <code>true</code> if the parser should recognized Aural properties,
+     * <code>true</code> if the parser should recognized Aural properties, 
      * <code>false</code> otherwise.
      */
     protected boolean mode;
@@ -101,9 +101,12 @@
 
     static StringBuffer SPACE = new StringBuffer(" ");
[...3202 lines suppressed...]
   }
 
@@ -3654,7 +4437,7 @@
     token = new Token();
     jj_ntk = -1;
     jj_gen = 0;
-    for (int i = 0; i < 120; i++) jj_la1[i] = -1;
+    for (int i = 0; i < 179; i++) jj_la1[i] = -1;
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
   }
 
@@ -3773,7 +4556,7 @@
       la1tokens[jj_kind] = true;
       jj_kind = -1;
     }
-    for (int i = 0; i < 120; i++) {
+    for (int i = 0; i < 179; i++) {
       if (jj_la1[i] == jj_gen) {
         for (int j = 0; j < 32; j++) {
           if ((jj_la1_0[i] & (1<<j)) != 0) {

Index: CssParserConstants.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParserConstants.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssParserConstants.java	30 Mar 2004 13:24:18 -0000	1.6
+++ CssParserConstants.java	19 Apr 2006 11:28:05 -0000	1.7
@@ -4,96 +4,97 @@
 public interface CssParserConstants {
 
   int EOF = 0;
-  int S = 1;
-  int CDO = 5;
-  int CDC = 6;
-  int LBRACE = 7;
-  int RBRACE = 8;
-  int DASHMATCH = 9;
-  int INCLUDES = 10;
-  int PREFIXMATCH = 11;
-  int SUFFIXMATCH = 12;
-  int SUBSTRINGMATCH = 13;
-  int TILDE = 14;
-  int EQ = 15;
-  int PLUS = 16;
-  int MINUS = 17;
-  int COMMA = 18;
-  int SEMICOLON = 19;
-  int PRECEDES = 20;
-  int DIV = 21;
-  int LBRACKET = 22;
-  int RBRACKET = 23;
-  int ANY = 24;
-  int DOT = 25;
-  int LPARAN = 26;
-  int RPARAN = 27;
-  int COLON = 28;
-  int AND = 29;
-  int MEDIARESTRICTOR = 30;
-  int NONASCII = 31;
-  int H = 32;
-  int UNICODE = 33;
-  int ESCAPE = 34;
-  int NMSTART = 35;
-  int NMCHAR = 36;
-  int STRINGCHAR = 37;
-  int D = 38;
-  int NAME = 39;
-  int STRING = 40;
-  int IDENT = 41;
-  int NUMBER = 42;
-  int _URL = 43;
-  int URL = 44;
-  int PERCENTAGE = 45;
-  int LENGTH = 46;
-  int EMS = 47;
-  int EXS = 48;
-  int ANGLE = 49;
-  int TIME = 50;
-  int FREQ = 51;
-  int RESOLUTION = 52;
-  int DATE = 53;
-  int DIMEN = 54;
-  int HASH = 55;
-  int IMPORTANT_SYM = 56;
-  int IMPORT_SYM = 57;
-  int MEDIA_SYM = 58;
-  int PAGE_SYM = 59;
-  int FONT_FACE_SYM = 60;
-  int PREF_SYM = 61;
-  int COLOR_PROFILE = 62;
-  int CHARSET_SYM = 63;
-  int ATTOP = 64;
-  int ATRIGHT = 65;
-  int ATBOTTOM = 66;
-  int ATLEFT = 67;
-  int ATCOUNTER = 68;
-  int PHONETIC_ALPHABET_SYM = 69;
-  int ATKEYWORD = 70;
-  int RANGE0 = 71;
-  int RANGE1 = 72;
-  int RANGE2 = 73;
-  int RANGE3 = 74;
-  int RANGE4 = 75;
-  int RANGE5 = 76;
-  int RANGE6 = 77;
-  int RANGE = 78;
-  int UNI = 79;
-  int UNICODERANGE = 80;
-  int CLASS = 81;
-  int FUNCTION = 82;
-  int UNKNOWN = 83;
+  int SPC_CHAR = 1;
+  int S = 2;
+  int CDO = 6;
+  int CDC = 7;
+  int LBRACE = 8;
+  int RBRACE = 9;
+  int DASHMATCH = 10;
+  int INCLUDES = 11;
+  int PREFIXMATCH = 12;
+  int SUFFIXMATCH = 13;
+  int SUBSTRINGMATCH = 14;
+  int TILDE = 15;
+  int EQ = 16;
+  int PLUS = 17;
+  int MINUS = 18;
+  int COMMA = 19;
+  int SEMICOLON = 20;
+  int PRECEDES = 21;
+  int DIV = 22;
+  int LBRACKET = 23;
+  int RBRACKET = 24;
+  int ANY = 25;
+  int DOT = 26;
+  int LPARAN = 27;
+  int RPARAN = 28;
+  int COLON = 29;
+  int AND = 30;
+  int MEDIARESTRICTOR = 31;
+  int NONASCII = 32;
+  int H = 33;
+  int UNICODE = 34;
+  int ESCAPE = 35;
+  int NMSTART = 36;
+  int NMCHAR = 37;
+  int STRINGCHAR = 38;
+  int D = 39;
+  int NAME = 40;
+  int STRING = 41;
+  int IDENT = 42;
+  int NUMBER = 43;
+  int _URL = 44;
+  int URL = 45;
+  int PERCENTAGE = 46;
+  int LENGTH = 47;
+  int EMS = 48;
+  int EXS = 49;
+  int ANGLE = 50;
+  int TIME = 51;
+  int FREQ = 52;
+  int RESOLUTION = 53;
+  int DATE = 54;
+  int DIMEN = 55;
+  int HASH = 56;
+  int IMPORTANT_SYM = 57;
+  int IMPORT_SYM = 58;
+  int MEDIA_SYM = 59;
+  int PAGE_SYM = 60;
+  int FONT_FACE_SYM = 61;
+  int PREF_SYM = 62;
+  int COLOR_PROFILE = 63;
+  int CHARSET_SYM = 64;
+  int ATTOP = 65;
+  int ATRIGHT = 66;
+  int ATBOTTOM = 67;
+  int ATLEFT = 68;
+  int ATCOUNTER = 69;
+  int PHONETIC_ALPHABET_SYM = 70;
+  int ATKEYWORD = 71;
+  int RANGE0 = 72;
+  int RANGE1 = 73;
+  int RANGE2 = 74;
+  int RANGE3 = 75;
+  int RANGE4 = 76;
+  int RANGE5 = 77;
+  int RANGE6 = 78;
+  int RANGE = 79;
+  int UNI = 80;
+  int UNICODERANGE = 81;
+  int CLASS = 82;
+  int FUNCTION = 83;
 
   int DEFAULT = 0;
   int IN_COMMENT = 1;
 
   String[] tokenImage = {
     "<EOF>",
+    "\" \"",
     "<S>",
     "\"/*\"",
     "\"*/\"",
-    "<token of kind 4>",
+    "<token of kind 5>",
     "\"<!--\"",
     "\"-->\"",
     "\"{\"",
@@ -172,7 +173,6 @@
     "<UNICODERANGE>",
     "<CLASS>",
     "<FUNCTION>",
-    "<UNKNOWN>",
     "\"::\"",
   };
 

Index: CssParser.jj
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParser.jj,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- CssParser.jj	14 Sep 2005 15:14:18 -0000	1.17
+++ CssParser.jj	19 Apr 2006 11:28:05 -0000	1.18
@@ -10,7 +10,7 @@
 options {
     IGNORE_CASE  = true;
     STATIC = false;
-    /*    DEBUG_TOKEN_MANAGER = true;
+    /*DEBUG_TOKEN_MANAGER = true;
 	  DEBUG_PARSER = true; */
 	  
 }
@@ -119,6 +119,9 @@
 
     static StringBuffer SPACE = new StringBuffer(" ");
 
+    // to be able to remove a ruleset if the selector is not valid
+    protected boolean validSelector = true;
+
     /**
      * The ac for handling errors and warnings.
      * 
@@ -343,7 +346,8 @@
 <DEFAULT>
 TOKEN :
 {
-    < S : ( [ " ", "\t" , "\n" , "\r", "\f" ] )+ > 
+    < SPC_CHAR : " " >
+    |< S : ( [ "\t" , "\n" , "\r", "\f" ] )+ > 
          { image = CssParser.SPACE; }
 }
 
@@ -423,7 +427,7 @@
   | < #ESCAPE     : <UNICODE> | ( "\\" [ " "-"~","\200"-"\377" ] ) >
   | < #NMSTART    : [ "a"-"z", "_" ] | <NONASCII> | <ESCAPE> >
   | < #NMCHAR	  : ["a"-"z", "0"-"9", "-", "_"] | <NONASCII> | <ESCAPE> >
-  | < #STRINGCHAR : [ "\t"," ","!","#","$","%","&","("-"~" ] 
+  | < #STRINGCHAR : [ "\t"," ","!","#","$","%","&","("-"[","]"-"~" ] 
                     | "\\\n" | "\\\r\n" | <NONASCII> | <ESCAPE> >
   | < #D          : ["0"-"9"] >
   | < #NAME       : ( <NMCHAR> )+ >
@@ -434,11 +438,11 @@
 {
   < STRING      : ( "\"" ( <STRINGCHAR> | "'" )* "\"" ) | 
                   ( "'" ( <STRINGCHAR> | "\"" )* "'" ) >
-  | < IDENT         : <NMSTART> ( <NMCHAR> )* >
+  | < IDENT         : ( <MINUS> )? <NMSTART> ( <NMCHAR> )* >
   | < NUMBER	  : ( <D> )+ | ( <D> )* "." ( <D> )+ > 
   | < #_URL       : [ "!","#","$","%","&","*"-"~" ] | <NONASCII> | <ESCAPE> >
-  | < URL         : "url(" ( <S> )*
-                    ( <STRING> | ( <_URL> )* ) ( <S> )* ")" >            
+  | < URL         : "url(" ( ( <S> |<SPC_CHAR>) )*
+                    ( <STRING> | ( <_URL> )* ) ( ( <S> |<SPC_CHAR>) )* ")" >            
 }
 
 <DEFAULT>
@@ -473,7 +477,7 @@
 <DEFAULT>
 TOKEN :
 {
- < IMPORTANT_SYM : "!" ( <S> )? "important" >
+ < IMPORTANT_SYM : "!" ( ( <S> |<SPC_CHAR>) )? "important" >
 }
 
 /* RESERVED ATRULE WORDS */
@@ -486,7 +490,7 @@
   | < FONT_FACE_SYM: "@font-face" >
   | < PREF_SYM     : "@preference" >
   | < COLOR_PROFILE: "@color-profile" >
-  | < CHARSET_SYM  : "@charset" >
+  | < CHARSET_SYM  : "@charset" >         
   | < ATTOP	   : "@top" >
   | < ATRIGHT      : "@right" >
   | < ATBOTTOM     : "@bottom" >
@@ -525,11 +529,11 @@
  < FUNCTION : <IDENT> "(" >
 }
 
-<DEFAULT, IN_COMMENT>
-TOKEN :
-{ /* avoid token manager error */
-    < UNKNOWN : ~[] >
-}
+//<DEFAULT, IN_COMMENT>
+//TOKEN :
+//{ /* avoid token manager error */
+//   < UNKNOWN : ~[] >
+//}
 
 /*
  * The grammar of CSS2
@@ -544,22 +548,35 @@
 {}
 {
   ( charset() )?
-  ( <S> | ignoreStatement() )*
-  ( importDeclaration() ( ignoreStatement() ( <S> )* )* )*
+  ( <S> | <SPC_CHAR> | ignoreStatement() )*
+  ( importDeclaration() ( ignoreStatement() ( <S> | <SPC_CHAR> )* )* )*
   afterImportDeclaration()
   <EOF>
 }
 
 void charset() :
-{ Token n; }
+{
+    Token n = null;
+    Token charsetToken = null;
+}
 {  
-    try {
-	<CHARSET_SYM> ( <S> )* n=<STRING> ( <S> )* ";"
+    try {        
+        // @charset has a very specific syntax : 
+        // only one space allowed between @charset and the string 
+	charsetToken=<CHARSET_SYM> <SPC_CHAR> n=<STRING> ";"
+        //<CHARSET_SYM> n=<STRING> ";"
 	{
-	 	addCharSet(n.image);
+            // the @charset must be at the beginning of the document
+            if(charsetToken.beginLine != 1 || charsetToken.beginColumn != 1) {                     
+                throw new ParseException(
+                    ac.getMsg().getString("parser.charset"));                    
+            }
+            else {
+                addCharSet(n.image);                    
+            }
 	}
     } catch (Exception e) {
-        addError(e, skipStatement()); 
+        addError(e, charsetToken.image + " " + n.image + ";"); 
     }
 }
 
@@ -571,14 +588,22 @@
       | ret=skipStatement() 
       { if ((ret == null) || (ret.length() == 0)) {
 	    return; 
-        } else {
+        }
+        // quite ugly but necessary to avoid probably a lot of changes in the
+        // grammar, still having a beatiful error message
+        else if(ret.startsWith("@charset")) {
+            ParseException e = 
+		new ParseException(ac.getMsg().getString("parser.charset"));
+	    addError(e, ret);
+        }
+        else {
 	    ParseException e = 
 		new ParseException("Parse error - Unrecognized ");
 	    addError(e, ret);
         }
       }
      )
-    ( ignoreStatement() ( <S> )* )* )*
+    ( ignoreStatement() ( <S> | <SPC_CHAR> )* )* )*
 }
 
 void ignoreStatement() :
@@ -600,7 +625,7 @@
 }
 {
  try {
-  <IMPORT_SYM> ( <S> )*
+  <IMPORT_SYM> ( <S> | <SPC_CHAR> )*
        ( n=<STRING> {
 		     importFile = n.image.substring(1, n.image.length() -1);
        } 
@@ -614,11 +639,11 @@
 	     }
 	 }
 	 )
-       ( <S> )*
+       ( <S> | <SPC_CHAR> )*
        ( medium(media) 
-	 ( <COMMA> ( <S> )* medium(media) 
+	 ( <COMMA> ( <S> | <SPC_CHAR> )* medium(media) 
 	   )* )? ";"
-       ( <S> )*
+       ( <S> | <SPC_CHAR> )*
    { 
      handleImport(getURL(), importFile, media);
    } 
@@ -640,10 +665,10 @@
  }
 {
  try {
-  <MEDIA_SYM> ( <S> )* (n=<MEDIARESTRICTOR> { newRule.addMediaRestrictor(convertIdent(n.image), ac); } ( <S> )+)?
+  <MEDIA_SYM> ( <S> | <SPC_CHAR> )* (n=<MEDIARESTRICTOR> { newRule.addMediaRestrictor(convertIdent(n.image), ac); } ( <S> | <SPC_CHAR> )+)?
    medium(newRule) 
-   ( <COMMA> ( <S> )* medium(newRule) ( <S> )* )* 
-     (<AND> ( <S> )* <RPARAN> ( <S> )* p=mediadeclaration() { newRule.addMediaFeature(p); } ( <S> )* <LPARAN> ( <S> )* )*
+   ( <COMMA> ( <S> | <SPC_CHAR> )* medium(newRule) ( <S> | <SPC_CHAR> )* )* 
+     (<AND> ( <S> | <SPC_CHAR> )* <RPARAN> ( <S> | <SPC_CHAR> )* p=mediadeclaration() { newRule.addMediaFeature(p); } ( <S> | <SPC_CHAR> )* <LPARAN> ( <S> | <SPC_CHAR> )* )*
    
  {
 	String media = getAtRule().toString();
@@ -663,7 +688,7 @@
 	    newAtRule(getAtRule());	
         }
 }
-   <LBRACE> ( <S> )* ( ruleSet() )* <RBRACE> ( <S> )*
+   <LBRACE> ( <S> | <SPC_CHAR> )* ( ruleSet() )* <RBRACE> ( <S> | <SPC_CHAR> )*
 {
 	if (!ac.getCssVersion().equals("css1")) {
 	    endOfAtRule();
@@ -684,7 +709,7 @@
 void medium(AtRuleMedia media) : /* tv, projection, screen, ... */
 {Token n;}
 {
-  n=<IDENT> ( <S> )*
+  n=<IDENT> ( <S> | <SPC_CHAR> )*
   { try {
         media.addMedia(convertIdent(n.image), ac); 
     } catch (InvalidParamException e) {
@@ -710,14 +735,14 @@
 }
 {
  try {
-  <PAGE_SYM> ( <S> )* ( n=<IDENT> { newRule.setIdent(convertIdent(n.image)); } 
-			( <S> )* )?
+  <PAGE_SYM> ( <S> | <SPC_CHAR> )* ( n=<IDENT> { newRule.setIdent(convertIdent(n.image)); } 
+			( <S> | <SPC_CHAR> )* )?
 
-  ( pseudo_page(newRule) )? <LBRACE> ( <S> )* ( v=pageContent() 
+  ( pseudo_page(newRule) )? <LBRACE> ( <S> | <SPC_CHAR> )* ( v=pageContent() 
 	{ 
 		collectv = v;
 	}
- ) <RBRACE> ( <S> )*
+ ) <RBRACE> ( <S> | <SPC_CHAR> )*
    {
 	if (!ac.getCssVersion().equals("css1")) {
 	    newAtRule(getAtRule());
@@ -772,8 +797,8 @@
 }
 {
     try {
-        (n=<ATTOP> | n=<ATBOTTOM> | n=<ATLEFT> | n=<ATRIGHT> ) ( <S> )*
-        <LBRACE> ( <S> )* v=declarations() <RBRACE> ( <S> )* 
+        (n=<ATTOP> | n=<ATBOTTOM> | n=<ATLEFT> | n=<ATRIGHT> ) ( <S> | <SPC_CHAR> )*
+        <LBRACE> ( <S> | <SPC_CHAR> )* v=declarations() <RBRACE> ( <S> | <SPC_CHAR> )* 
 	{
 		return v;
 	}
@@ -785,7 +810,7 @@
 void pseudo_page(AtRulePage page) :
 { Token n; }
 {
-  ":" n=<IDENT> ( <S> )*
+  ":" n=<IDENT> ( <S> | <SPC_CHAR> )*
   { try {
         page.setName(":" + convertIdent(n.image), ac); 
     } catch (InvalidParamException e) {
@@ -806,7 +831,7 @@
 }
 {
  try {
-  <FONT_FACE_SYM> ( <S> )* 
+  <FONT_FACE_SYM> ( <S> | <SPC_CHAR> )* 
 {
 	if (ac.getCssVersion().equals("css1")) {
 	    skipStatement();
@@ -818,7 +843,7 @@
         }
 
 }
-  <LBRACE> ( <S> )* v=declarations() <RBRACE> ( <S> )*
+  <LBRACE> ( <S> | <SPC_CHAR> )* v=declarations() <RBRACE> ( <S> | <SPC_CHAR> )*
    {
 	if (!ac.getCssVersion().equals("css1")) {
             addProperty(v);
@@ -850,7 +875,7 @@
 }
 {
   try {
-    <COLOR_PROFILE> ( <S> )*
+    <COLOR_PROFILE> ( <S> | <SPC_CHAR> )*
 {
 	if (!ac.getCssVersion().equals("svg")) {
 	    skipStatement();
@@ -862,7 +887,7 @@
         }
 
 }
-    <LBRACE> ( <S> )* v=declarations() <RBRACE> ( <S> )*
+    <LBRACE> ( <S> | <SPC_CHAR> )* v=declarations() <RBRACE> ( <S> | <SPC_CHAR> )*
     {
 	if (ac.getCssVersion().equals("svg")) {
 	    addProperty(v);
@@ -897,7 +922,7 @@
 }
 {
   try {
-    <PREF_SYM> ( <S> )*
+    <PREF_SYM> ( <S> | <SPC_CHAR> )*
 {
 	if (ac.getCssVersion().equals("css1")) {
 	    skipStatement();
@@ -909,7 +934,7 @@
         }
 
 }
-    <LBRACE> ( <S> )* v=declarations() <RBRACE> ( <S> )*
+    <LBRACE> ( <S> | <SPC_CHAR> )* v=declarations() <RBRACE> ( <S> | <SPC_CHAR> )*
     {
 	if (!ac.getCssVersion().equals("css1")) {
 	    addProperty(v);
@@ -943,7 +968,7 @@
 }
 {
  try {
-   <PHONETIC_ALPHABET_SYM> ( <S> )* n=<STRING> ( <S> )* ";"
+   <PHONETIC_ALPHABET_SYM> ( <S> | <SPC_CHAR> )* n=<STRING> ( <S> | <SPC_CHAR> )* ";"
    {
 	if (!ac.getCssVersion().equals("css3")) {
 	    skipStatement();
@@ -988,8 +1013,8 @@
 void operator(CssExpression expr) :
 {}
 {
-  "/" ( <S> )* { if (expr.getCount() > 0) expr.setOperator('/'); }
-| "," ( <S> )* { if (expr.getCount() > 0) expr.setOperator(','); }
+  "/" ( <S> | <SPC_CHAR> )* { if (expr.getCount() > 0) expr.setOperator('/'); }
+| "," ( <S> | <SPC_CHAR> )* { if (expr.getCount() > 0) expr.setOperator(','); }
 }
 
 /**
@@ -1000,13 +1025,13 @@
 char connector = ' ';
 }
 {
-    "+" ( <S> )* {  return '+'; }
-  | ">" ( <S> )* { return '>'; }
-  | "~" ( <S> )* { return '~'; }
-  | <S>  ( ( "+" { connector = '+'; } 
+    "+" ( <S> | <SPC_CHAR> )* {  return '+'; }
+  | ">" ( <S> | <SPC_CHAR> )* { return '>'; }
+  | "~" ( <S> | <SPC_CHAR> )* { return '~'; }
+  | <S> | <SPC_CHAR>  ( ( "+" { connector = '+'; } 
            | ">" { connector = '>'; } 
 	   | "~" { connector = '~'; }) 
-  ( <S> )* )? { return connector; }
+  ( <S> | <SPC_CHAR> )* )? { return connector; }
 }
 
 /**
@@ -1025,7 +1050,7 @@
 String property() :
 {Token n; }
 {
-  n=<IDENT> ( <S> )* { currentProperty = convertIdent(n.image); 
+  n=<IDENT> ( <S> | <SPC_CHAR> )* { currentProperty = convertIdent(n.image); 
 		       return currentProperty; }
 }
 
@@ -1047,16 +1072,16 @@
        }
      }
    
-     ( <COMMA> ( <S> )*
+     ( <COMMA> ( <S> | <SPC_CHAR> )*
        contextual=selector()
        { if (contextual != null) {
           context_set.addElement(contextual); 
          }
        }  
      )*
-     <LBRACE> ( <S> )*
+     <LBRACE> ( <S> | <SPC_CHAR> )*     
      value_set=declarations()
-     <RBRACE> ( <S> )*
+     <RBRACE> ( <S> | <SPC_CHAR> )*
     {
       markRule = true;
 
@@ -1085,11 +1110,17 @@
 
 Vector declarations() :
 {
+    if(!validSelector) {        
+        validSelector = true;
+        skip_to_matching_brace();
+        return null;
+    }
+
   CssProperty values;
   Vector value_set   = new Vector();
   boolean wrong_value = true;
 }
-{
+{    
      ( values=declaration() 
        { if (values != null) {
 	   value_set.addElement(values);
@@ -1100,7 +1131,7 @@
          currentProperty = null;
        }
      )? 
-     ( ";" ( <S> )*
+     ( ";" ( <S> | <SPC_CHAR> )*
        ( values=declaration() 
 	{ if (values != null) {
 	   value_set.addElement(values);
@@ -1164,10 +1195,10 @@
                 //current.setConnector(comb); 
 	  }
 	 current=simple_selector(current) 
-	 )* ( <S> )*
+	 )* ( <S> | <SPC_CHAR> )*
    { return current; }
  }
- catch (InvalidParamException ie) {
+ catch (InvalidParamException ie) {    
      skipStatement();
      removeThisRule();
      ac.getFrame().addError(new CssError(ie));
@@ -1175,7 +1206,7 @@
      return null;
  }
  catch (ParseException e) {
-
+        validSelector = false;
 	if (ac.getProfile() != null) {
 	    if(!(ac.getProfile().equals("mobile"))) {
 	       Token t = getToken(1);
@@ -1217,7 +1248,7 @@
     CssSelectors current; }
 {
    current=simple_selector(null) 
-       ( ( <S> )+
+       ( ( <S> | <SPC_CHAR> )+
 	 current=simple_selector(current) 
 	 )*
    { return current; }
@@ -1377,20 +1408,20 @@
     int selectorType = CssSelectors.ATTRIBUTE_ANY;
 }
 {
-  "[" ( <S> )* att=<IDENT> ( <S> )*
+  "[" ( <S> | <SPC_CHAR> )* att=<IDENT> ( <S> | <SPC_CHAR> )*
       ( ("=" { selectorType = CssSelectors.ATTRIBUTE_EXACT; }
         | <INCLUDES> { selectorType = CssSelectors.ATTRIBUTE_ONE_OF; }
 	| <DASHMATCH> { selectorType = CssSelectors.ATTRIBUTE_BEGIN; }
 	| <PREFIXMATCH> { selectorType = CssSelectors.ATTRIBUTE_START; }
 	| <SUFFIXMATCH> { selectorType = CssSelectors.ATTRIBUTE_SUFFIX; }
 	| <SUBSTRINGMATCH> { selectorType = CssSelectors.ATTRIBUTE_SUBSTR; }
-	 ) ( <S> )* 
+	 ) ( <S> | <SPC_CHAR> )* 
 	 ( val=<IDENT> 
 	     { val.image = convertIdent(val.image); }
 	   | ( val=<STRING> 
 	       { val.image = convertStringIndex(val.image, 1, val.image.length() -1);} 
 			   ) 
-	   ( <S> )* ) )?
+	   ( <S> | <SPC_CHAR> )* ) )?
   "]"
       {
 	  if (selectorType == CssSelectors.ATTRIBUTE_ANY) {
@@ -1480,7 +1511,7 @@
 		     ac.getFrame().addError(new CssError(e));
 		}
  } )
-	| ( n=<FUNCTION> ( <S> )* (language=<NUMBER> | language=<IDENT> | language=<STRING> | param=simple_selector(null)) ( <S> )* ")"
+	| ( n=<FUNCTION> ( <S> | <SPC_CHAR> )* (language=<NUMBER> | language=<IDENT> | language=<STRING> | param=simple_selector(null)) ( <S> | <SPC_CHAR> )* ")"
 	    // :lang(en) is a very special case ...
 	    // since CSS3: contains(String), nth-of-type(n) and nth-child(n) and not(simple selector) too
 	    { 
@@ -1581,7 +1612,7 @@
 }
 {
 try {
-      string_property=property() (":" ( <S> )* 
+      string_property=property() (":" ( <S> | <SPC_CHAR> )* 
       values=expr() ( important=prio() )? )?
     {
 	
@@ -1628,7 +1659,7 @@
 }
 {
 try {
-     string_property=property() ":" ( <S> )* 
+     string_property=property() ":" ( <S> | <SPC_CHAR> )* 
       values=expr() ( important=prio() )?
     {
 	try {
@@ -1680,7 +1711,7 @@
 boolean prio() :
 {}
 {
-  <IMPORTANT_SYM> ( <S> )* { return true; }
+  <IMPORTANT_SYM> ( <S> | <SPC_CHAR> )* { return true; }
 }
 
 /**
@@ -1719,7 +1750,7 @@
     | n=<DIMEN> {  
 	addError(new ParseException("Unknown dimension"), n.image); }    
     | func=function() { setValue(func, exp, operator, null, FUNCTION); }
-      ) ( <S> )* )
+      ) ( <S> | <SPC_CHAR> )* )
   | (( n=<STRING> { setValue(new CssString(), exp, operator, n, STRING); }
     | n=<IDENT> 
     {
@@ -1753,7 +1784,7 @@
       }
     | n=<UNICODERANGE> { setValue(new CssUnicodeRange(), exp, operator, n, 
 				UNICODERANGE); }
-    ) ( <S> )* )
+    ) ( <S> | <SPC_CHAR> )* )
 }
 
 /**
@@ -1766,7 +1797,7 @@
  org.w3c.css.values.ATSCColor colorATSC = new org.w3c.css.values.ATSCColor();
 }
 {
-    n=<FUNCTION> ( <S> )* exp=expr() 
+    n=<FUNCTION> ( <S> | <SPC_CHAR> )* exp=expr() 
     ")" { 
 
 	if (n.image.toLowerCase().equals("rgb(")) {
@@ -1842,7 +1873,6 @@
 	getNextToken();
 	tok = getToken(1);
     }
-
     return s.toString().trim();
 }
 

Received on Wednesday, 19 April 2006 11:28:12 UTC