W3C home > Mailing lists > Public > www-validator-cvs@w3.org > April 2012

2002/css-validator/org/w3c/css/parser/analyzer CssParser.java,1.82,1.83 CssParser.jj,1.80,1.81 CssParserConstants.java,1.19,1.20 CssParserTokenManager.java,1.42,1.43

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 25 Apr 2012 20:21:55 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1SN8jJ-0006K3-B2@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/parser/analyzer
In directory hutz:/tmp/cvs-serv23918/w3c/css/parser/analyzer

Modified Files:
	CssParser.java CssParser.jj CssParserConstants.java 
	CssParserTokenManager.java 
Log Message:
Finished implementation of css3-background (background and borders)
* border is now a single item, instead of one per level
* able to parse all the positive tests, some negative ones will need some tuning
* Grammar modification to use the '/' between two numbers without matching a ratio 



Index: CssParserTokenManager.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParserTokenManager.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- CssParserTokenManager.java	3 Apr 2012 14:20:53 -0000	1.42
+++ CssParserTokenManager.java	25 Apr 2012 20:21:52 -0000	1.43
@@ -100,7 +100,7 @@
          return jjMoveNfa_0(7, 0);
       case 58:
          jjmatchedKind = 52;
-         return jjMoveStringLiteralDfa1_0(0x0L, 0x40000004L);
+         return jjMoveStringLiteralDfa1_0(0x0L, 0x20000002L);
       case 59:
          jjmatchedKind = 44;
          return jjMoveNfa_0(7, 0);
@@ -110,7 +110,7 @@
          jjmatchedKind = 42;
          return jjMoveNfa_0(7, 0);
[...6152 lines suppressed...]
@@ -6189,8 +6033,8 @@
    0x2L, 0x0L, 
 };
 protected SimpleCharStream input_stream;
