KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > w3c > flute > parser > Parser


1 /* Generated By:JavaCC: Do not edit this line. Parser.java */
2 package org.w3c.flute.parser;
3
4 import java.io.*;
5 import java.net.*;
6 import java.util.Locale JavaDoc;
7
8
9 import org.w3c.css.sac.ConditionFactory;
10 import org.w3c.css.sac.Condition;
11 import org.w3c.css.sac.SelectorFactory;
12 import org.w3c.css.sac.SelectorList;
13 import org.w3c.css.sac.Selector;
14 import org.w3c.css.sac.SimpleSelector;
15 import org.w3c.css.sac.DocumentHandler;
16 import org.w3c.css.sac.InputSource;
17 import org.w3c.css.sac.ErrorHandler;
18 import org.w3c.css.sac.CSSException;
19 import org.w3c.css.sac.CSSParseException;
20 import org.w3c.css.sac.Locator;
21 import org.w3c.css.sac.LexicalUnit;
22
23 import org.w3c.flute.parser.selectors.SelectorFactoryImpl;
24 import org.w3c.flute.parser.selectors.ConditionFactoryImpl;
25
26 import org.w3c.flute.util.Encoding;
27
28 /**
29  * A CSS2 parser
30  *
31  * @author Philippe Le Hégaret
32  * @version $Revision: 1.1.1.1 $
33  */

34 public class Parser implements org.w3c.css.sac.Parser, ParserConstants {
35
36     // replaces all \t, \n, etc with this StringBuffer.
37
static final StringBuffer JavaDoc SPACE = new StringBuffer JavaDoc(" ");
38
39     // the document handler for the parser
40
protected DocumentHandler documentHandler;
41     // the error handler for the parser
42
protected ErrorHandler errorHandler;
43     // the input source for the parser
44
protected InputSource source;
45
46     protected ConditionFactory conditionFactory;
47     protected SelectorFactory selectorFactory;
48
49     // temporary place holder for pseudo-element ...
50
protected String JavaDoc pseudoElt;
51
52     /**
53      * Creates a new Parser
54      */

55     public Parser() {
56         this((CharStream) null);
57     }
58
59     /**
60      * @@TODO
61      * @exception CSSException Not yet implemented
62      */

63     public void setLocale(Locale JavaDoc locale) throws CSSException {
64         throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
65     }
66
67     /**
68      * Set the document handler for this parser
69      */

70     public void setDocumentHandler(DocumentHandler handler) {
71         this.documentHandler = handler;
72     }
73
74     public void setSelectorFactory(SelectorFactory selectorFactory) {
75         this.selectorFactory = selectorFactory;
76     }
77
78     public void setConditionFactory(ConditionFactory conditionFactory) {
79         this.conditionFactory = conditionFactory;
80     }
81
82     /**
83      * Set the error handler for this parser
84      */

85     public void setErrorHandler(ErrorHandler error) {
86         this.errorHandler = error;
87     }
88
89     /**
90      * Main parse methods
91      *
92      * @param source the source of the style sheet.
93      * @exception IOException the source can't be parsed.
94      * @exception CSSException the source is not CSS valid.
95      */

96     public void parseStyleSheet(InputSource source)
97             throws CSSException, IOException {
98         this.source = source;
99         ReInit(getCharStreamWithLurk(source));
100         if (selectorFactory == null) {
101             selectorFactory = new SelectorFactoryImpl();
102         }
103         if (conditionFactory == null) {
104             conditionFactory = new ConditionFactoryImpl();
105         }
106
107         parserUnit();
108     }
109
110     /**
111      * Convenient method for URIs.
112      *
113      * @param systemId the fully resolved URI of the style sheet.
114      * @exception IOException the source can't be parsed.
115      * @exception CSSException the source is not CSS valid.
116      */

117     public void parseStyleSheet(String JavaDoc systemId)
118             throws CSSException, IOException {
119         parseStyleSheet(new InputSource(systemId));
120     }
121
122     /**
123      * This method parses only one rule (style rule or at-rule, except @charset).
124      *
125      * @param source the source of the rule.
126      * @exception IOException the source can't be parsed.
127      * @exception CSSException the source is not CSS valid.
128      */

129     public void parseRule(InputSource source)
130             throws CSSException, IOException {
131         this.source = source;
132         ReInit(getCharStreamWithLurk(source));
133
134         if (selectorFactory == null) {
135             selectorFactory = new SelectorFactoryImpl();
136         }
137         if (conditionFactory == null) {
138             conditionFactory = new ConditionFactoryImpl();
139         }
140         _parseRule();
141     }
142
143     /**
144      * This method parses a style declaration (including the surrounding curly
145      * braces).
146      *
147      * @param source the source of the style declaration.
148      * @exception IOException the source can't be parsed.
149      * @exception CSSException the source is not CSS valid.
150      */

151     public void parseStyleDeclaration(InputSource source)
152             throws CSSException, IOException {
153         this.source = source;
154         ReInit(getCharStreamWithLurk(source));
155
156         if (selectorFactory == null) {
157             selectorFactory = new SelectorFactoryImpl();
158         }
159         if (conditionFactory == null) {
160             conditionFactory = new ConditionFactoryImpl();
161         }
162         _parseDeclarationBlock();
163     }
164
165     /**
166      * This methods returns "http://www.w3.org/TR/REC-CSS2".
167      * @return the string "http://www.w3.org/TR/REC-CSS2".
168      */

169     public String JavaDoc getParserVersion() {
170         return "http://www.w3.org/TR/REC-CSS2";
171     }
172
173     /**
174      * Parse methods used by DOM Level 2 implementation.
175      */

176     public void parseImportRule(InputSource source)
177             throws CSSException, IOException {
178         this.source = source;
179         ReInit(getCharStreamWithLurk(source));
180
181         if (selectorFactory == null) {
182             selectorFactory = new SelectorFactoryImpl();
183         }
184         if (conditionFactory == null) {
185             conditionFactory = new ConditionFactoryImpl();
186         }
187         _parseImportRule();
188     }
189
190     public void parseMediaRule(InputSource source)
191             throws CSSException, IOException {
192         this.source = source;
193         ReInit(getCharStreamWithLurk(source));
194
195         if (selectorFactory == null) {
196             selectorFactory = new SelectorFactoryImpl();
197         }
198         if (conditionFactory == null) {
199             conditionFactory = new ConditionFactoryImpl();
200         }
201         _parseMediaRule();
202     }
203
204     public SelectorList parseSelectors(InputSource source)
205             throws CSSException, IOException {
206         this.source = source;
207         ReInit(getCharStreamWithLurk(source));
208
209         if (selectorFactory == null) {
210             selectorFactory = new SelectorFactoryImpl();
211         }
212         if (conditionFactory == null) {
213             conditionFactory = new ConditionFactoryImpl();
214         }
215         return _parseSelectors();
216     }
217
218
219     public String JavaDoc parseNamespaceToken(InputSource source)
220             throws CSSException, IOException {
221         this.source = source;
222         ReInit(getCharStreamWithLurk(source));
223
224         if (selectorFactory == null) {
225             selectorFactory = new SelectorFactoryImpl();
226         }
227         if (conditionFactory == null) {
228             conditionFactory = new ConditionFactoryImpl();
229         }
230         return _parseNamespaceToken();
231     }
232
233     public LexicalUnit parsePropertyValue(InputSource source)
234             throws CSSException, IOException {
235         this.source = source;
236         ReInit(getCharStreamWithLurk(source));
237
238         return expr();
239     }
240
241     public boolean parsePriority(InputSource source)
242             throws CSSException, IOException {
243         this.source = source;
244         ReInit(getCharStreamWithLurk(source));
245
246         return prio();
247     }
248
249     /**
250      * Convert the source into a Reader. Used only by DOM Level 2 parser methods.
251      */

252     private Reader getReader(InputSource source) throws IOException {
253         if (source.getCharacterStream() != null) {
254             return source.getCharacterStream();
255         } else if (source.getByteStream() != null) {
256             // My DOM level 2 implementation doesn't use this case.
257
if (source.getEncoding() == null) {
258                 // unknown encoding, use ASCII as default.
259
return new InputStreamReader(source.getByteStream(), "ASCII");
260             } else {
261                 return new InputStreamReader(source.getByteStream(),
262                                              source.getEncoding());
263             }
264         } else {
265             // systemId
266
// @@TODO
267
throw new CSSException("not yet implemented");
268         }
269     }
270
271     /**
272      * Convert the source into a CharStream with encoding informations.
273      * The encoding can be found in the InputSource or in the CSS document.
274      * Since this method marks the reader and make a reset after looking for
275      * the charset declaration, you'll find the charset declaration into the
276      * stream.
277      */

278     private CharStream getCharStreamWithLurk(InputSource source)
279             throws CSSException, IOException {
280         if (source.getCharacterStream() != null) {
281             // all encoding are supposed to be resolved by the user
282
// return the reader
283
return new Generic_CharStream(source.getCharacterStream(), 1, 1);
284         } else if (source.getByteStream() == null) {
285             // @@CONTINUE ME. see also getReader() with systemId
286
try {
287                 source.setByteStream(new URL(source.getURI()).openStream());
288             } catch (Exception JavaDoc e) {
289                 try {
290                     source.setByteStream(new FileInputStream(source.getURI()));
291                 } catch (IOException ex) {
292                     throw new CSSException("invalid url ?");
293                 }
294             }
295         }
296         String JavaDoc encoding = "ASCII";
297         InputStream input = source.getByteStream();
298         char c = ' ';
299
300         if (!input.markSupported()) {
301             input = new BufferedInputStream(input);
302             source.setByteStream(input);
303         }
304         input.mark(100);
305         c = (char) input.read();
306
307         if (c == '@') {
308             // hum, is it a charset ?
309
int size = 100;
310             byte[] buf = new byte[size];
311             input.read(buf, 0, 7);
312             String JavaDoc keyword = new String JavaDoc(buf, 0, 7);
313             if (keyword.equals("charset")) {
314                 // Yes, this is the charset declaration !
315

316                 // here I don't use the right declaration : white space are ' '.
317
while ((c = (char) input.read()) == ' ') {
318                     // find the first quote
319
}
320                 char endChar = c;
321                 int i = 0;
322
323                 if ((endChar != '"') && (endChar != '\'')) {
324                     // hum this is not a quote.
325
throw new CSSException("invalid charset declaration");
326                 }
327
328                 while ((c = (char) input.read()) != endChar) {
329                     buf[i++] = (byte) c;
330                     if (i == size) {
331                         byte[] old = buf;
332                         buf = new byte[size + 100];
333                         System.arraycopy(old, 0, buf, 0, size);
334                         size += 100;
335                     }
336                 }
337                 while ((c = (char) input.read()) == ' ') {
338                     // find the next relevant character
339
}
340                 if (c != ';') {
341                     // no semi colon at the end ?
342
throw new CSSException("invalid charset declaration: "
343                                            + "missing semi colon");
344                 }
345                 encoding = new String JavaDoc(buf, 0, i);
346                 if (source.getEncoding() != null) {
347                     // compare the two encoding informations.
348
// For example, I don't accept to have ASCII and after UTF-8.
349
// Is it really good ? That is the question.
350
if (!encoding.equals(source.getEncoding())) {
351                         throw new CSSException("invalid encoding information.");
352                     }
353                 }
354             } // else no charset declaration available
355
}
356         // ok set the real encoding of this source.
357
source.setEncoding(encoding);
358         // set the real reader of this source.
359
source.setCharacterStream(new InputStreamReader(source.getByteStream(),
360                                              Encoding.getJavaEncoding(encoding)));
361         // reset the stream (leave the charset declaration in the stream).
362
input.reset();
363
364         return new Generic_CharStream(source.getCharacterStream(), 1, 1);
365     }
366
367     private LocatorImpl currentLocator;
368     private Locator getLocator() {
369         if (currentLocator == null) {
370             currentLocator = new LocatorImpl(this);
371             return currentLocator;
372         }
373         return currentLocator.reInit(this);
374     }
375     private LocatorImpl getLocator(Token save) {
376         if (currentLocator == null) {
377             currentLocator = new LocatorImpl(this, save);
378             return currentLocator;
379         }
380         return currentLocator.reInit(this, save);
381     }
382
383     private void reportError(Locator l, Exception JavaDoc e) {
384         if (errorHandler != null) {
385             if (e instanceof ParseException) {
386                 // construct a clean error message.
387
ParseException pe = (ParseException) e;
388                 if (pe.specialConstructor) {
389                     StringBuffer JavaDoc errorM = new StringBuffer JavaDoc();
390                     if (pe.currentToken != null) {
391                         errorM.append("encountered \"")
392                             .append(pe.currentToken.next);
393                     }
394                     errorM.append('"');
395                     if (pe.expectedTokenSequences.length != 0) {
396                         errorM.append(". Was expecting one of: ");
397                         for (int i = 0; i < pe.expectedTokenSequences.length; i++) {
398                             for (int j = 0; j < pe.expectedTokenSequences[i].length; j++) {
399                                 int kind = pe.expectedTokenSequences[i][j];
400                                 if (kind != S) {
401                                     errorM.append(pe.tokenImage[kind]);
402                                     errorM.append(' ');
403                                 }
404                             }
405                         }
406                     }
407                     errorHandler.error(new CSSParseException(errorM.toString(),
408                                                              l, e));
409                 } else {
410                     errorHandler.error(new CSSParseException(e.getMessage(),
411                                                              l, e));
412                 }
413             } else if (e == null) {
414                 errorHandler.error(new CSSParseException("error", l, null));
415             } else {
416                 errorHandler.error(new CSSParseException(e.getMessage(), l, e));
417             }
418         }
419     }
420
421     private void reportWarningSkipText(Locator l, String JavaDoc text) {
422         if (errorHandler != null && text != null) {
423             errorHandler.warning(new CSSParseException("Skipping: " + text, l));
424         }
425     }
426
427 /*
428  * The grammar of CSS2
429  */

430
431 /**
432  * The main entry for the parser.
433  *
434  * @exception ParseException exception during the parse
435  */

436   final public void parserUnit() throws ParseException {
437     try {
438           documentHandler.startDocument(source);
439       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
440       case CHARSET_SYM:
441         charset();
442         break;
443       default:
444         jj_la1[0] = jj_gen;
445         ;
446       }
447       label_1:
448       while (true) {
449         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
450         case S:
451         case CDO:
452         case CDC:
453         case ATKEYWORD:
454           ;
455           break;
456         default:
457           jj_la1[1] = jj_gen;
458           break label_1;
459         }
460         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
461         case S:
462           jj_consume_token(S);
463           break;
464         case CDO:
465         case CDC:
466         case ATKEYWORD:
467           ignoreStatement();
468           break;
469         default:
470           jj_la1[2] = jj_gen;
471           jj_consume_token(-1);
472           throw new ParseException();
473         }
474       }
475       label_2:
476       while (true) {
477         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
478         case IMPORT_SYM:
479           ;
480           break;
481         default:
482           jj_la1[3] = jj_gen;
483           break label_2;
484         }
485         importDeclaration();
486         label_3:
487         while (true) {
488           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
489           case CDO:
490           case CDC:
491           case ATKEYWORD:
492             ;
493             break;
494           default:
495             jj_la1[4] = jj_gen;
496             break label_3;
497           }
498           ignoreStatement();
499           label_4:
500           while (true) {
501             switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
502             case S:
503               ;
504               break;
505             default:
506               jj_la1[5] = jj_gen;
507               break label_4;
508             }
509             jj_consume_token(S);
510           }
511         }
512       }
513       label_5:
514       while (true) {
515         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
516         case NAMESPACE_SYM:
517           ;
518           break;
519         default:
520           jj_la1[6] = jj_gen;
521           break label_5;
522         }
523         namespaceDeclaration();
524         label_6:
525         while (true) {
526           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
527           case CDO:
528           case CDC:
529           case ATKEYWORD:
530             ;
531             break;
532           default:
533             jj_la1[7] = jj_gen;
534             break label_6;
535           }
536           ignoreStatement();
537           label_7:
538           while (true) {
539             switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
540             case S:
541               ;
542               break;
543             default:
544               jj_la1[8] = jj_gen;
545               break label_7;
546             }
547             jj_consume_token(S);
548           }
549         }
550       }
551       afterImportDeclaration();
552       jj_consume_token(0);
553     } finally {
554         documentHandler.endDocument(source);
555     }
556   }
557
558   final public void charset() throws ParseException {
559   Token n;
560     try {
561       jj_consume_token(CHARSET_SYM);
562       label_8:
563       while (true) {
564         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
565         case S:
566           ;
567           break;
568         default:
569           jj_la1[9] = jj_gen;
570           break label_8;
571         }
572         jj_consume_token(S);
573       }
574       n = jj_consume_token(STRING);
575       label_9:
576       while (true) {
577         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
578         case S:
579           ;
580           break;
581         default:
582           jj_la1[10] = jj_gen;
583           break label_9;
584         }
585         jj_consume_token(S);
586       }
587       jj_consume_token(SEMICOLON);
588     } catch (ParseException e) {
589         reportError(getLocator(e.currentToken.next), e);
590         skipStatement();
591         // reportWarningSkipText(getLocator(), skipStatement());
592

593     } catch (Exception JavaDoc e) {
594         reportError(getLocator(), e);
595         skipStatement();
596         // reportWarningSkipText(getLocator(), skipStatement());
597

598     }
599   }
600
601   final public void afterImportDeclaration() throws ParseException {
602  String JavaDoc ret;
603  Locator l;
604     label_10:
605     while (true) {
606       ;
607       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
608       case LBRACKET:
609       case ANY:
610       case DOT:
611       case COLON:
612       case IDENT:
613       case NAMESPACE_IDENT:
614       case HASH:
615         styleRule();
616         break;
617       case MEDIA_SYM:
618         media();
619         break;
620       case PAGE_SYM:
621         page();
622         break;
623       case FONT_FACE_SYM:
624         fontFace();
625         break;
626       default:
627         jj_la1[11] = jj_gen;
628           l = getLocator();
629         ret = skipStatement();
630           if ((ret == null) || (ret.length() == 0)) {
631               {if (true) return;}
632           }
633           reportWarningSkipText(l, ret);
634           if (ret.charAt(0) == '@') {
635               documentHandler.ignorableAtRule(ret);
636           }
637       }
638       label_11:
639       while (true) {
640         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
641         case CDO:
642         case CDC:
643         case ATKEYWORD:
644           ;
645           break;
646         default:
647           jj_la1[12] = jj_gen;
648           break label_11;
649         }
650         ignoreStatement();
651         label_12:
652         while (true) {
653           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
654           case S:
655             ;
656             break;
657           default:
658             jj_la1[13] = jj_gen;
659             break label_12;
660           }
661           jj_consume_token(S);
662         }
663       }
664     }
665   }
666
667   final public void ignoreStatement() throws ParseException {
668     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
669     case CDO:
670       jj_consume_token(CDO);
671       break;
672     case CDC:
673       jj_consume_token(CDC);
674       break;
675     case ATKEYWORD:
676       atRuleDeclaration();
677       break;
678     default:
679       jj_la1[14] = jj_gen;
680       jj_consume_token(-1);
681       throw new ParseException();
682     }
683   }
684
685 /**
686  * The import statement
687  *
688  * @exception ParseException exception during the parse
689  */

