2002/css-validator/org/w3c/css/parser/analyzer CssParser.java,1.51,1.52 CssParser.jj,1.51,1.52

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

Modified Files:
	CssParser.java CssParser.jj 
Log Message:
Imports are now printed in the output
Namespace handling, they are now printed in the output, next step
is to add them to the context to be checked when a definition using them
matches.



Index: CssParser.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParser.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- CssParser.java	12 Feb 2009 21:26:35 -0000	1.51
+++ CssParser.java	13 Feb 2009 14:03:36 -0000	1.52
@@ -174,7 +174,18 @@
      * @param url  The style sheet where this import statement appears.
      * @param file the file name in the import
      */
-    public abstract void handleImport(URL url, String file, AtRuleMedia media);
+    public abstract void handleImport(URL url, String file,
+                                      boolean is_url, AtRuleMedia media);
+
+    /**
+     * Call by the namespace declaration statement.
+     *
+     * @param url  The style sheet where this namespace statement appears.
+     * @param file the file/url name in the namespace declaration
+     */
+    public abstract void handleNamespaceDeclaration(URL url, String prefix,
+                                                    String file,
+                                                    boolean is_url);
 
     /**
      * Call by the at-rule statement.
@@ -619,7 +630,12 @@
   }
 
   final public void namespaceDeclaration() throws ParseException {
-  Token n=null;
+    Token n=null;
+    Token v=null;
+    boolean is_url; /* for formatting */
+    String nsname;
+    String prefix = null;
+    CssValue val;
     jj_consume_token(NAMESPACE_SYM);
     label_10:
     while (true) {
@@ -636,6 +652,7 @@
     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
     case IDENT:
       n = jj_consume_token(IDENT);
+          prefix = convertIdent(n.image);
       label_11:
       while (true) {
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -655,10 +672,20 @@
     }
     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
     case STRING:
-      jj_consume_token(STRING);
+      v = jj_consume_token(STRING);
+              is_url = false;
+              nsname = v.image.substring(1, n.image.length() -1);
       break;
     case URL:
-      jj_consume_token(URL);
+      v = jj_consume_token(URL);
+              is_url = true;
+              val = new CssURL();
+              ((CssURL) val).set(v.image, ac, url);
+              nsname = (String) val.get();
+              if ((nsname.charAt(0) == '"')
+                  || (nsname.charAt(0) == '\'')) {
+                  nsname = nsname.substring(1, nsname.length()-1);
+              }
       break;
     default:
       jj_la1[16] = jj_gen;
@@ -693,8 +720,10 @@
         if (!ac.getCssVersion().equals("css3")) {
             addError(new InvalidParamException("at-rule", "@namespace", ac),
                      n.toString());
-        }
-        if (n != null) {
+        } else {
+            if (v != null) {
+                handleNamespaceDeclaration(getURL(), prefix, nsname, is_url);
+            }
         }
   }
 
@@ -708,6 +737,7 @@
     AtRuleMedia media = new AtRuleMedia();
     CssValue val;
     String importFile;
+    boolean is_url = false;
     try {
       jj_consume_token(IMPORT_SYM);
       label_14:
@@ -726,6 +756,7 @@
       case STRING:
         n = jj_consume_token(STRING);
                 importFile = n.image.substring(1, n.image.length() -1);
+                is_url = false;
         break;
       case URL:
         n = jj_consume_token(URL);
@@ -736,6 +767,7 @@
                     || (importFile.charAt(0) == '\'')) {
                     importFile = importFile.substring(1, importFile.length()-1);
                 }
+                is_url = true;
         break;
       default:
         jj_la1[20] = jj_gen;
@@ -800,7 +832,7 @@
         }
         jj_consume_token(S);
       }
-                handleImport(getURL(), importFile, media);
+                handleImport(getURL(), importFile, is_url, media);
     } catch (ParseException e) {
         addError(e, skipStatement());
     }
@@ -3573,14 +3605,6 @@
     finally { jj_save(0, xla); }
   }
 
-  final private boolean jj_3_1() {
-    Token xsp;
-    xsp = jj_scanpos;
-    if (jj_3R_83()) jj_scanpos = xsp;
-    if (jj_scan_token(98)) return true;
-    return false;
-  }
-
   final private boolean jj_3R_83() {
     Token xsp;
     xsp = jj_scanpos;
@@ -3591,6 +3615,14 @@
     return false;
   }
 