-private final int[] jjrounds = new int[744];
-private final int[] jjstateSet = new int[1488];
+private final int[] jjrounds = new int[716];
+private final int[] jjstateSet = new int[1432];
 protected char curChar;
 /** Constructor. */
 public CssParserTokenManager(SimpleCharStream stream){
@@ -6217,7 +6061,7 @@
 {
    int i;
    jjround = 0x80000001;
-   for (i = 744; i-- > 0;)
+   for (i = 716; i-- > 0;)
       jjrounds[i] = 0x80000000;
 }
 

Index: CssParser.jj
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParser.jj,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- CssParser.jj	3 Apr 2012 14:20:53 -0000	1.80
+++ CssParser.jj	25 Apr 2012 20:21:52 -0000	1.81
@@ -1,4 +1,5 @@
 /* -*-java-extended-*-
+/* -*-java-extended-*-
  *
  * (c) COPYRIGHT MIT and INRIA, 1997.
  * Please first read the full copyright statement in file COPYRIGHT.html
@@ -542,7 +543,6 @@
   | < TIME       : <NUM> ( "ms" | "s" ) >
   | < FREQ       : <NUM> "Hz" | <NUM> "kHz" >
   | < RESOLUTION : <NUM> "dpi" | <NUM> "dpcm" >
-  | < RATIO      : <NUM> ( <_S> )* "/" ( <_S> )* <NUM> >
   | < DIMEN      : <NUM> <NMSTART> ( <NMCHAR> )* >
   | < PERCENTAGE : <NUM> "%" >
   | < NUMBER     : <NUM> >
@@ -916,6 +916,19 @@
     }
 }
 
+void ratio(CssExpression exp, char operator) :
+{
+Token w,h,n;
+}
+{
+
+   ( w=<NUMBER> ( <S> )* <DIV> ( <S> )* h=<NUMBER> ) {
+     StringBuilder sb = new StringBuilder();
+     sb.append(w.image).append('/').append(h.image);
+     n = Token.newToken(w.kind, sb.toString());
+     setValue(new CssRatio(), exp, operator, n, NUMBER);
+   }
+}
 
 void mediaquerylist(AtRuleMedia mediaRule) :
 {
@@ -961,7 +974,7 @@
        }
        mediaFeatureName = convertIdent(n.image); }
     ( <S> )*
-    ( <COLON> ( <S> )* val=expr() )?
+    ( <COLON> ( <S> )* val=mediaexpr() )?
     <LPARAN>  ( <S> )*  {
         MediaFeature mf = handleMediaFeature(mediaRule, mediaFeatureName, val);
         mediaRule.addMediaFeature(mf, ac);
@@ -2122,6 +2135,18 @@
 /**
  * @exception ParseException exception during the parse
  */
+CssExpression mediaexpr() :
+{
+  CssExpression values = new CssExpression();
+}
+{
+  mediaterm(values) ( operator(values) mediaterm(values) )*
+  { return values; }
+}
+
+/**
+ * @exception ParseException exception during the parse
+ */
 void term(CssExpression exp) :
 { Token n;
   char operator = ' ';
@@ -2139,7 +2164,6 @@
     | n=<TIME> { setValue(new CssTime(), exp, operator, n, TIME); }
     | n=<FREQ> { setValue(new CssFrequency(), exp, operator, n, FREQ); }
     | n=<RESOLUTION> { setValue(new CssResolution(), exp, operator, n, RESOLUTION); }
-    | n=<RATIO> { setValue(new CssRatio(), exp, operator, n, RATIO); }
     | n=<DIMEN> {
 	  addError(new ParseException(ac.getMsg().getString("parser.unknown-dimension")), n.image); }    
     | func=function() { setValue(func, exp, operator, null, FUNCTION); }
@@ -2184,6 +2208,67 @@
 /**
  * @exception ParseException exception during the parse
  */
+void mediaterm(CssExpression exp) :
+{ Token n;
+  char operator = ' ';
+  CssValue func;
+}
+{
+  ( ( operator=unaryOperator() )?
+    (  ( LOOKAHEAD( <NUMBER> ( <S> )* "/" ) ratio(exp, operator)
+      | n=<NUMBER> { setValue(new CssNumber(), exp, operator, n, NUMBER); }
+      )
+    | n=<PERCENTAGE> { setValue(new CssPercentage(), exp, operator, n,
+				PERCENTAGE); }
+    | n=<LENGTH> { setValue(new CssLength(), exp, operator, n, LENGTH); }
+    | n=<EMS> { setValue(new CssLength(), exp, operator, n, EMS); }
+    | n=<EXS> { setValue(new CssLength(), exp, operator, n, EXS); }
+    | n=<ANGLE> { setValue(new CssAngle(), exp, operator, n, ANGLE);}
+    | n=<TIME> { setValue(new CssTime(), exp, operator, n, TIME); }
+    | n=<FREQ> { setValue(new CssFrequency(), exp, operator, n, FREQ); }
+    | n=<RESOLUTION> { setValue(new CssResolution(), exp, operator, n, RESOLUTION); }
+    | n=<DIMEN> {
+	  addError(new ParseException(ac.getMsg().getString("parser.unknown-dimension")), n.image); }
+    | func=function() { setValue(func, exp, operator, null, FUNCTION); }
+      ) ( <S> )* )
+  | (( n=<STRING> { setValue(new CssString(), exp, operator, n, STRING); }
+    | n=<IDENT>
+    {
+	/*
+	 * Common error :
+	 * H1 {
+	 *   color : black
+	 *   background : white
+	 * }
+	 */
+	Token t = getToken(1);
+	Token semicolon = new Token();
+	semicolon.kind = SEMICOLON;
+	semicolon.image = ";";
+	if (t.kind == COLON) {
+	    /* @@SEEME. (generate a warning?) */
+	    /* @@SEEME if expression is a single ident,
+	       generate an error ? */
+	    addError(new ParseException(ac.getMsg().getString("parser.semi-colon")),
+		     (CssExpression) null);
+	    rejectToken(semicolon);
+	} else {
+	    setValue(new CssIdent(), exp, operator, n, IDENT);
+	}
+    }
+    | hexcolor(exp)
+    | n=<URL> {
+	CssURL _u = new CssURL();
+	_u.set(n.image, ac, url);
+	exp.addValue(_u);
+      }
+    | n=<UNICODERANGE> { setValue(new CssUnicodeRange(), exp, operator, n,
+				UNICODERANGE); }
+    ) ( <S> )* )
+}
+/**
+ * @exception ParseException exception during the parse
+ */
 CssValue function() :
 {Token n;
  CssExpression exp;

Index: CssParser.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParser.java,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- CssParser.java	3 Apr 2012 14:20:53 -0000	1.82
+++ CssParser.java	25 Apr 2012 20:21:52 -0000	1.83
@@ -617,7 +617,7 @@
       case PSEUDOELEMENT_SYM:
       case CLASS:
       case FUNCTIONNOT:
-      case 98:
+      case 97:
         ruleSet();
         break;
       case MEDIA_SYM:
@@ -966,7 +966,7 @@
         case PSEUDOELEMENT_SYM:
         case CLASS:
[...1947 lines suppressed...]
       if (la1tokens[i]) {
         jj_expentry = new int[1];
         jj_expentry[0] = i;
@@ -4119,7 +4389,7 @@
 
   private void jj_rescan_token() {
     jj_rescan = true;
-    for (int i = 0; i < 1; i++) {
+    for (int i = 0; i < 2; i++) {
     try {
       JJCalls p = jj_2_rtns[i];
       do {
@@ -4127,6 +4397,7 @@
           jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
           switch (i) {
             case 0: jj_3_1(); break;
+            case 1: jj_3_2(); break;
           }
         }
         p = p.next;

Index: CssParserConstants.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParserConstants.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- CssParserConstants.java	3 Apr 2012 14:20:53 -0000	1.19
+++ CssParserConstants.java	25 Apr 2012 20:21:52 -0000	1.20
@@ -131,79 +131,77 @@
   /** RegularExpression Id. */
   int RESOLUTION = 60;
   /** RegularExpression Id. */
-  int RATIO = 61;
-  /** RegularExpression Id. */
-  int DIMEN = 62;
+  int DIMEN = 61;
   /** RegularExpression Id. */
-  int PERCENTAGE = 63;
+  int PERCENTAGE = 62;
   /** RegularExpression Id. */
-  int NUMBER = 64;
+  int NUMBER = 63;
   /** RegularExpression Id. */
-  int IMPORTANT_SYM = 65;
+  int IMPORTANT_SYM = 64;
   /** RegularExpression Id. */
-  int PSEUDOELEMENT_SYM = 66;
+  int PSEUDOELEMENT_SYM = 65;
   /** RegularExpression Id. */
-  int CHARSET_SYM = 67;
+  int CHARSET_SYM = 66;
   /** RegularExpression Id. */
-  int IMPORT_SYM = 68;
+  int IMPORT_SYM = 67;
   /** RegularExpression Id. */
-  int NAMESPACE_SYM = 69;
+  int NAMESPACE_SYM = 68;
   /** RegularExpression Id. */
-  int MEDIA_SYM = 70;
+  int MEDIA_SYM = 69;
   /** RegularExpression Id. */
-  int PAGE_SYM = 71;
+  int PAGE_SYM = 70;
   /** RegularExpression Id. */
-  int FONT_FACE_SYM = 72;
+  int FONT_FACE_SYM = 71;
   /** RegularExpression Id. */
-  int PREF_SYM = 73;
+  int PREF_SYM = 72;
   /** RegularExpression Id. */
-  int COLOR_PROFILE = 74;
+  int COLOR_PROFILE = 73;
   /** RegularExpression Id. */
-  int ATTOP = 75;
+  int ATTOP = 74;
   /** RegularExpression Id. */
-  int ATRIGHT = 76;
+  int ATRIGHT = 75;
   /** RegularExpression Id. */
-  int ATBOTTOM = 77;
+  int ATBOTTOM = 76;
   /** RegularExpression Id. */
-  int ATLEFT = 78;
+  int ATLEFT = 77;
   /** RegularExpression Id. */
-  int ATCOUNTER = 79;
+  int ATCOUNTER = 78;
   /** RegularExpression Id. */
-  int PHONETIC_ALPHABET_SYM = 80;
+  int PHONETIC_ALPHABET_SYM = 79;
   /** RegularExpression Id. */
-  int ATKEYWORD = 81;
+  int ATKEYWORD = 80;
   /** RegularExpression Id. */
-  int RANGE0 = 82;
+  int RANGE0 = 81;
   /** RegularExpression Id. */
-  int RANGE1 = 83;
+  int RANGE1 = 82;
   /** RegularExpression Id. */
-  int RANGE2 = 84;
+  int RANGE2 = 83;
   /** RegularExpression Id. */
-  int RANGE3 = 85;
+  int RANGE3 = 84;
   /** RegularExpression Id. */
-  int RANGE4 = 86;
+  int RANGE4 = 85;
   /** RegularExpression Id. */
-  int RANGE5 = 87;
+  int RANGE5 = 86;
   /** RegularExpression Id. */
-  int RANGE6 = 88;
+  int RANGE6 = 87;
   /** RegularExpression Id. */
-  int RANGE = 89;
+  int RANGE = 88;
   /** RegularExpression Id. */
-  int UNI = 90;
+  int UNI = 89;
   /** RegularExpression Id. */
-  int UNICODERANGE = 91;
+  int UNICODERANGE = 90;
   /** RegularExpression Id. */
-  int CLASS = 92;
+  int CLASS = 91;
   /** RegularExpression Id. */
-  int FUNCTIONLANG = 93;
+  int FUNCTIONLANG = 92;
   /** RegularExpression Id. */
-  int FUNCTIONNOT = 94;
+  int FUNCTIONNOT = 93;
   /** RegularExpression Id. */
-  int FUNCTION = 95;
+  int FUNCTION = 94;
   /** RegularExpression Id. */
-  int HTMLSTARTTAG = 96;
+  int HTMLSTARTTAG = 95;
   /** RegularExpression Id. */
-  int HTMLENDTAG = 97;
+  int HTMLENDTAG = 96;
 
   /** Lexical state. */
   int DEFAULT = 0;
@@ -271,7 +269,6 @@
     "<TIME>",
     "<FREQ>",
     "<RESOLUTION>",
-    "<RATIO>",
     "<DIMEN>",
     "<PERCENTAGE>",
     "<NUMBER>",
Received on Wednesday, 25 April 2012 20:22:28 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:49 UTC