690   final public void importDeclaration() throws ParseException {
691  Token n;
692  String JavaDoc uri;
693  MediaListImpl ml = new MediaListImpl();
694     try {
695       jj_consume_token(IMPORT_SYM);
696       label_13:
697       while (true) {
698         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
699         case S:
700           ;
701           break;
702         default:
703           jj_la1[15] = jj_gen;
704           break label_13;
705         }
706         jj_consume_token(S);
707       }
708       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
709       case STRING:
710         n = jj_consume_token(STRING);
711                                uri = convertStringIndex(n.image, 1,
712                                                         n.image.length() -1);
713         break;
714       case URL:
715         n = jj_consume_token(URL);
716                uri = n.image.substring(4, n.image.length()-1).trim();
717                if ((uri.charAt(0) == '"')
718                    || (uri.charAt(0) == '\'')) {
719                    uri = uri.substring(1, uri.length()-1);
720                }
721         break;
722       default:
723         jj_la1[16] = jj_gen;
724         jj_consume_token(-1);
725         throw new ParseException();
726       }
727       label_14:
728       while (true) {
729         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
730         case S:
731           ;
732           break;
733         default:
734           jj_la1[17] = jj_gen;
735           break label_14;
736         }
737         jj_consume_token(S);
738       }
739       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
740       case IDENT:
741         mediaStatement(ml);
742         break;
743       default:
744         jj_la1[18] = jj_gen;
745         ;
746       }
747       jj_consume_token(SEMICOLON);
748       label_15:
749       while (true) {
750         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
751         case S:
752           ;
753           break;
754         default:
755           jj_la1[19] = jj_gen;
756           break label_15;
757         }
758         jj_consume_token(S);
759       }
760                if (ml.getLength() == 0) {
761                    // see section 6.3 of the CSS2 recommandation.
762
ml.addItem("all");
763                }
764                documentHandler.importStyle(uri, ml, null);
765     } catch (ParseException e) {
766      reportError(getLocator(), e);
767      skipStatement();
768      // reportWarningSkipText(getLocator(), skipStatement());
769

770     }
771   }
772
773 /**
774  * The namespace statement
775  *
776  * @exception ParseException exception during the parse
777  */

778   final public void namespaceDeclaration() throws ParseException {
779  Token n;
780  Token prefix = null;
781  String JavaDoc uri;
782     try {
783       jj_consume_token(NAMESPACE_SYM);
784       label_16:
785       while (true) {
786         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
787         case S:
788           ;
789           break;
790         default:
791           jj_la1[20] = jj_gen;
792           break label_16;
793         }
794         jj_consume_token(S);
795       }
796       prefix = jj_consume_token(IDENT);
797       label_17:
798       while (true) {
799         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
800         case S:
801           ;
802           break;
803         default:
804           jj_la1[21] = jj_gen;
805           break label_17;
806         }
807         jj_consume_token(S);
808       }
809       n = jj_consume_token(URL);
810               uri = n.image.substring(4, n.image.length()-1).trim();
811               if ((uri.charAt(0) == '"') || (uri.charAt(0) == '\''))
812               {
813                 uri = uri.substring(1, uri.length()-1);
814               }
815       jj_consume_token(SEMICOLON);
816       label_18:
817       while (true) {
818         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
819         case S:
820           ;
821           break;
822         default:
823           jj_la1[22] = jj_gen;
824           break label_18;
825         }
826         jj_consume_token(S);
827       }
828              if (prefix == null)
829              {
830                this.documentHandler.namespaceDeclaration("", uri);
831              }
832              else
833              {
834                this.documentHandler.namespaceDeclaration(prefix.image, uri);
835              }
836     } catch (ParseException e) {
837      reportError(getLocator(), e);
838      skipStatement();
839      // reportWarningSkipText(getLocator(), skipStatement());
840

841     }
842   }
843
844 /**
845  * @exception ParseException exception during the parse
846  */

847   final public void media() throws ParseException {
848     boolean start = false;
849     String JavaDoc ret;
850     MediaListImpl ml = new MediaListImpl();
851     try {
852       jj_consume_token(MEDIA_SYM);
853       label_19:
854       while (true) {
855         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
856         case S:
857           ;
858           break;
859         default:
860           jj_la1[23] = jj_gen;
861           break label_19;
862         }
863         jj_consume_token(S);
864       }
865       mediaStatement(ml);
866      start = true; documentHandler.startMedia(ml);
867       jj_consume_token(LBRACE);
868       label_20:
869       while (true) {
870         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
871         case S:
872           ;
873           break;
874         default:
875           jj_la1[24] = jj_gen;
876           break label_20;
877         }
878         jj_consume_token(S);
879       }
880       label_21:
881       while (true) {
882         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
883         case CDO:
884         case LBRACE:
885         case DASHMATCH:
886         case INCLUDES:
887         case PLUS:
888         case MINUS:
889         case COMMA:
890         case SEMICOLON:
891         case PRECEDES:
892         case LBRACKET:
893         case ANY:
894         case DOT:
895         case COLON:
896         case NONASCII:
897         case STRING:
898         case IDENT:
899         case NUMBER:
900         case URL:
901         case NAMESPACE_IDENT:
902         case PERCENTAGE:
903         case HASH:
904         case IMPORT_SYM:
905         case MEDIA_SYM:
906         case CHARSET_SYM:
907         case PAGE_SYM:
908         case FONT_FACE_SYM:
909         case ATKEYWORD:
910         case IMPORTANT_SYM:
911         case UNICODERANGE:
912         case FUNCTION:
913         case UNKNOWN:
914           ;
915           break;
916         default:
917           jj_la1[25] = jj_gen;
918           break label_21;
919         }
920         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
921         case LBRACKET:
922         case ANY:
923         case DOT:
924         case COLON:
925         case IDENT:
926         case NAMESPACE_IDENT:
927         case HASH:
928           styleRule();
929           break;
930         case CDO:
931         case LBRACE:
932         case DASHMATCH:
933         case INCLUDES:
934         case PLUS:
935         case MINUS:
936         case COMMA:
937         case SEMICOLON:
938         case PRECEDES:
939         case NONASCII:
940         case STRING:
941         case NUMBER:
942         case URL:
943         case PERCENTAGE:
944         case IMPORT_SYM:
945         case MEDIA_SYM:
946         case CHARSET_SYM:
947         case PAGE_SYM:
948         case FONT_FACE_SYM:
949         case ATKEYWORD:
950         case IMPORTANT_SYM:
951         case UNICODERANGE:
952         case FUNCTION:
953         case UNKNOWN:
954           skipUnknownRule();
955           break;
956         default:
957           jj_la1[26] = jj_gen;
958           jj_consume_token(-1);
959           throw new ParseException();
960         }
961       }
962       jj_consume_token(RBRACE);
963       label_22:
964       while (true) {
965         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
966         case S:
967           ;
968           break;
969         default:
970           jj_la1[27] = jj_gen;
971           break label_22;
972         }
973         jj_consume_token(S);
974       }
975     } catch (ParseException e) {
976      reportError(getLocator(), e);
977      skipStatement();
978      // reportWarningSkipText(getLocator(), skipStatement());
979

980     } finally {
981      if (start) {
982          documentHandler.endMedia(ml);
983      }
984     }
985   }
986
987   final public void mediaStatement(MediaListImpl ml) throws ParseException {
988     String JavaDoc m;
989     m = medium();
990     label_23:
991     while (true) {
992       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
993       case COMMA:
994         ;
995         break;
996       default:
997         jj_la1[28] = jj_gen;
998         break label_23;
999       }
1000      jj_consume_token(COMMA);
1001      label_24:
1002      while (true) {
1003        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1004        case S:
1005          ;
1006          break;
1007        default:
1008          jj_la1[29] = jj_gen;
1009          break label_24;
1010        }
1011        jj_consume_token(S);
1012      }
1013                                   ml.addItem(m);
1014      m = medium();
1015    }
1016     ml.addItem(m);
1017  }
1018
1019/**
1020 * @exception ParseException exception during the parse
1021 */