+  final private boolean jj_3_1() {
+    Token xsp;
+    xsp = jj_scanpos;
+    if (jj_3R_83()) jj_scanpos = xsp;
+    if (jj_scan_token(98)) return true;
+    return false;
+  }
+
   public CssParserTokenManager token_source;
   SimpleCharStream jj_input_stream;
   public Token token, jj_nt;

Index: CssParser.jj
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParser.jj,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- CssParser.jj	12 Feb 2009 21:26:35 -0000	1.51
+++ CssParser.jj	13 Feb 2009 14:03:36 -0000	1.52
@@ -193,7 +193,18 @@
      * @param url  The style sheet where this import statement appears.
      * @param file the file name in the import
      */  
-    public abstract void handleImport(URL url, String file, AtRuleMedia media);
+    public abstract void handleImport(URL url, String file, 
+				      boolean is_url, AtRuleMedia media);
+
+    /**
+     * Call by the namespace declaration statement.
+     *
+     * @param url  The style sheet where this namespace statement appears.
+     * @param file the file/url name in the namespace declaration
+     */  
+    public abstract void handleNamespaceDeclaration(URL url, String prefix,
+						    String file, 
+						    boolean is_url);
 
     /**
      * Call by the at-rule statement.
@@ -693,12 +704,37 @@
 }
 
 void namespaceDeclaration() :
-{ Token n=null;}
+{
+    Token n=null;
+    Token v=null;
+    boolean is_url; /* for formatting */
+    String nsname;
+    String prefix = null;
+    CssValue val;
+}
 {
     // FIXME add namespaces in context to match when a definition happens
     ( <NAMESPACE_SYM> 
       ( <S> )* 
-      ( n=<IDENT> ( <S> )* )? ( <STRING> | <URL> ) 
+      ( n=<IDENT> {
+	  prefix = convertIdent(n.image);
+      } 
+	  ( <S> )* )?
+      ( v=<STRING> { 
+	      is_url = false;
+	      nsname = v.image.substring(1, n.image.length() -1);
+	  } 
+	  | v=<URL> {
+	      is_url = true;
+	      val = new CssURL(); 
+	      ((CssURL) val).set(v.image, ac, url);
+	      nsname = (String) val.get();
+	      if ((nsname.charAt(0) == '"')
+		  || (nsname.charAt(0) == '\'')) {
+		  nsname = nsname.substring(1, nsname.length()-1);
+	      }
+	  }
+      ) 
       ( <S> )*
       <SEMICOLON> 
       ( <S> )*
@@ -706,8 +742,10 @@
 	if (!ac.getCssVersion().equals("css3")) {
 	    addError(new InvalidParamException("at-rule", "@namespace", ac),
 		     n.toString());
-	}
-	if (n != null) {
+	} else {
+	    if (v != null) {
+		handleNamespaceDeclaration(getURL(), prefix, nsname, is_url);
+	    }
 	}
     }
 }
@@ -721,12 +759,14 @@
     AtRuleMedia media = new AtRuleMedia();
     CssValue val; 
     String importFile;
+    boolean is_url = false;
 }
 {
     try {
 	<IMPORT_SYM> ( <S> )*
 	    ( n=<STRING> {
 		importFile = n.image.substring(1, n.image.length() -1);
+		is_url = false;
 	    } 
 	      | n=<URL> {
 		val = new CssURL(); 
@@ -736,6 +776,7 @@
 		    || (importFile.charAt(0) == '\'')) {
 		    importFile = importFile.substring(1, importFile.length()-1);
 		}
+		is_url = true;
 	    } 
 	    )
 	    ( <S> )*
@@ -744,7 +785,7 @@
 		)* )? <SEMICOLON> 
 	    ( <S> )*
 	    { 
-		handleImport(getURL(), importFile, media);
+		handleImport(getURL(), importFile, is_url, media);
 	    } 
     } catch (ParseException e) {
 	addError(e, skipStatement()); 

Received on Friday, 13 February 2009 14:03:47 UTC