1022  final public String JavaDoc medium() throws ParseException {
1023 Token n;
1024    n = jj_consume_token(IDENT);
1025    label_25:
1026    while (true) {
1027      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1028      case S:
1029        ;
1030        break;
1031      default:
1032        jj_la1[30] = jj_gen;
1033        break label_25;
1034      }
1035      jj_consume_token(S);
1036    }
1037                         {if (true) return convertIdent(n.image);}
1038    throw new Error JavaDoc("Missing return statement in function");
1039  }
1040
1041/**
1042 * @exception ParseException exception during the parse
1043 */

1044  final public void page() throws ParseException {
1045 boolean start = false;
1046 Token n = null;
1047 String JavaDoc page = null;
1048 String JavaDoc pseudo = null;
1049    try {
1050      jj_consume_token(PAGE_SYM);
1051      label_26:
1052      while (true) {
1053        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1054        case S:
1055          ;
1056          break;
1057        default:
1058          jj_la1[31] = jj_gen;
1059          break label_26;
1060        }
1061        jj_consume_token(S);
1062      }
1063      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1064      case IDENT:
1065        n = jj_consume_token(IDENT);
1066        label_27:
1067        while (true) {
1068          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1069          case S:
1070            ;
1071            break;
1072          default:
1073            jj_la1[32] = jj_gen;
1074            break label_27;
1075          }
1076          jj_consume_token(S);
1077        }
1078        break;
1079      default:
1080        jj_la1[33] = jj_gen;
1081        ;
1082      }
1083      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1084      case COLON:
1085        pseudo = pseudo_page();
1086        break;
1087      default:
1088        jj_la1[34] = jj_gen;
1089        ;
1090      }
1091          if (n != null) {
1092              page = convertIdent(n.image);
1093          }
1094      jj_consume_token(LBRACE);
1095      label_28:
1096      while (true) {
1097        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1098        case S:
1099          ;
1100          break;
1101        default:
1102          jj_la1[35] = jj_gen;
1103          break label_28;
1104        }
1105        jj_consume_token(S);
1106      }
1107          start = true;
1108          documentHandler.startPage(page, pseudo);
1109      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1110      case IDENT:
1111        declaration();
1112        break;
1113      default:
1114        jj_la1[36] = jj_gen;
1115        ;
1116      }
1117      label_29:
1118      while (true) {
1119        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1120        case SEMICOLON:
1121          ;
1122          break;
1123        default:
1124          jj_la1[37] = jj_gen;
1125          break label_29;
1126        }
1127        jj_consume_token(SEMICOLON);
1128        label_30:
1129        while (true) {
1130          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1131          case S:
1132            ;
1133            break;
1134          default:
1135            jj_la1[38] = jj_gen;
1136            break label_30;
1137          }
1138          jj_consume_token(S);
1139        }
1140        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1141        case IDENT:
1142          declaration();
1143          break;
1144        default:
1145          jj_la1[39] = jj_gen;
1146          ;
1147        }
1148      }
1149      jj_consume_token(RBRACE);
1150      label_31:
1151      while (true) {
1152        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1153        case S:
1154          ;
1155          break;
1156        default:
1157          jj_la1[40] = jj_gen;
1158          break label_31;
1159        }
1160        jj_consume_token(S);
1161      }
1162    } catch (ParseException e) {
1163     if (errorHandler != null) {
1164         LocatorImpl li = new LocatorImpl(this,
1165                                          e.currentToken.next.beginLine,
1166                                          e.currentToken.next.beginColumn-1);
1167         reportError(li, e);
1168         skipStatement();
1169         // reportWarningSkipText(li, skipStatement());
1170
} else {
1171         skipStatement();
1172     }
1173    } finally {
1174     if (start) {
1175         documentHandler.endPage(page, pseudo);
1176     }
1177    }
1178  }
1179
1180  final public String JavaDoc pseudo_page() throws ParseException {
1181  Token n;
1182    jj_consume_token(COLON);
1183    n = jj_consume_token(IDENT);
1184    label_32:
1185    while (true) {
1186      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1187      case S:
1188        ;
1189        break;
1190      default:
1191        jj_la1[41] = jj_gen;
1192        break label_32;
1193      }
1194      jj_consume_token(S);
1195    }
1196                             {if (true) return convertIdent(n.image);}
1197    throw new Error JavaDoc("Missing return statement in function");
1198  }
1199
1200  final public void fontFace() throws ParseException {
1201    boolean start = false;
1202    try {
1203      jj_consume_token(FONT_FACE_SYM);
1204      label_33:
1205      while (true) {
1206        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1207        case S:
1208          ;
1209          break;
1210        default:
1211          jj_la1[42] = jj_gen;
1212          break label_33;
1213        }
1214        jj_consume_token(S);
1215      }
1216      jj_consume_token(LBRACE);
1217      label_34:
1218      while (true) {
1219        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1220        case S:
1221          ;
1222          break;
1223        default:
1224          jj_la1[43] = jj_gen;
1225          break label_34;
1226        }
1227        jj_consume_token(S);
1228      }
1229        start = true; documentHandler.startFontFace();
1230      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1231      case IDENT:
1232        declaration();
1233        break;
1234      default:
1235        jj_la1[44] = jj_gen;
1236        ;
1237      }
1238      label_35:
1239      while (true) {
1240        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1241        case SEMICOLON:
1242          ;
1243          break;
1244        default:
1245          jj_la1[45] = jj_gen;
1246          break label_35;
1247        }
1248        jj_consume_token(SEMICOLON);
1249        label_36:
1250        while (true) {
1251          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1252          case S:
1253            ;
1254            break;
1255          default:
1256            jj_la1[46] = jj_gen;
1257            break label_36;
1258          }
1259          jj_consume_token(S);
1260        }
1261        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1262        case IDENT:
1263          declaration();
1264          break;
1265        default:
1266          jj_la1[47] = jj_gen;
1267          ;
1268        }
1269      }
1270      jj_consume_token(RBRACE);
1271      label_37:
1272      while (true) {
1273        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1274        case S:
1275          ;
1276          break;
1277        default:
1278          jj_la1[48] = jj_gen;
1279          break label_37;
1280        }
1281        jj_consume_token(S);
1282      }
1283    } catch (ParseException e) {
1284     reportError(getLocator(), e);
1285     skipStatement();
1286     // reportWarningSkipText(getLocator(), skipStatement());
1287

1288    } finally {
1289     if (start) {
1290         documentHandler.endFontFace();
1291     }
1292    }
1293  }
1294
1295/**
1296 * @exception ParseException exception during the parse
1297 */

1298  final public void atRuleDeclaration() throws ParseException {
1299 Token n;
1300 String JavaDoc ret;
1301    n = jj_consume_token(ATKEYWORD);
1302        ret=skipStatement();
1303        reportWarningSkipText(getLocator(), ret);
1304        if ((ret != null) && (ret.charAt(0) == '@')) {
1305            documentHandler.ignorableAtRule(ret);
1306        }
1307  }
1308
1309  final public void skipUnknownRule() throws ParseException {
1310  Token n;
1311    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1312    case ATKEYWORD:
1313      n = jj_consume_token(ATKEYWORD);
1314      break;
1315    case CDO:
1316      n = jj_consume_token(CDO);
1317      break;
1318    case CHARSET_SYM:
1319      n = jj_consume_token(CHARSET_SYM);
1320      break;
1321    case COMMA:
1322      n = jj_consume_token(COMMA);
1323      break;
1324    case DASHMATCH:
1325      n = jj_consume_token(DASHMATCH);
1326      break;
1327    case FONT_FACE_SYM:
1328      n = jj_consume_token(FONT_FACE_SYM);
1329      break;
1330    case FUNCTION:
1331      n = jj_consume_token(FUNCTION);
1332      break;
1333    case IMPORTANT_SYM:
1334      n = jj_consume_token(IMPORTANT_SYM);
1335      break;
1336    case IMPORT_SYM:
1337      n = jj_consume_token(IMPORT_SYM);
1338      break;
1339    case INCLUDES:
1340      n = jj_consume_token(INCLUDES);
1341      break;
1342    case LBRACE:
1343      n = jj_consume_token(LBRACE);
1344      break;
1345    case MEDIA_SYM:
1346      n = jj_consume_token(MEDIA_SYM);
1347      break;
1348    case NONASCII:
1349      n = jj_consume_token(NONASCII);
1350      break;
1351    case NUMBER:
1352      n = jj_consume_token(NUMBER);
1353      break;
1354    case PAGE_SYM:
1355      n = jj_consume_token(PAGE_SYM);
1356      break;
1357    case PERCENTAGE:
1358      n = jj_consume_token(PERCENTAGE);
1359      break;
1360    case STRING:
1361      n = jj_consume_token(STRING);
1362      break;
1363    case UNICODERANGE:
1364      n = jj_consume_token(UNICODERANGE);
1365      break;
1366    case URL:
1367      n = jj_consume_token(URL);
1368      break;
1369    case SEMICOLON:
1370      n = jj_consume_token(SEMICOLON);
1371      break;
1372    case PLUS:
1373      n = jj_consume_token(PLUS);
1374      break;
1375    case PRECEDES:
1376      n = jj_consume_token(PRECEDES);
1377      break;
1378    case MINUS:
1379      n = jj_consume_token(MINUS);
1380      break;
1381    case UNKNOWN:
1382      n = jj_consume_token(UNKNOWN);
1383      break;
1384    default:
1385      jj_la1[49] = jj_gen;
1386      jj_consume_token(-1);
1387      throw new ParseException();
1388    }
1389     String JavaDoc ret;
1390     Locator loc = getLocator();
1391     ret=skipStatement();
1392     reportWarningSkipText(loc, ret);
1393     if ((ret != null) && (n.image.charAt(0) == '@')) {
1394         documentHandler.ignorableAtRule(ret);
1395     }
1396  }
1397
1398/**
1399 * @exception ParseException exception during the parse
1400 */

1401  final public char combinator() throws ParseException {
1402char connector = ' ';
1403    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1404    case PLUS:
1405      jj_consume_token(PLUS);
1406      label_38:
1407      while (true) {
1408        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1409        case S:
1410          ;
1411          break;
1412        default:
1413          jj_la1[50] = jj_gen;
1414          break label_38;
1415        }
1416        jj_consume_token(S);
1417      }
1418                   {if (true) return '+';}
1419      break;
1420    case PRECEDES:
1421      jj_consume_token(PRECEDES);
1422      label_39:
1423      while (true) {
1424        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1425        case S:
1426          ;
1427          break;
1428        default:
1429          jj_la1[51] = jj_gen;
1430          break label_39;
1431        }
1432        jj_consume_token(S);
1433      }
1434                     {if (true) return '>';}
1435      break;
1436    case S:
1437      jj_consume_token(S);
1438      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1439      case PLUS:
1440      case PRECEDES:
1441        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1442        case PLUS:
1443          jj_consume_token(PLUS);
1444                 connector = '+';
1445          break;
1446        case PRECEDES:
1447          jj_consume_token(PRECEDES);
1448                   connector = '>';
1449          break;
1450        default:
1451          jj_la1[52] = jj_gen;
1452          jj_consume_token(-1);
1453          throw new ParseException();
1454        }
1455        label_40:
1456        while (true) {
1457          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1458          case S:
1459            ;
1460            break;
1461          default:
1462            jj_la1[53] = jj_gen;
1463            break label_40;
1464          }
1465          jj_consume_token(S);
1466        }
1467        break;
1468      default:
1469        jj_la1[54] = jj_gen;
1470        ;
1471      }
1472               {if (true) return connector;}
1473      break;
1474    default:
1475      jj_la1[55] = jj_gen;
1476      jj_consume_token(-1);
1477      throw new ParseException();
1478    }
1479    throw new Error JavaDoc("Missing return statement in function");
1480  }
1481
1482/**
1483 * @exception ParseException exception during the parse
1484 */

1485  final public String JavaDoc property() throws ParseException {
1486 Token n;
1487    n = jj_consume_token(IDENT);
1488    label_41:
1489    while (true) {
1490      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1491      case S:
1492        ;
1493        break;
1494      default:
1495        jj_la1[56] = jj_gen;
1496        break label_41;
1497      }
1498      jj_consume_token(S);
1499    }
1500                         {if (true) return convertIdent(n.image);}
1501    throw new Error JavaDoc("Missing return statement in function");
1502  }
1503
1504/**
1505 * @exception ParseException exception during the parse
1506 */

1507  final public void styleRule() throws ParseException {
1508    boolean start = false;
1509    SelectorList l = null;
1510    Token save;
1511    Locator loc;
1512    try {
1513      l = selectorList();
1514                        save = token;
1515      jj_consume_token(LBRACE);
1516      label_42:
1517      while (true) {
1518        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1519        case S:
1520          ;
1521          break;
1522        default:
1523          jj_la1[57] = jj_gen;
1524          break label_42;
1525        }
1526        jj_consume_token(S);
1527      }
1528         start = true;
1529         documentHandler.startSelector(l);
1530      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1531      case IDENT:
1532        declaration();
1533        break;
1534      default:
1535        jj_la1[58] = jj_gen;
1536        ;
1537      }
1538      label_43:
1539      while (true) {
1540        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1541        case SEMICOLON:
1542          ;
1543          break;
1544        default:
1545          jj_la1[59] = jj_gen;
1546          break label_43;
1547        }
1548        jj_consume_token(SEMICOLON);
1549        label_44:
1550        while (true) {
1551          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1552          case S:
1553            ;
1554            break;
1555          default:
1556            jj_la1[60] = jj_gen;
1557            break label_44;
1558          }
1559          jj_consume_token(S);
1560        }
1561        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1562        case IDENT:
1563          declaration();
1564          break;
1565        default:
1566          jj_la1[61] = jj_gen;
1567          ;
1568        }
1569      }
1570      jj_consume_token(RBRACE);
1571      label_45:
1572      while (true) {
1573        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1574        case S:
1575          ;
1576          break;
1577        default:
1578          jj_la1[62] = jj_gen;
1579          break label_45;
1580        }
1581        jj_consume_token(S);
1582      }
1583    } catch (ThrowedParseException e) {
1584     if (errorHandler != null) {
1585         LocatorImpl li = new LocatorImpl(this,
1586                                          e.e.currentToken.next.beginLine,
1587                                          e.e.currentToken.next.beginColumn-1);
1588         reportError(li, e.e);
1589     }
1590    } catch (ParseException e) {
1591     reportError(getLocator(), e);
1592     skipStatement();
1593     // reportWarningSkipText(getLocator(), skipStatement());
1594

1595    } catch (TokenMgrError e) {
1596     reportWarningSkipText(getLocator(), skipStatement());
1597    } finally {
1598     if (start) {
1599         documentHandler.endSelector(l);
1600     }
1601    }
1602  }
1603
1604  final public SelectorList selectorList() throws ParseException {
1605    SelectorListImpl selectors = new SelectorListImpl();
1606    Selector selector;
1607    selector = selector();
1608    label_46:
1609    while (true) {
1610      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1611      case COMMA:
1612        ;
1613        break;
1614      default:
1615        jj_la1[63] = jj_gen;
1616        break label_46;
1617      }
1618      jj_consume_token(COMMA);
1619      label_47:
1620      while (true) {
1621        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1622        case S:
1623          ;
1624          break;
1625        default:
1626          jj_la1[64] = jj_gen;
1627          break label_47;
1628        }
1629        jj_consume_token(S);
1630      }
1631                                        selectors.addSelector(selector);
1632      selector = selector();
1633    }
1634    selectors.addSelector(selector);
1635    {if (true) return selectors;}
1636    throw new Error JavaDoc("Missing return statement in function");
1637  }
1638
1639/**
1640 * @exception ParseException exception during the parse
1641 */

1642  final public Selector selector() throws ParseException {
1643    Selector selector;
1644    char comb;
1645    try {
1646      selector = simple_selector(null, ' ');
1647      label_48:
1648      while (true) {
1649        if (jj_2_1(2)) {
1650          ;
1651        } else {
1652          break label_48;
1653        }
1654        comb = combinator();
1655        selector = simple_selector(selector, comb);
1656      }
1657      label_49:
1658      while (true) {
1659        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1660        case S:
1661          ;
1662          break;
1663        default:
1664          jj_la1[65] = jj_gen;
1665          break label_49;
1666        }
1667        jj_consume_token(S);
1668      }
1669       {if (true) return selector;}
1670    } catch (ParseException e) {
1671     /*
1672     Token t = getToken(1);
1673     StringBuffer s = new StringBuffer();
1674     s.append(getToken(0).image);
1675     while ((t.kind != COMMA) && (t.kind != SEMICOLON)
1676        && (t.kind != LBRACE) && (t.kind != EOF)) {
1677     s.append(t.image);
1678     getNextToken();
1679     t = getToken(1);
1680     }
1681     reportWarningSkipText(getLocator(), s.toString());
1682     */

1683     Token t = getToken(1);
1684     while ((t.kind != COMMA) && (t.kind != SEMICOLON)
1685            && (t.kind != LBRACE) && (t.kind != EOF)) {
1686         getNextToken();
1687         t = getToken(1);
1688     }
1689
1690     {if (true) throw new ThrowedParseException(e);}
1691    }
1692    throw new Error JavaDoc("Missing return statement in function");
1693  }
1694
1695/**
1696 * @exception ParseException exception during the parse
1697 */

1698  final public Selector simple_selector(Selector selector, char comb) throws ParseException {
1699    SimpleSelector simple_current = null;
1700    Condition cond = null;
1701
1702    pseudoElt = null;
1703    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1704    case ANY:
1705    case IDENT:
1706    case NAMESPACE_IDENT:
1707      simple_current = element_name();
1708      label_50:
1709      while (true) {
1710        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1711        case LBRACKET:
1712        case DOT:
1713        case COLON:
1714        case HASH:
1715          ;
1716          break;
1717        default:
1718          jj_la1[66] = jj_gen;
1719          break label_50;
1720        }
1721        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1722        case HASH:
1723          cond = hash(cond);
1724          break;
1725        case DOT:
1726          cond = _class(cond);
1727          break;
1728        case LBRACKET:
1729          cond = attrib(cond);
1730          break;
1731        case COLON:
1732          cond = pseudo(cond);
1733          break;
1734        default:
1735          jj_la1[67] = jj_gen;
1736          jj_consume_token(-1);
1737          throw new ParseException();
1738        }
1739      }
1740      break;
1741    case HASH:
1742      cond = hash(cond);
1743      label_51:
1744      while (true) {
1745        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1746        case LBRACKET:
1747        case DOT:
1748        case COLON:
1749          ;
1750          break;
1751        default:
1752          jj_la1[68] = jj_gen;
1753          break label_51;
1754        }
1755        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1756        case DOT:
1757          cond = _class(cond);
1758          break;
1759        case LBRACKET:
1760          cond = attrib(cond);
1761          break;
1762        case COLON:
1763          cond = pseudo(cond);
1764          break;
1765        default:
1766          jj_la1[69] = jj_gen;
1767          jj_consume_token(-1);
1768          throw new ParseException();
1769        }
1770      }
1771      break;
1772    case DOT:
1773      cond = _class(cond);
1774      label_52:
1775      while (true) {
1776        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1777        case LBRACKET:
1778        case DOT:
1779        case COLON:
1780        case HASH:
1781          ;
1782          break;
1783        default:
1784          jj_la1[70] = jj_gen;
1785          break label_52;
1786        }
1787        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1788        case HASH:
1789          cond = hash(cond);
1790          break;
1791        case DOT:
1792          cond = _class(cond);
1793          break;
1794        case LBRACKET:
1795          cond = attrib(cond);
1796          break;
1797        case COLON:
1798          cond = pseudo(cond);
1799          break;
1800        default:
1801          jj_la1[71] = jj_gen;
1802          jj_consume_token(-1);
1803          throw new ParseException();
1804        }
1805      }
1806      break;
1807    case COLON:
1808      cond = pseudo(cond);
1809      label_53:
1810      while (true) {
1811        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1812        case LBRACKET:
1813        case DOT:
1814        case COLON:
1815        case HASH:
1816          ;
1817          break;
1818        default:
1819          jj_la1[72] = jj_gen;
1820          break label_53;
1821        }
1822        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1823        case HASH:
1824          cond = hash(cond);
1825          break;
1826        case DOT:
1827          cond = _class(cond);
1828          break;
1829        case LBRACKET:
1830          cond = attrib(cond);
1831          break;
1832        case COLON:
1833          cond = pseudo(cond);
1834          break;
1835        default:
1836          jj_la1[73] = jj_gen;
1837          jj_consume_token(-1);
1838          throw new ParseException();
1839        }
1840      }
1841      break;
1842    case LBRACKET:
1843      cond = attrib(cond);
1844      label_54:
1845      while (true) {
1846        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1847        case LBRACKET:
1848        case DOT:
1849        case COLON:
1850        case HASH:
1851          ;
1852          break;
1853        default:
1854          jj_la1[74] = jj_gen;
1855          break label_54;
1856        }
1857        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1858        case HASH:
1859          cond = hash(cond);
1860          break;
1861        case DOT:
1862          cond = _class(cond);
1863          break;
1864        case LBRACKET:
1865          cond = attrib(cond);
1866          break;
1867        case COLON:
1868          cond = pseudo(cond);
1869          break;
1870        default:
1871          jj_la1[75] = jj_gen;
1872          jj_consume_token(-1);
1873          throw new ParseException();
1874        }
1875      }
1876      break;
1877    default:
1878      jj_la1[76] = jj_gen;
1879      jj_consume_token(-1);
1880      throw new ParseException();
1881    }
1882            if (simple_current == null) {
1883                simple_current = selectorFactory.createElementSelector(null, null);
1884            }
1885            if (cond != null) {
1886                simple_current = selectorFactory.createConditionalSelector(simple_current,
1887                                                                    cond);
1888            }
1889            if (selector != null) {
1890                switch (comb) {
1891                case ' ':
1892                    selector = selectorFactory.createDescendantSelector(selector,
1893                                                                       simple_current);
1894                    break;
1895                case '+':
1896                    selector =
1897                        selectorFactory.createDirectAdjacentSelector((short) 1,
1898                                                                     selector,
1899                                                                     simple_current);
1900                    break;
1901                case '>':
1902                    selector = selectorFactory.createChildSelector(selector,
1903                                                                  simple_current);
1904                    break;
1905                default:
1906                    {if (true) throw new ParseException("invalid state. send a bug report");}
1907                }
1908            } else {
1909                selector= simple_current;
1910            }
1911            if (pseudoElt != null) {
1912                selector = selectorFactory.createChildSelector(selector,
1913                             selectorFactory.createPseudoElementSelector(null, pseudoElt));
1914            }
1915            {if (true) return selector;}
1916    throw new Error JavaDoc("Missing return statement in function");
1917  }
1918
1919/**
1920 * @exception ParseException exception during the parse
1921 */

1922  final public Condition _class(Condition pred) throws ParseException {
1923 Token n;
1924Condition c;
1925    jj_consume_token(DOT);
1926    n = jj_consume_token(IDENT);
1927          c = conditionFactory.createClassCondition(null, n.image);
1928          if (pred == null) {
1929              {if (true) return c;}
1930          } else {
1931              {if (true) return conditionFactory.createAndCondition(pred, c);}
1932          }
1933    throw new Error JavaDoc("Missing return statement in function");
1934  }
1935
1936/**
1937 * @exception ParseException exception during the parse
1938 */

1939  final public SimpleSelector element_name() throws ParseException {
1940 Token n;
1941    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1942    case IDENT:
1943      n = jj_consume_token(IDENT);
1944      {if (true) return selectorFactory.createElementSelector(null, convertIdent(n.image));}
1945      break;
1946    case NAMESPACE_IDENT:
1947      n = jj_consume_token(NAMESPACE_IDENT);
1948      {if (true) return selectorFactory.createElementSelector(null, convertIdent(n.image));}
1949      break;
1950    case ANY:
1951      jj_consume_token(ANY);
1952      {if (true) return selectorFactory.createElementSelector(null, null);}
1953      break;
1954    default:
1955      jj_la1[77] = jj_gen;
1956      jj_consume_token(-1);
1957      throw new ParseException();
1958    }
1959    throw new Error JavaDoc("Missing return statement in function");
1960  }
1961
1962/**
1963 * @exception ParseException exception during the parse
1964 */

1965  final public Condition attrib(Condition pred) throws ParseException {
1966    int cases = 0;
1967    Token att = null;
1968    Token val = null;
1969    String JavaDoc attValue = null;
1970    jj_consume_token(LBRACKET);
1971    label_55:
1972    while (true) {
1973      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1974      case S:
1975        ;
1976        break;
1977      default:
1978        jj_la1[78] = jj_gen;
1979        break label_55;
1980      }
1981      jj_consume_token(S);
1982    }
1983    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1984    case IDENT:
1985      att = jj_consume_token(IDENT);
1986      break;
1987    case NAMESPACE_IDENT:
1988      att = jj_consume_token(NAMESPACE_IDENT);
1989      break;
1990    default:
1991      jj_la1[79] = jj_gen;
1992      jj_consume_token(-1);
1993      throw new ParseException();
1994    }
1995    label_56:
1996    while (true) {
1997      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1998      case S:
1999        ;
2000        break;
2001      default:
2002        jj_la1[80] = jj_gen;
2003        break label_56;
2004      }
2005      jj_consume_token(S);
2006    }
2007    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2008    case DASHMATCH:
2009    case INCLUDES:
2010    case EQ:
2011      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2012      case EQ:
2013        jj_consume_token(EQ);
2014            cases = 1;
2015        break;
2016      case INCLUDES:
2017        jj_consume_token(INCLUDES);
2018                    cases = 2;
2019        break;
2020      case DASHMATCH:
2021        jj_consume_token(DASHMATCH);
2022                    cases = 3;
2023        break;
2024      default:
2025        jj_la1[81] = jj_gen;
2026        jj_consume_token(-1);
2027        throw new ParseException();
2028      }
2029      label_57:
2030      while (true) {
2031        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2032        case S:
2033          ;
2034          break;
2035        default:
2036          jj_la1[82] = jj_gen;
2037          break label_57;
2038        }
2039        jj_consume_token(S);
2040      }
2041      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2042      case IDENT:
2043        val = jj_consume_token(IDENT);
2044                  attValue = val.image;
2045        break;
2046      case STRING:
2047        val = jj_consume_token(STRING);
2048                  attValue = convertStringIndex(val.image, 1, val.image.length() -1);
2049        break;
2050      default:
2051        jj_la1[83] = jj_gen;
2052        jj_consume_token(-1);
2053        throw new ParseException();
2054      }
2055      label_58:
2056      while (true) {
2057        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2058        case S:
2059          ;
2060          break;
2061        default:
2062          jj_la1[84] = jj_gen;
2063          break label_58;
2064        }
2065        jj_consume_token(S);
2066      }
2067      break;
2068    default:
2069      jj_la1[85] = jj_gen;
2070      ;
2071    }
2072    jj_consume_token(RBRACKET);
2073      String JavaDoc name = convertIdent(att.image);
2074      Condition c;
2075      switch (cases) {
2076          case 0:
2077          c = conditionFactory.createAttributeCondition(name, null, false, null);
2078          break;
2079          case 1:
2080          c = conditionFactory.createAttributeCondition(name, null, false,
2081                                                        attValue);
2082          break;
2083          case 2:
2084          c = conditionFactory.createOneOfAttributeCondition(name, null, false,
2085                                                             attValue);
2086          break;
2087          case 3:
2088          c = conditionFactory.createBeginHyphenAttributeCondition(name, null,
2089                                                                   false,
2090                                                                   attValue);
2091          break;
2092          default:
2093          // never reached.
2094
c = null;
2095      }
2096      if (pred == null) {
2097          {if (true) return c;}
2098      } else {
2099          {if (true) return conditionFactory.createAndCondition(pred, c);}
2100      }
2101    throw new Error JavaDoc("Missing return statement in function");
2102  }
2103
2104/**
2105 * @exception ParseException exception during the parse
2106 */

2107  final public Condition pseudo(Condition pred) throws ParseException {
2108 Token n;
2109Token language;
2110    jj_consume_token(COLON);
2111    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2112    case IDENT:
2113      n = jj_consume_token(IDENT);
2114            String JavaDoc s = convertIdent(n.image);
2115            if (s.equals("first-letter") || s.equals("first-line")) {
2116                if (pseudoElt != null) {
2117                    {if (true) throw new CSSParseException("duplicate pseudo element definition "
2118                                                + s, getLocator());}
2119                } else {
2120                    pseudoElt = s;
2121                    {if (true) return pred;}
2122                }
2123            } else {
2124                Condition c =
2125                conditionFactory.createPseudoClassCondition(null, s);
2126                if (pred == null) {
2127                    {if (true) return c;}
2128                } else {
2129                    {if (true) return conditionFactory.createAndCondition(pred, c);}
2130                }
2131            }
2132      break;
2133    case FUNCTION:
2134      n = jj_consume_token(FUNCTION);
2135      label_59:
2136      while (true) {
2137        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2138        case S:
2139          ;
2140          break;
2141        default:
2142          jj_la1[86] = jj_gen;
2143          break label_59;
2144        }
2145        jj_consume_token(S);
2146      }
2147      language = jj_consume_token(IDENT);
2148      label_60:
2149      while (true) {
2150        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2151        case S:
2152          ;
2153          break;
2154        default:
2155          jj_la1[87] = jj_gen;
2156          break label_60;
2157        }
2158        jj_consume_token(S);
2159      }
2160      jj_consume_token(LPARAN);
2161                  String JavaDoc f = convertIdent(n.image);
2162                  if (f.equals("lang(")) {
2163                      Condition d =
2164              conditionFactory.createLangCondition(convertIdent(language.image));
2165                      if (pred == null) {
2166                          {if (true) return d;}
2167                      } else {
2168                          {if (true) return conditionFactory.createAndCondition(pred, d);}
2169                      }
2170                  } else {
2171                      {if (true) throw new CSSParseException("invalid pseudo function name "
2172                                                  + f, getLocator());}
2173                  }
2174      break;
2175    default:
2176      jj_la1[88] = jj_gen;
2177      jj_consume_token(-1);
2178      throw new ParseException();
2179    }
2180    throw new Error JavaDoc("Missing return statement in function");
2181  }
2182
2183/**
2184 * @exception ParseException exception during the parse
2185 */

2186  final public Condition hash(Condition pred) throws ParseException {
2187 Token n;
2188    n = jj_consume_token(HASH);
2189      Condition d =
2190          conditionFactory.createIdCondition(n.image.substring(1));
2191      if (pred == null) {
2192          {if (true) return d;}
2193      } else {
2194          {if (true) return conditionFactory.createAndCondition(pred, d);}
2195      }
2196    throw new Error JavaDoc("Missing return statement in function");
2197  }
2198
2199/**
2200 * @exception ParseException exception during the parse
2201 */

2202  final public void declaration() throws ParseException {
2203  boolean important = false;
2204  String JavaDoc name;
2205  LexicalUnit exp;
2206  Token save;
2207    try {
2208      name = property();
2209       save = token;
2210      jj_consume_token(COLON);
2211      label_61:
2212      while (true) {
2213        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2214        case S:
2215          ;
2216          break;
2217        default:
2218          jj_la1[89] = jj_gen;
2219          break label_61;
2220        }
2221        jj_consume_token(S);
2222      }
2223      exp = expr();
2224      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2225      case IMPORTANT_SYM:
2226        important = prio();
2227        break;
2228      default:
2229        jj_la1[90] = jj_gen;
2230        ;
2231      }
2232         documentHandler.property(name, exp, important);
2233    } catch (JumpException e) {
2234     skipAfterExpression();
2235     // reportWarningSkipText(getLocator(), skipAfterExpression());
2236

2237    } catch (NumberFormatException JavaDoc e) {
2238     if (errorHandler != null) {
2239         errorHandler.error(new CSSParseException("Invalid number "
2240                                                  + e.getMessage(),
2241                                                  getLocator(),
2242                                                  e));
2243     }
2244     reportWarningSkipText(getLocator(), skipAfterExpression());
2245    } catch (ParseException e) {
2246     if (errorHandler != null) {
2247         if (e.currentToken != null) {
2248             LocatorImpl li = new LocatorImpl(this,
2249                                              e.currentToken.next.beginLine,
2250                                              e.currentToken.next.beginColumn-1);
2251             reportError(li, e);
2252         } else {
2253             reportError(getLocator(), e);
2254         }
2255         skipAfterExpression();
2256         /*
2257     LocatorImpl loc = (LocatorImpl) getLocator();
2258     loc.column--;
2259     reportWarningSkipText(loc, skipAfterExpression());
2260     */

2261     } else {
2262         skipAfterExpression();
2263     }
2264    }
2265  }
2266
2267/**
2268 * @exception ParseException exception during the parse
2269 */

2270  final public boolean prio() throws ParseException {
2271    jj_consume_token(IMPORTANT_SYM);
2272    label_62:
2273    while (true) {
2274      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2275      case S:
2276        ;
2277        break;
2278      default:
2279        jj_la1[91] = jj_gen;
2280        break label_62;
2281      }
2282      jj_consume_token(S);
2283    }
2284                             {if (true) return true;}
2285    throw new Error JavaDoc("Missing return statement in function");
2286  }
2287
2288/**
2289 * @exception ParseException exception during the parse
2290 */

2291  final public LexicalUnitImpl operator(LexicalUnitImpl prev) throws ParseException {
2292 Token n;
2293    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2294    case DIV:
2295      n = jj_consume_token(DIV);
2296      label_63:
2297      while (true) {
2298        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2299        case S:
2300          ;
2301          break;
2302        default:
2303          jj_la1[92] = jj_gen;
2304          break label_63;
2305        }
2306        jj_consume_token(S);
2307      }
2308                 {if (true) return LexicalUnitImpl.createSlash(n.beginLine,
2309                                                       n.beginColumn,
2310                                                       prev);}
2311      break;
2312    case COMMA:
2313      n = jj_consume_token(COMMA);
2314      label_64:
2315      while (true) {
2316        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2317        case S:
2318          ;
2319          break;
2320        default:
2321          jj_la1[93] = jj_gen;
2322          break label_64;
2323        }
2324        jj_consume_token(S);
2325      }
2326                   {if (true) return LexicalUnitImpl.createComma(n.beginLine,
2327                                                         n.beginColumn,
2328                                                         prev);}
2329      break;
2330    default:
2331      jj_la1[94] = jj_gen;
2332      jj_consume_token(-1);
2333      throw new ParseException();
2334    }
2335    throw new Error JavaDoc("Missing return statement in function");
2336  }
2337
2338/**
2339 * @exception ParseException exception during the parse
2340 */

2341  final public LexicalUnit expr() throws ParseException {
2342    LexicalUnitImpl first, res;
2343    char op;
2344    first = term(null);
2345                       res = first;
2346    label_65:
2347    while (true) {
2348      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2349      case PLUS:
2350      case MINUS:
2351      case COMMA:
2352      case DIV:
2353      case STRING:
2354      case IDENT:
2355      case NUMBER:
2356      case URL:
2357      case NAMESPACE_IDENT:
2358      case PERCENTAGE:
2359      case PT:
2360      case MM:
2361      case CM:
2362      case PC:
2363      case IN:
2364      case PX:
2365      case EMS:
2366      case EXS:
2367      case DEG:
2368      case RAD:
2369      case GRAD:
2370      case MS:
2371      case SECOND:
2372      case HZ:
2373      case KHZ:
2374      case DIMEN:
2375      case HASH:
2376      case UNICODERANGE:
2377      case FUNCTION:
2378        ;
2379        break;
2380      default:
2381        jj_la1[95] = jj_gen;
2382        break label_65;
2383      }
2384      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2385      case COMMA:
2386      case DIV:
2387        res = operator(res);
2388        break;
2389      default:
2390        jj_la1[96] = jj_gen;
2391        ;
2392      }
2393      res = term(res);
2394    }
2395    {if (true) return first;}
2396    throw new Error JavaDoc("Missing return statement in function");
2397  }
2398
2399/**
2400 * @exception ParseException exception during the parse
2401 */

2402  final public char unaryOperator() throws ParseException {
2403    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2404    case MINUS:
2405      jj_consume_token(MINUS);
2406        {if (true) return '-';}
2407      break;
2408    case PLUS:
2409      jj_consume_token(PLUS);
2410        {if (true) return '+';}
2411      break;
2412    default:
2413      jj_la1[97] = jj_gen;
2414      jj_consume_token(-1);
2415      throw new ParseException();
2416    }
2417    throw new Error JavaDoc("Missing return statement in function");
2418  }
2419
2420/**
2421 * @exception ParseException exception during the parse
2422 */

2423  final public LexicalUnitImpl term(LexicalUnitImpl prev) throws ParseException {
2424  LexicalUnitImpl result = null;
2425  Token n = null;
2426  char op = ' ';
2427    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2428    case PLUS:
2429    case MINUS:
2430    case NUMBER:
2431    case PERCENTAGE:
2432    case PT:
2433    case MM:
2434    case CM:
2435    case PC:
2436    case IN:
2437    case PX:
2438    case EMS:
2439    case EXS:
2440    case DEG:
2441    case RAD:
2442    case GRAD:
2443    case MS:
2444    case SECOND:
2445    case HZ:
2446    case KHZ:
2447    case DIMEN:
2448    case FUNCTION:
2449      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2450      case PLUS:
2451      case MINUS:
2452        op = unaryOperator();
2453        break;
2454      default:
2455        jj_la1[98] = jj_gen;
2456        ;
2457      }
2458      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2459      case NUMBER:
2460        n = jj_consume_token(NUMBER);
2461          result = LexicalUnitImpl.createNumber(n.beginLine, n.beginColumn,
2462                                                prev, number(op, n, 0));
2463        break;
2464      case PERCENTAGE:
2465        n = jj_consume_token(PERCENTAGE);
2466          result = LexicalUnitImpl.createPercentage(n.beginLine, n.beginColumn,
2467                                                    prev, number(op, n, 1));
2468        break;
2469      case PT:
2470        n = jj_consume_token(PT);
2471          result = LexicalUnitImpl.createPT(n.beginLine, n.beginColumn,
2472                                            prev, number(op, n, 2));
2473        break;
2474      case CM:
2475        n = jj_consume_token(CM);
2476          result = LexicalUnitImpl.createCM(n.beginLine, n.beginColumn,
2477                                            prev, number(op, n, 2));
2478        break;
2479      case MM:
2480        n = jj_consume_token(MM);
2481          result = LexicalUnitImpl.createMM(n.beginLine, n.beginColumn,
2482                                            prev, number(op, n, 2));
2483        break;
2484      case PC:
2485        n = jj_consume_token(PC);
2486          result = LexicalUnitImpl.createPC(n.beginLine, n.beginColumn,
2487                                            prev, number(op, n, 2));
2488        break;
2489      case IN:
2490        n = jj_consume_token(IN);
2491          result = LexicalUnitImpl.createIN(n.beginLine, n.beginColumn,
2492                                            prev, number(op, n, 2));
2493        break;
2494      case PX:
2495        n = jj_consume_token(PX);
2496          result = LexicalUnitImpl.createPX(n.beginLine, n.beginColumn,
2497                                            prev, number(op, n, 2));
2498        break;
2499      case EMS:
2500        n = jj_consume_token(EMS);
2501          result = LexicalUnitImpl.createEMS(n.beginLine, n.beginColumn,
2502                                             prev, number(op, n, 2));
2503        break;
2504      case EXS:
2505        n = jj_consume_token(EXS);
2506          result = LexicalUnitImpl.createEXS(n.beginLine, n.beginColumn,
2507                                             prev, number(op, n, 2));
2508        break;
2509      case DEG:
2510        n = jj_consume_token(DEG);
2511          result = LexicalUnitImpl.createDEG(n.beginLine, n.beginColumn,
2512                                             prev, number(op, n, 3));
2513        break;
2514      case RAD:
2515        n = jj_consume_token(RAD);
2516          result = LexicalUnitImpl.createRAD(n.beginLine, n.beginColumn,
2517                                             prev, number(op, n, 3));
2518        break;
2519      case GRAD:
2520        n = jj_consume_token(GRAD);
2521          result = LexicalUnitImpl.createGRAD(n.beginLine, n.beginColumn,
2522                                              prev, number(op, n, 3));
2523        break;
2524      case SECOND:
2525        n = jj_consume_token(SECOND);
2526          result = LexicalUnitImpl.createS(n.beginLine, n.beginColumn,
2527                                           prev, number(op, n, 1));
2528        break;
2529      case MS:
2530        n = jj_consume_token(MS);
2531          result = LexicalUnitImpl.createMS(n.beginLine, n.beginColumn,
2532                                            prev, number(op, n, 2));
2533        break;
2534      case HZ:
2535        n = jj_consume_token(HZ);
2536          result = LexicalUnitImpl.createHZ(n.beginLine, n.beginColumn,
2537                                            prev, number(op, n, 2));
2538        break;
2539      case KHZ:
2540        n = jj_consume_token(KHZ);
2541          result = LexicalUnitImpl.createKHZ(n.beginLine, n.beginColumn,
2542                                             prev, number(op, n, 3));
2543        break;
2544      case DIMEN:
2545        n = jj_consume_token(DIMEN);
2546            String JavaDoc s = n.image;
2547            int i = 0;
2548            while (i < s.length()
2549                   && (Character.isDigit(s.charAt(i)) || (s.charAt(i) == '.'))) {
2550                i++;
2551            }
2552            result = LexicalUnitImpl.createDimen(n.beginLine, n.beginColumn, prev,
2553                                                 Float.valueOf(s.substring(0, i)).floatValue(),
2554                                                 s.substring(i));
2555        break;
2556      case FUNCTION:
2557        result = function(op, prev);
2558        break;
2559      default:
2560        jj_la1[99] = jj_gen;
2561        jj_consume_token(-1);
2562        throw new ParseException();
2563      }
2564      break;
2565    case STRING:
2566    case IDENT:
2567    case URL:
2568    case NAMESPACE_IDENT:
2569    case HASH:
2570    case UNICODERANGE:
2571      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2572      case STRING:
2573        n = jj_consume_token(STRING);
2574              result = LexicalUnitImpl.createString
2575                              (n.beginLine, n.beginColumn, prev,
2576                                                 convertStringIndex(n.image, 1,
2577                                                                   n.image.length() -1));
2578        break;
2579      case NAMESPACE_IDENT:
2580        n = jj_consume_token(NAMESPACE_IDENT);
2581        result = LexicalUnitImpl.createIdent
2582                  (n.beginLine, n.beginColumn, prev, convertIdent(n.image));
2583        break;
2584      case IDENT:
2585        n = jj_consume_token(IDENT);
2586        String JavaDoc s = convertIdent(n.image);
2587              if ("inherit".equals(s))
2588              {
2589                result = LexicalUnitImpl.createInherit
2590                          (n.beginLine, n.beginColumn, prev);
2591              }
2592              else
2593              {
2594                result = LexicalUnitImpl.createIdent
2595                          (n.beginLine, n.beginColumn, prev, s);
2596              }
2597
2598          /* /
2599         Auto correction code used in the CSS Validator but must not
2600          be used by a conformant CSS2 parser.
2601     * Common error :
2602     * H1 {
2603     * color : black
2604     * background : white
2605     * }
2606     *
2607    Token t = getToken(1);
2608    Token semicolon = new Token();
2609    semicolon.kind = SEMICOLON;
2610    semicolon.image = ";";
2611    if (t.kind == COLON) {
2612        // @@SEEME. (generate a warning?)
2613        // @@SEEME if expression is a single ident,
2614           generate an error ?
2615        rejectToken(semicolon);
2616        
2617        result = prev;
2618    }
2619    / */

2620
2621        break;
2622      case HASH:
2623        result = hexcolor(prev);
2624        break;
2625      case URL:
2626        result = url(prev);
2627        break;
2628      case UNICODERANGE:
2629        result = unicode(prev);
2630        break;
2631      default:
2632        jj_la1[100] = jj_gen;
2633        jj_consume_token(-1);
2634        throw new ParseException();
2635      }
2636      break;
2637    default:
2638      jj_la1[101] = jj_gen;
2639      jj_consume_token(-1);
2640      throw new ParseException();
2641    }
2642    label_66:
2643    while (true) {
2644      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2645      case S:
2646        ;
2647        break;
2648      default:
2649        jj_la1[102] = jj_gen;
2650        break label_66;
2651      }
2652      jj_consume_token(S);
2653    }
2654          {if (true) return result;}
2655    throw new Error JavaDoc("Missing return statement in function");
2656  }
2657
2658/**
2659 * Handle all CSS2 functions.
2660 * @exception ParseException exception during the parse
2661 */

2662  final public LexicalUnitImpl function(char operator, LexicalUnitImpl prev) throws ParseException {
2663 Token n;
2664 LexicalUnit params = null;
2665    n = jj_consume_token(FUNCTION);
2666    label_67:
2667    while (true) {
2668      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2669      case S:
2670        ;
2671        break;
2672      default:
2673        jj_la1[103] = jj_gen;
2674        break label_67;
2675      }
2676      jj_consume_token(S);
2677    }
2678    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2679    case PLUS:
2680    case MINUS:
2681    case STRING:
2682    case IDENT:
2683    case NUMBER:
2684    case URL:
2685    case NAMESPACE_IDENT:
2686    case PERCENTAGE:
2687    case PT:
2688    case MM:
2689    case CM:
2690    case PC:
2691    case IN:
2692    case PX:
2693    case EMS:
2694    case EXS:
2695    case DEG:
2696    case RAD:
2697    case GRAD:
2698    case MS:
2699    case SECOND:
2700    case HZ:
2701    case KHZ:
2702    case DIMEN:
2703    case HASH:
2704    case UNICODERANGE:
2705    case FUNCTION:
2706      params = expr();
2707      break;
2708    default:
2709      jj_la1[104] = jj_gen;
2710      ;
2711    }
2712    jj_consume_token(LPARAN);
2713        if (operator != ' ') {
2714            {if (true) throw new CSSParseException("invalid operator before a function.",
2715                                        getLocator());}
2716        }
2717        String JavaDoc f = convertIdent(n.image);
2718        LexicalUnitImpl l = (LexicalUnitImpl) params;
2719        boolean loop = true;
2720        if ("rgb(".equals(f)) {
2721            // this is a RGB declaration (e.g. rgb(255, 50%, 0) )
2722
int i = 0;
2723            while (loop && l != null && i < 5) {
2724                switch (i) {
2725                    case 0:
2726                    case 2:
2727                    case 4:
2728                        if ((l.getLexicalUnitType() != LexicalUnit.SAC_INTEGER)
2729                            && (l.getLexicalUnitType() != LexicalUnit.SAC_PERCENTAGE)) {
2730                            loop = false;
2731                        }
2732                        break;
2733                    case 1:
2734                    case 3:
2735                        if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
2736                            loop = false;
2737                        }
2738                        break;
2739                    default:
2740                        {if (true) throw new ParseException("implementation error");}
2741                }
2742                if (loop) {
2743                    l = (LexicalUnitImpl) l.getNextLexicalUnit();
2744                    i ++;
2745                }
2746            }
2747            if ((i == 5) && loop && (l == null)) {
2748                {if (true) return LexicalUnitImpl.createRGBColor(n.beginLine,
2749                                                      n.beginColumn,
2750                                                      prev, params);}
2751            } else {
2752                if (errorHandler != null) {
2753                    String JavaDoc errorText;
2754                    Locator loc;
2755                    if (i < 5) {
2756                        if (params == null) {
2757                            loc = new LocatorImpl(this, n.beginLine,
2758                                                  n.beginColumn-1);
2759                            errorText = "not enough parameters.";
2760                        } else if (l == null) {
2761                            loc = new LocatorImpl(this, n.beginLine,
2762                                                  n.beginColumn-1);
2763                            errorText = "not enough parameters: "
2764                                + params.toString();
2765                        } else {
2766                            loc = new LocatorImpl(this, l.getLineNumber(),
2767                                                  l.getColumnNumber());
2768                            errorText = "invalid parameter: "
2769                                + l.toString();
2770                        }
2771                    } else {
2772                        loc = new LocatorImpl(this, l.getLineNumber(),
2773                                              l.getColumnNumber());
2774                        errorText = "too many parameters: "
2775                            + l.toString();
2776                    }
2777                    errorHandler.error(new CSSParseException(errorText, loc));
2778                }
2779
2780                {if (true) throw new JumpException();}
2781            }
2782        } else if ("counter".equals(f)) {
2783            int i = 0;
2784            while (loop && l != null && i < 3) {
2785                switch (i) {
2786                    case 0:
2787                    case 2:
2788                        if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) {
2789                            loop = false;
2790                        }
2791                        break;
2792                    case 1:
2793                        if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
2794                            loop = false;
2795                        }
2796                        break;
2797                    default:
2798                        {if (true) throw new ParseException("implementation error");}
2799                }
2800                l = (LexicalUnitImpl) l.getNextLexicalUnit();
2801                i ++;
2802            }
2803            if (((i == 1) || (i == 3)) && loop && (l == null)) {
2804                {if (true) return LexicalUnitImpl.createCounter(n.beginLine, n.beginColumn,
2805                                                     prev, params);}
2806            }
2807
2808        } else if ("counters(".equals(f)) {
2809
2810            int i = 0;
2811            while (loop && l != null && i < 5) {
2812                switch (i) {
2813                    case 0:
2814                    case 4:
2815                        if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) {
2816                            loop = false;
2817                        }
2818                        break;
2819                    case 2:
2820                        if (l.getLexicalUnitType() != LexicalUnit.SAC_STRING_VALUE) {
2821                            loop = false;
2822                        }
2823                        break;
2824                    case 1:
2825                    case 3:
2826                        if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
2827                            loop = false;
2828                        }
2829                        break;
2830                    default:
2831                        {if (true) throw new ParseException("implementation error");}
2832                }
2833                l = (LexicalUnitImpl) l.getNextLexicalUnit();
2834                i ++;
2835            }
2836            if (((i == 3) || (i == 5)) && loop && (l == null)) {
2837                {if (true) return LexicalUnitImpl.createCounters(n.beginLine, n.beginColumn,
2838                                                      prev, params);}
2839            }
2840        } else if ("attr(".equals(f)) {
2841            if ((l != null)
2842                && (l.getNextLexicalUnit() == null)
2843                && (l.getLexicalUnitType() == LexicalUnit.SAC_IDENT)) {
2844                {if (true) return LexicalUnitImpl.createAttr(l.getLineNumber(),
2845                                                  l.getColumnNumber(),
2846                                                  prev, l.getStringValue());}
2847            }
2848        } else if ("rect(".equals(f)) {
2849            int i = 0;
2850            while (loop && l != null && i < 7) {
2851                switch (i) {
2852                    case 0:
2853                    case 2:
2854                    case 4:
2855                    case 6:
2856                        switch (l.getLexicalUnitType()) {
2857                        case LexicalUnit.SAC_INTEGER:
2858                            if (l.getIntegerValue() != 0) {
2859                                loop = false;
2860                            }
2861                            break;
2862                        case LexicalUnit.SAC_IDENT:
2863                            if (!l.getStringValue().equals("auto")) {
2864                                loop = false;
2865                            }
2866                            break;
2867                        case LexicalUnit.SAC_EM:
2868                        case LexicalUnit.SAC_EX:
2869                        case LexicalUnit.SAC_PIXEL:
2870                        case LexicalUnit.SAC_CENTIMETER:
2871                        case LexicalUnit.SAC_MILLIMETER:
2872                        case LexicalUnit.SAC_INCH:
2873                        case LexicalUnit.SAC_POINT:
2874                        case LexicalUnit.SAC_PICA:
2875                            // nothing
2876
break;
2877                        default:
2878                            loop = false;
2879                        }
2880                        break;
2881                    case 1:
2882                    case 3:
2883                    case 5:
2884                        if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
2885                            loop = false;
2886                        }
2887                        break;
2888                    default:
2889                        {if (true) throw new ParseException("implementation error");}
2890                }
2891                l = (LexicalUnitImpl) l.getNextLexicalUnit();
2892                i ++;
2893            }
2894            if ((i == 7) && loop && (l == null)) {
2895                {if (true) return LexicalUnitImpl.createRect(n.beginLine, n.beginColumn,
2896                                                  prev, params);}
2897            }
2898        }
2899        {if (true) return LexicalUnitImpl.createFunction(n.beginLine, n.beginColumn, prev,
2900                                              f.substring(0,
2901                                                        f.length() -1),
2902                                              params);}
2903    throw new Error JavaDoc("Missing return statement in function");
2904  }
2905
2906  final public LexicalUnitImpl unicode(LexicalUnitImpl prev) throws ParseException {
2907  Token n;
2908    n = jj_consume_token(UNICODERANGE);
2909     LexicalUnitImpl params = null;
2910     String JavaDoc s = n.image.substring(2);
2911     int index = s.indexOf('-');
2912     if (index == -1) {
2913         params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn,
2914                                                params, Integer.parseInt(s, 16));
2915     } else {
2916         String JavaDoc s1 = s.substring(0, index);
2917         String JavaDoc s2 = s.substring(index);
2918
2919         params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn,
2920                                                params, Integer.parseInt(s1, 16));
2921         params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn,
2922                                                params, Integer.parseInt(s2, 16));
2923     }
2924
2925     {if (true) return LexicalUnitImpl.createUnicodeRange(n.beginLine, n.beginColumn,
2926                                               prev, params);}
2927    throw new Error JavaDoc("Missing return statement in function");
2928  }
2929
2930  final public LexicalUnitImpl url(LexicalUnitImpl prev) throws ParseException {
2931  Token n;
2932    n = jj_consume_token(URL);
2933   String JavaDoc urlname = n.image.substring(4, n.image.length()-1).trim();
2934   if (urlname.charAt(0) == '"'
2935       || urlname.charAt(0) == '\'') {
2936       urlname = urlname.substring(1, urlname.length()-1);
2937   }
2938   {if (true) return LexicalUnitImpl.createURL(n.beginLine, n.beginColumn, prev, urlname);}
2939    throw new Error JavaDoc("Missing return statement in function");
2940  }
2941
2942/**
2943 * @exception ParseException exception during the parse
2944 */

2945  final public LexicalUnitImpl hexcolor(LexicalUnitImpl prev) throws ParseException {
2946 Token n;
2947    n = jj_consume_token(HASH);
2948     int r;
2949     LexicalUnitImpl first, params = null;
2950     String JavaDoc s = n.image.substring(1);
2951
2952     if (s.length() == 3) {
2953         String JavaDoc sh = s.substring(0,1);
2954         r = Integer.parseInt(sh+sh, 16);
2955         first = params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn,
2956                                                        params, r);
2957         params = LexicalUnitImpl.createComma(n.beginLine, n.beginColumn,
2958                                                 params);
2959         sh = s.substring(1,2);
2960         r = Integer.parseInt(sh+sh, 16);
2961         params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn,
2962                                                params, r);
2963         params = LexicalUnitImpl.createComma(n.beginLine, n.beginColumn,
2964                                                 params);
2965         sh = s.substring(2,3);
2966         r = Integer.parseInt(sh+sh, 16);
2967         params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn,
2968                                                params, r);
2969     } else if (s.length() == 6) {
2970         r = Integer.parseInt(s.substring(0,2), 16);
2971         first = params = LexicalUnitImpl.createInteger(n.beginLine,
2972                                                        n.beginColumn,
2973                                                        params, r);
2974         params = LexicalUnitImpl.createComma(n.beginLine, n.beginColumn,
2975                                                 params);
2976         r = Integer.parseInt(s.substring(2,4), 16);
2977         params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn,
2978                                                params, r);
2979         params = LexicalUnitImpl.createComma(n.beginLine, n.beginColumn,
2980                                                 params);
2981         r = Integer.parseInt(s.substring(4,6), 16);
2982         params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn,
2983                                                params, r);
2984     } else {
2985         first = null;
2986         {if (true) throw new CSSParseException("invalid hexadecimal notation for RGB: " + s,
2987                                     getLocator());}
2988     }
2989     {if (true) return LexicalUnitImpl.createRGBColor(n.beginLine, n.beginColumn,
2990                                           prev, first);}
2991    throw new Error JavaDoc("Missing return statement in function");
2992  }
2993
2994  float number(char operator, Token n, int lengthUnit) throws ParseException {
2995    String JavaDoc image = n.image;
2996    float f = 0;
2997
2998    if (lengthUnit != 0) {
2999        image = image.substring(0, image.length() - lengthUnit);
3000    }
3001    f = Float.valueOf(image).floatValue();
3002    return (operator == '-')? -f: f;
3003  }
3004
3005  String JavaDoc skipStatement() throws ParseException {
3006    StringBuffer JavaDoc s = new StringBuffer JavaDoc();
3007    Token tok = getToken(0);
3008    if (tok.image != null) {
3009        s.append(tok.image);
3010    }
3011    while (true) {
3012        tok = getToken(1);
3013        if (tok.kind == EOF) {
3014            return null;
3015        }
3016        s.append(tok.image);
3017        if (tok.kind == LBRACE) {
3018            getNextToken();
3019            s.append(skip_to_matching_brace());
3020            getNextToken();
3021            tok = getToken(1);
3022            break;
3023        } else if (tok.kind == RBRACE) {
3024            getNextToken();
3025            tok = getToken(1);
3026            break;
3027        } else if (tok.kind == SEMICOLON) {
3028            getNextToken();
3029            tok = getToken(1);
3030            break;
3031        }
3032        getNextToken();
3033    }
3034
3035    // skip white space
3036
while (true) {
3037        if (tok.kind != S) {
3038            break;
3039        }
3040        tok = getNextToken();
3041        tok = getToken(1);
3042    }
3043
3044    return s.toString().trim();
3045  }
3046
3047  String JavaDoc skip_to_matching_brace() throws ParseException {
3048    StringBuffer JavaDoc s = new StringBuffer JavaDoc();
3049    Token tok;
3050    int nesting = 1;
3051    while (true) {
3052        tok = getToken(1);
3053        if (tok.kind == EOF) {
3054            break;
3055        }
3056        s.append(tok.image);
3057        if (tok.kind == LBRACE) {
3058            nesting++;
3059        } else if (tok.kind == RBRACE) {
3060            nesting--;
3061            if (nesting == 0) {
3062                break;
3063            }
3064        }
3065        getNextToken();
3066    }
3067    return s.toString();
3068  }
3069
3070  String JavaDoc convertStringIndex(String JavaDoc s, int start, int len) throws ParseException {
3071    StringBuffer JavaDoc buf = new StringBuffer JavaDoc(len);
3072    int index = start;
3073
3074    while (index < len) {
3075        char c = s.charAt(index);
3076        if (c == '\\') {
3077            if (++index < len) {
3078                c = s.charAt(index);
3079                switch (c) {
3080                case '0': case '1': case '2': case '3': case '4':
3081                case '5': case '6': case '7': case '8': case '9':
3082                case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
3083                case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
3084                    int numValue = Character.digit(c, 16);
3085                    int count = 0;
3086                    int p = 16;
3087
3088                    while (index + 1 < len && count < 6) {
3089                        c = s.charAt(index+1);
3090
3091                        if (Character.digit(c, 16) != -1) {
3092                            numValue = (numValue * 16) + Character.digit(c, 16);
3093                            p *= 16;
3094                            index++;
3095                        } else {
3096                            if (c == ' ') {
3097                                // skip the latest white space
3098
index++;
3099                            }
3100                            break;
3101                        }
3102                    }
3103                    buf.append((char) numValue);
3104                    break;
3105                case '\n':
3106                case '\f':
3107                    break;
3108                case '\r':
3109                    if (index + 1 < len) {
3110                        if (s.charAt(index + 1) == '\n') {
3111                            index ++;
3112                        }
3113                    }
3114                    break;
3115                default:
3116                    buf.append(c);
3117                }
3118            } else {
3119                throw new CSSParseException("invalid string " + s, getLocator());
3120            }
3121        } else {
3122            buf.append(c);
3123        }
3124        index++;
3125    }
3126
3127    return buf.toString();
3128  }
3129
3130  String JavaDoc convertIdent(String JavaDoc s) throws ParseException {
3131    return convertStringIndex(s, 0, s.length());
3132  }
3133
3134  String JavaDoc convertString(String JavaDoc s) throws ParseException {
3135    return convertStringIndex(s, 0, s.length());
3136  }
3137
3138  void rejectToken(Token t) throws ParseException {
3139    Token fakeToken = new Token();
3140    t.next = token;
3141    fakeToken.next = t;
3142    token = fakeToken;
3143  }
3144
3145  String JavaDoc skipAfterExpression() throws ParseException {
3146    Token t = getToken(1);
3147    StringBuffer JavaDoc s = new StringBuffer JavaDoc();
3148    s.append(getToken(0).image);
3149
3150    while ((t.kind != RBRACE) && (t.kind != SEMICOLON) && (t.kind != EOF)) {
3151        s.append(t.image);
3152        getNextToken();
3153        t = getToken(1);
3154    }
3155
3156    return s.toString();
3157  }
3158
3159/**
3160 * The following functions are useful for a DOM CSS implementation only and are
3161 * not part of the general CSS2 parser.
3162 */

3163  final public void _parseRule() throws ParseException {
3164 String JavaDoc ret = null;
3165    label_68:
3166    while (true) {
3167      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3168      case S:
3169        ;
3170        break;
3171      default:
3172        jj_la1[105] = jj_gen;
3173        break label_68;
3174      }
3175      jj_consume_token(S);
3176    }
3177    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3178    case IMPORT_SYM:
3179      importDeclaration();
3180      break;
3181    case LBRACKET:
3182    case ANY:
3183    case DOT:
3184    case COLON:
3185    case IDENT:
3186    case NAMESPACE_IDENT:
3187    case HASH:
3188      styleRule();
3189      break;
3190    case MEDIA_SYM:
3191      media();
3192      break;
3193    case PAGE_SYM:
3194      page();
3195      break;
3196    case FONT_FACE_SYM:
3197      fontFace();
3198      break;
3199    default:
3200      jj_la1[106] = jj_gen;
3201      ret = skipStatement();
3202                    if ((ret == null) || (ret.length() == 0)) {
3203                        {if (true) return;}
3204                    }
3205                    if (ret.charAt(0) == '@') {
3206                        documentHandler.ignorableAtRule(ret);
3207                    } else {
3208                        {if (true) throw new CSSParseException("unrecognize rule: " + ret,
3209                                                    getLocator());}
3210                    }
3211    }
3212  }
3213
3214  final public void _parseImportRule() throws ParseException {
3215    label_69:
3216    while (true) {
3217      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3218      case S:
3219        ;
3220        break;
3221      default:
3222        jj_la1[107] = jj_gen;
3223        break label_69;
3224      }
3225      jj_consume_token(S);
3226    }
3227    importDeclaration();
3228  }
3229
3230  final public void _parseMediaRule() throws ParseException {
3231    label_70:
3232    while (true) {
3233      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3234      case S:
3235        ;
3236        break;
3237      default:
3238        jj_la1[108] = jj_gen;
3239        break label_70;
3240      }
3241      jj_consume_token(S);
3242    }
3243    media();
3244  }
3245
3246  final public void _parseDeclarationBlock() throws ParseException {
3247    label_71:
3248    while (true) {
3249      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3250      case S:
3251        ;
3252        break;
3253      default:
3254        jj_la1[109] = jj_gen;
3255        break label_71;
3256      }
3257      jj_consume_token(S);
3258    }
3259    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3260    case IDENT:
3261      declaration();
3262      break;
3263    default:
3264      jj_la1[110] = jj_gen;
3265      ;
3266    }
3267    label_72:
3268    while (true) {
3269      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3270      case SEMICOLON:
3271        ;
3272        break;
3273      default:
3274        jj_la1[111] = jj_gen;
3275        break label_72;
3276      }
3277      jj_consume_token(SEMICOLON);
3278      label_73:
3279      while (true) {
3280        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3281        case S:
3282          ;
3283          break;
3284        default:
3285          jj_la1[112] = jj_gen;
3286          break label_73;
3287        }
3288        jj_consume_token(S);
3289      }
3290      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3291      case IDENT:
3292        declaration();
3293        break;
3294      default:
3295        jj_la1[113] = jj_gen;
3296        ;
3297      }
3298    }
3299  }
3300
3301  final public SelectorList _parseSelectors() throws ParseException {
3302  SelectorList p = null;
3303    try {
3304      label_74:
3305      while (true) {
3306        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3307        case S:
3308          ;
3309          break;
3310        default:
3311          jj_la1[114] = jj_gen;
3312          break label_74;
3313        }
3314        jj_consume_token(S);
3315      }
3316      p = selectorList();
3317          {if (true) return p;}
3318    } catch (ThrowedParseException e) {
3319        {if (true) throw (ParseException) e.e;}//.fillInStackTrace();
3320

3321    }
3322    throw new Error JavaDoc("Missing return statement in function");
3323  }
3324
3325  final public String JavaDoc _parseNamespaceToken() throws ParseException {
3326  Token retval = null;
3327    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3328    case NAMESPACE_IDENT:
3329      retval = jj_consume_token(NAMESPACE_IDENT);
3330      {if (true) return retval.image;}
3331      break;
3332    case IDENT:
3333      retval = jj_consume_token(IDENT);
3334      {if (true) return retval.image;}
3335      break;
3336    default:
3337      jj_la1[115] = jj_gen;
3338      jj_consume_token(-1);
3339      throw new ParseException();
3340    }
3341    throw new Error JavaDoc("Missing return statement in function");
3342  }
3343
3344  final private boolean jj_2_1(int xla) {
3345    jj_la = xla; jj_lastpos = jj_scanpos = token;
3346    try { return !jj_3_1(); }
3347    catch(LookaheadSuccess ls) { return true; }
3348    finally { jj_save(0, xla); }
3349  }
3350
3351  final private boolean jj_3R_92() {
3352    if (jj_scan_token(PRECEDES)) return true;
3353    return false;
3354  }
3355
3356  final private boolean jj_3R_88() {
3357    if (jj_scan_token(DOT)) return true;
3358    return false;
3359  }
3360
3361  final private boolean jj_3R_91() {
3362    if (jj_scan_token(PLUS)) return true;
3363    return false;
3364  }
3365
3366  final private boolean jj_3R_85() {
3367    Token xsp;
3368    xsp = jj_scanpos;
3369    if (jj_3R_91()) {
3370    jj_scanpos = xsp;
3371    if (jj_3R_92()) return true;
3372    }
3373    return false;
3374  }
3375
3376  final private boolean jj_3R_84() {
3377    if (jj_3R_90()) return true;
3378    return false;
3379  }
3380
3381  final private boolean jj_3R_90() {
3382    if (jj_scan_token(LBRACKET)) return true;
3383    return false;
3384  }
3385
3386  final private boolean jj_3R_78() {
3387    if (jj_scan_token(PRECEDES)) return true;
3388    Token xsp;
3389    while (true) {
3390      xsp = jj_scanpos;
3391      if (jj_scan_token(1)) { jj_scanpos = xsp; break; }
3392    }
3393    return false;
3394  }
3395
3396  final private boolean jj_3R_79() {
3397    if (jj_scan_token(S)) return true;
3398    Token xsp;
3399    xsp = jj_scanpos;
3400    if (jj_3R_85()) jj_scanpos = xsp;
3401    return false;
3402  }
3403
3404  final private boolean jj_3R_77() {
3405    if (jj_scan_token(PLUS)) return true;
3406    Token xsp;
3407    while (true) {
3408      xsp = jj_scanpos;
3409      if (jj_scan_token(1)) { jj_scanpos = xsp; break; }
3410    }
3411    return false;
3412  }
3413
3414  final private boolean jj_3R_75() {
3415    Token xsp;
3416    xsp = jj_scanpos;
3417    if (jj_3R_77()) {
3418    jj_scanpos = xsp;
3419    if (jj_3R_78()) {
3420    jj_scanpos = xsp;
3421    if (jj_3R_79()) return true;
3422    }
3423    }
3424    return false;
3425  }
3426
3427  final private boolean jj_3R_83() {
3428    if (jj_3R_89()) return true;
3429    return false;
3430  }
3431
3432  final private boolean jj_3R_82() {
3433    if (jj_3R_88()) return true;
3434    return false;
3435  }
3436
3437  final private boolean jj_3R_95() {
3438    if (jj_scan_token(ANY)) return true;
3439    return false;
3440  }
3441
3442  final private boolean jj_3_1() {
3443    if (jj_3R_75()) return true;
3444    if (jj_3R_76()) return true;
3445    return false;
3446  }
3447
3448  final private boolean jj_3R_94() {
3449    if (jj_scan_token(NAMESPACE_IDENT)) return true;
3450    return false;
3451  }
3452
3453  final private boolean jj_3R_81() {
3454    if (jj_3R_87()) return true;
3455    return false;
3456  }
3457
3458  final private boolean jj_3R_89() {
3459    if (jj_scan_token(COLON)) return true;
3460    return false;
3461  }
3462
3463  final private boolean jj_3R_87() {
3464    if (jj_scan_token(HASH)) return true;
3465    return false;
3466  }
3467
3468  final private boolean jj_3R_93() {
3469    if (jj_scan_token(IDENT)) return true;
3470    return false;
3471  }
3472
3473  final private boolean jj_3R_86() {
3474    Token xsp;
3475    xsp = jj_scanpos;
3476    if (jj_3R_93()) {
3477    jj_scanpos = xsp;
3478    if (jj_3R_94()) {
3479    jj_scanpos = xsp;
3480    if (jj_3R_95()) return true;
3481    }
3482    }
3483    return false;
3484  }
3485
3486  final private boolean jj_3R_80() {
3487    if (jj_3R_86()) return true;
3488    return false;
3489  }
3490
3491  final private boolean jj_3R_76() {
3492    Token xsp;
3493    xsp = jj_scanpos;
3494    if (jj_3R_80()) {
3495    jj_scanpos = xsp;
3496    if (jj_3R_81()) {
3497    jj_scanpos = xsp;
3498    if (jj_3R_82()) {
3499    jj_scanpos = xsp;
3500    if (jj_3R_83()) {
3501    jj_scanpos = xsp;
3502    if (jj_3R_84()) return true;
3503    }
3504    }
3505    }
3506    }
3507    return false;
3508  }
3509
3510  public ParserTokenManager token_source;
3511  public Token token, jj_nt;
3512  private int jj_ntk;
3513  private Token jj_scanpos, jj_lastpos;
3514  private int jj_la;
3515  public boolean lookingAhead = false;
3516  private boolean jj_semLA;
3517  private int jj_gen;
3518  final private int[] jj_la1 = new int[116];
3519  static private int[] jj_la1_0;
3520  static private int[] jj_la1_1;
3521  static private int[] jj_la1_2;
3522  static {
3523      jj_la1_0();
3524      jj_la1_1();
3525      jj_la1_2();
3526   }
3527   private static void jj_la1_0() {
3528      jj_la1_0 = new int[] {0x0,0x62,0x62,0x0,0x60,0x2,0x0,0x60,0x2,0x2,0x2,0x1340000,0x60,0x2,0x60,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x335f6a0,0x335f6a0,0x2,0x4000,0x2,0x2,0x2,0x2,0x0,0x1000000,0x2,0x0,0x8000,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x8000,0x2,0x0,0x2,0x201f6a0,0x2,0x2,0x11000,0x2,0x11000,0x11002,0x2,0x2,0x0,0x8000,0x2,0x0,0x2,0x4000,0x2,0x2,0x1240000,0x1240000,0x1240000,0x1240000,0x1240000,0x1240000,0x1240000,0x1240000,0x1240000,0x1240000,0x1340000,0x100000,0x2,0x0,0x2,0xe00,0x2,0x0,0x2,0xe00,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x24000,0x27000,0x24000,0x3000,0x3000,0x0,0x0,0x3000,0x2,0x2,0x3000,0x2,0x1340000,0x2,0x2,0x2,0x0,0x8000,0x2,0x0,0x2,0x0,};
3529   }
3530   private static void jj_la1_1() {
3531      jj_la1_1 = new int[] {0x20000000,0x0,0x0,0x8000000,0x0,0x0,0x80000000,0x0,0x0,0x0,0x0,0x54000110,0x0,0x0,0x0,0x0,0x88,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x7c0003b8,0x7c0003b8,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x0,0x0,0x10,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x10,0x0,0x0,0x10,0x0,0x780002a8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x4000000,0x4000000,0x0,0x0,0x4000000,0x4000000,0x4000000,0x4000000,0x4000000,0x4000000,0x4000110,0x110,0x0,0x110,0x0,0x0,0x0,0x18,0x0,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x7ffffb8,0x0,0x0,0x0,0x3fffe20,0x4000198,0x7ffffb8,0x0,0x0,0x7ffffb8,0x0,0x5c000110,0x0,0x0,0x0,0x10,0x0,0x0,0x10,0x0,0x110,};
3532   }
3533   private static void jj_la1_2() {
3534      jj_la1_2 = new int[] {0x0,0x2,0x2,0x0,0x2,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x2,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7007,0x7007,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7007,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2000,0x0,0x4,0x0,0x0,0x0,0x0,0x3000,0x0,0x0,0x0,0x2000,0x1000,0x3000,0x0,0x0,0x3000,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
3535   }
3536  final private JJCalls[] jj_2_rtns = new JJCalls[1];
3537  private boolean jj_rescan = false;
3538  private int jj_gc = 0;
3539
3540  public Parser(CharStream stream) {
3541    token_source = new ParserTokenManager(stream);
3542    token = new Token();
3543    jj_ntk = -1;
3544    jj_gen = 0;
3545    for (int i = 0; i < 116; i++) jj_la1[i] = -1;
3546    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
3547  }
3548
3549  public void ReInit(CharStream stream) {
3550    token_source.ReInit(stream);
3551    token = new Token();
3552    jj_ntk = -1;
3553    jj_gen = 0;
3554    for (int i = 0; i < 116; i++) jj_la1[i] = -1;
3555    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
3556  }
3557
3558  public Parser(ParserTokenManager tm) {
3559    token_source = tm;
3560    token = new Token();
3561    jj_ntk = -1;
3562    jj_gen = 0;
3563    for (int i = 0; i < 116; i++) jj_la1[i] = -1;
3564    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
3565  }
3566
3567  public void ReInit(ParserTokenManager tm) {
3568    token_source = tm;
3569    token = new Token();
3570    jj_ntk = -1;
3571    jj_gen = 0;
3572    for (int i = 0; i < 116; i++) jj_la1[i] = -1;
3573    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
3574  }
3575
3576  final private Token jj_consume_token(int kind) throws ParseException {
3577    Token oldToken;
3578    if ((oldToken = token).next != null) token = token.next;
3579    else token = token.next = token_source.getNextToken();
3580    jj_ntk = -1;
3581    if (token.kind == kind) {
3582      jj_gen++;
3583      if (++jj_gc > 100) {
3584        jj_gc = 0;
3585        for (int i = 0; i < jj_2_rtns.length; i++) {
3586          JJCalls c = jj_2_rtns[i];
3587          while (c != null) {
3588            if (c.gen < jj_gen) c.first = null;
3589            c = c.next;
3590          }
3591        }
3592      }
3593      return token;
3594    }
3595    token = oldToken;
3596    jj_kind = kind;
3597    throw generateParseException();
3598  }
3599
3600  static private final class LookaheadSuccess extends java.lang.Error JavaDoc { }
3601  final private LookaheadSuccess jj_ls = new LookaheadSuccess();
3602  final private boolean jj_scan_token(int kind) {
3603    if (jj_scanpos == jj_lastpos) {
3604      jj_la--;
3605      if (jj_scanpos.next == null) {
3606        jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
3607      } else {
3608        jj_lastpos = jj_scanpos = jj_scanpos.next;
3609      }
3610    } else {
3611      jj_scanpos = jj_scanpos.next;
3612    }
3613    if (jj_rescan) {
3614      int i = 0; Token tok = token;
3615      while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
3616      if (tok != null) jj_add_error_token(kind, i);
3617    }
3618    if (jj_scanpos.kind != kind) return true;
3619    if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
3620    return false;
3621  }
3622
3623  final public Token getNextToken() {
3624    if (token.next != null) token = token.next;
3625    else token = token.next = token_source.getNextToken();
3626    jj_ntk = -1;
3627    jj_gen++;
3628    return token;
3629  }
3630
3631  final public Token getToken(int index) {
3632    Token t = lookingAhead ? jj_scanpos : token;
3633    for (int i = 0; i < index; i++) {
3634      if (t.next != null) t = t.next;
3635      else t = t.next = token_source.getNextToken();
3636    }
3637    return t;
3638  }
3639
3640  final private int jj_ntk() {
3641    if ((jj_nt=token.next) == null)
3642      return (jj_ntk = (token.next=token_source.getNextToken()).kind);
3643    else
3644      return (jj_ntk = jj_nt.kind);
3645  }
3646
3647  private java.util.Vector JavaDoc jj_expentries = new java.util.Vector JavaDoc();
3648  private int[] jj_expentry;
3649  private int jj_kind = -1;
3650  private int[] jj_lasttokens = new int[100];
3651  private int jj_endpos;
3652
3653  private void jj_add_error_token(int kind, int pos) {
3654    if (pos >= 100) return;
3655    if (pos == jj_endpos + 1) {
3656      jj_lasttokens[jj_endpos++] = kind;
3657    } else if (jj_endpos != 0) {
3658      jj_expentry = new int[jj_endpos];
3659      for (int i = 0; i < jj_endpos; i++) {
3660        jj_expentry[i] = jj_lasttokens[i];
3661      }
3662      boolean exists = false;
3663      for (java.util.Enumeration JavaDoc e = jj_expentries.elements(); e.hasMoreElements();) {
3664        int[] oldentry = (int[])(e.nextElement());
3665        if (oldentry.length == jj_expentry.length) {
3666          exists = true;
3667          for (int i = 0; i < jj_expentry.length; i++) {
3668            if (oldentry[i] != jj_expentry[i]) {
3669              exists = false;
3670              break;
3671            }
3672          }
3673          if (exists) break;
3674        }
3675      }
3676      if (!exists) jj_expentries.addElement(jj_expentry);
3677      if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
3678    }
3679  }
3680
3681  public ParseException generateParseException() {
3682    jj_expentries.removeAllElements();
3683    boolean[] la1tokens = new boolean[79];
3684    for (int i = 0; i < 79; i++) {
3685      la1tokens[i] = false;
3686    }
3687    if (jj_kind >= 0) {
3688      la1tokens[jj_kind] = true;
3689      jj_kind = -1;
3690    }
3691    for (int i = 0; i < 116; i++) {
3692      if (jj_la1[i] == jj_gen) {
3693        for (int j = 0; j < 32; j++) {
3694          if ((jj_la1_0[i] & (1<<j)) != 0) {
3695            la1tokens[j] = true;
3696          }
3697          if ((jj_la1_1[i] & (1<<j)) != 0) {
3698            la1tokens[32+j] = true;
3699          }
3700          if ((jj_la1_2[i] & (1<<j)) != 0) {
3701            la1tokens[64+j] = true;
3702          }
3703        }
3704      }
3705    }
3706    for (int i = 0; i < 79; i++) {
3707      if (la1tokens[i]) {
3708        jj_expentry = new int[1];
3709        jj_expentry[0] = i;
3710        jj_expentries.addElement(jj_expentry);
3711      }
3712    }
3713    jj_endpos = 0;
3714    jj_rescan_token();
3715    jj_add_error_token(0, 0);
3716    int[][] exptokseq = new int[jj_expentries.size()][];
3717    for (int i = 0; i < jj_expentries.size(); i++) {
3718      exptokseq[i] = (int[])jj_expentries.elementAt(i);
3719    }
3720    return new ParseException(token, exptokseq, tokenImage);
3721  }
3722
3723  final public void enable_tracing() {
3724  }
3725
3726  final public void disable_tracing() {
3727  }
3728
3729  final private void jj_rescan_token() {
3730    jj_rescan = true;
3731    for (int i = 0; i < 1; i++) {
3732      JJCalls p = jj_2_rtns[i];
3733      do {
3734        if (p.gen > jj_gen) {
3735          jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
3736          switch (i) {
3737            case 0: jj_3_1(); break;
3738          }
3739        }
3740        p = p.next;
3741      } while (p != null);
3742    }
3743    jj_rescan = false;
3744  }
3745
3746  final private void jj_save(int index, int xla) {
3747    JJCalls p = jj_2_rtns[index];
3748    while (p.gen > jj_gen) {
3749      if (p.next == null) { p = p.next = new JJCalls(); break; }
3750      p = p.next;
3751    }
3752    p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
3753  }
3754
3755  static final class JJCalls {
3756    int gen;
3757    Token first;
3758    int arg;
3759    JJCalls next;
3760  }
3761
3762}
3763
Popular Tags