PageRenderTime 55ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/XML/tags/release-2-8-1/sidekick/css/parser/CSS3Parser.java

#
Java | 2426 lines | 2269 code | 66 blank | 91 comment | 334 complexity | bf38e412b4df3cb71523fe7696fa0705 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. /* Generated By:JavaCC: Do not edit this line. CSS3Parser.java */
  2. package sidekick.css.parser;
  3. import java.io.*;
  4. import java.net.*;
  5. import java.text.MessageFormat;
  6. import java.util.*;
  7. import java.util.regex.*;
  8. import sidekick.util.*;
  9. /**
  10. * A CSS3 parser
  11. *
  12. * @author Philippe Le Hegaret and Sijtsche Smeman
  13. * @author Dale Anson, major modifications for jEdit Sidekick
  14. * @version Revision: 1.71 (W3C version)
  15. */
  16. public class CSS3Parser implements CSS3ParserConstants {
  17. private List<ParseError> parseErrors = new ArrayList<ParseError>();
  18. private boolean proprietaryAsError = true;
  19. private static char hexdigits[] = { '0' ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'a' ,'b' ,'c' ,'d' ,'e' ,'f' } ;
  20. /**
  21. * The line offset is used when the css to be parsed is only part of a file,
  22. * for example when the css is the contents of a style block contained within
  23. * an html document.
  24. * @param lineOffset The line number of the first line of the css.
  25. * @param columnOffset The column number of the first character of the css.
  26. */
  27. public CSS3Parser(Reader in, int lineOffset, int columnOffset){
  28. this(in);
  29. jj_input_stream.ReInit(in,lineOffset,columnOffset);
  30. }
  31. /**
  32. * Set the tab size on the input stream. This should be set to the same
  33. * tab size as used in the buffer being parsed, otherwise, locations will
  34. * be off.
  35. */
  36. public void setTabSize(int size) {
  37. jj_input_stream.setTabSize(size);
  38. }
  39. /**
  40. * @return the current tab size used by the input stream.
  41. */
  42. public int getTabSize() {
  43. return jj_input_stream.getTabSize(0);
  44. }
  45. /**
  46. * If set to true, then a warning will be generated when proprietary
  47. * CSS markup is used.
  48. * @param b If set to true, then a warning will be generated when proprietary
  49. * CSS markup is used.
  50. */
  51. public void setProprietaryAsError(boolean b) {
  52. proprietaryAsError = b;
  53. }
  54. /**
  55. * Adds a parse exception to the list of parse exceptions. It is intended
  56. * that a complete file will be parsed and accumulate the exceptions rather
  57. * than quitting on the first exception.
  58. * @param pe A parse exception to add to the list.
  59. */
  60. private void addException(ParseException pe) {
  61. Range range = getExceptionLocation( pe );
  62. parseErrors.add(new ParseError(pe.getMessage(), range));
  63. //pe.printStackTrace();
  64. }
  65. /**
  66. * @return The list of parse exceptions found during parsing of a file.
  67. */
  68. public List<ParseError> getParseErrors() {
  69. //System.out.println("getParserErrors, there are " + parseErrors.size() + " errors");
  70. return parseErrors;
  71. }
  72. // regex to extract line and colun from a ParseException message
  73. // ParseException message look like: "Parse error at line 116, column 5. Encountered: }"
  74. private Pattern pePattern = Pattern.compile( "(.*?)(\\d+)(.*?)(\\d+)(.*?)" );
  75. /**
  76. * @return attempts to return a Location indicating the location of a parser
  77. * exception. If the ParseException contains a Token reference, all is well,
  78. * otherwise, this method attempts to parse the message string for the
  79. * exception.
  80. */
  81. private Range getExceptionLocation( ParseException pe ) {
  82. Token t = pe.currentToken;
  83. if ( t != null ) {
  84. return new Range( new Location( t.next.beginLine, t.next.beginColumn-1 ), new Location( t.next.endLine, t.next.endColumn ) );
  85. }
  86. // ParseException message look like: "Parse error at line 116, column 5. Encountered: }"
  87. try {
  88. Matcher m = pePattern.matcher( pe.getMessage() );
  89. if ( m.matches() ) {
  90. String ln = m.group( 2 );
  91. String cn = m.group( 4 );
  92. int line_number = -1;
  93. int column_number = 0;
  94. if ( ln != null )
  95. line_number = Integer.parseInt( ln );
  96. if ( cn != null )
  97. column_number = Integer.parseInt( cn );
  98. return line_number > -1 ? new Range( new Location( line_number - 1, column_number - 1 ), new Location( line_number - 1, column_number ) ) : null;
  99. }
  100. return new Range();
  101. } catch ( Exception e ) {
  102. //e.printStackTrace();
  103. return new Range();
  104. }
  105. }
  106. public void error_skipto(int kind) {
  107. Token t = null;
  108. int i = 0;
  109. do {
  110. i++;
  111. if (i > 100) {
  112. break;
  113. }
  114. t = getNextToken();
  115. } while (t != null && t.kind != kind);
  116. }
  117. /**
  118. * @param t A token to create a location from.
  119. * @return A location representing the start of the token.
  120. */
  121. public Location getStartLocation(Token t) {
  122. if (t == null)
  123. return new Location(0, 0);
  124. return new Location(t.beginLine, t.beginColumn);
  125. }
  126. /**
  127. * @param t A token to create a location from.
  128. * @return A location representing the end of the token.
  129. */
  130. public Location getEndLocation(Token t) {
  131. if (t == null)
  132. return new Location(0, 0);
  133. return new Location(t.endLine, t.endColumn + 1);
  134. }
  135. /**
  136. * Creates a CSSNode from a token using the token image as the node name
  137. * and the token start and end for node start and end locations.
  138. */
  139. public CSSNode createNode(Token t) {
  140. if (t == null) {
  141. return new CSSNode();
  142. }
  143. CSSNode node = new CSSNode(t.image);
  144. node.setStartLocation(getStartLocation(t));
  145. node.setEndLocation(getEndLocation(t));
  146. return node;
  147. }
  148. /**
  149. * Simple check to verify that all arguments are not null.
  150. */
  151. public boolean notNull(Object... args) {
  152. for (Object o : args) {
  153. if (o == null) {
  154. return false;
  155. }
  156. }
  157. return true;
  158. }
  159. // For testing. Usage: java CSS3Parser < inputfile
  160. public static void main(String[] args) {
  161. try {
  162. CSS3Parser parser = new CSS3Parser(System.in);
  163. parser.styleSheet();
  164. }
  165. catch(Exception e) {
  166. e.printStackTrace();
  167. }
  168. }
  169. //<DEFAULT, IN_COMMENT>
  170. //TOKEN :
  171. //{ /* avoid token manager error */
  172. // < UNKNOWN : ~[] >
  173. //}
  174. /*
  175. * The grammar for CSS2 and CSS3 starts here.
  176. */
  177. /**
  178. * The main entry for the parser. The W3C version called this method "parserUnit".
  179. * I changed the name so it matches up with the older CSS2 parser.
  180. *
  181. * @exception ParseException exception during the parse
  182. */
  183. final public CSSNode styleSheet() throws ParseException {
  184. CSSNode rootNode = new CSSNode("style");
  185. CSSNode firstNode = null;
  186. CSSNode childNode = null;
  187. List<CSSNode> children = null;
  188. try {
  189. label_1:
  190. while (true) {
  191. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  192. case HTMLSTARTTAG:
  193. case HTMLENDTAG:
  194. ;
  195. break;
  196. default:
  197. jj_la1[0] = jj_gen;
  198. break label_1;
  199. }
  200. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  201. case HTMLSTARTTAG:
  202. jj_consume_token(HTMLSTARTTAG);
  203. break;
  204. case HTMLENDTAG:
  205. jj_consume_token(HTMLENDTAG);
  206. break;
  207. default:
  208. jj_la1[1] = jj_gen;
  209. jj_consume_token(-1);
  210. throw new ParseException();
  211. }
  212. // TODO: put message in properties file
  213. addException ( new ParseException ("Do not mix html within CSS."));
  214. }
  215. label_2:
  216. while (true) {
  217. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  218. case CHARSET_SYM:
  219. ;
  220. break;
  221. default:
  222. jj_la1[2] = jj_gen;
  223. break label_2;
  224. }
  225. childNode = charset();
  226. if (childNode != null) {
  227. rootNode.addChild(childNode);
  228. if (firstNode == null) {
  229. firstNode = childNode;
  230. rootNode.setStartLocation(firstNode.getStartLocation());
  231. }
  232. }
  233. }
  234. label_3:
  235. while (true) {
  236. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  237. case S:
  238. case CDO:
  239. case CDC:
  240. ;
  241. break;
  242. default:
  243. jj_la1[3] = jj_gen;
  244. break label_3;
  245. }
  246. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  247. case S:
  248. jj_consume_token(S);
  249. break;
  250. case CDO:
  251. jj_consume_token(CDO);
  252. break;
  253. case CDC:
  254. jj_consume_token(CDC);
  255. break;
  256. default:
  257. jj_la1[4] = jj_gen;
  258. jj_consume_token(-1);
  259. throw new ParseException();
  260. }
  261. }
  262. label_4:
  263. while (true) {
  264. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  265. case IMPORT_SYM:
  266. ;
  267. break;
  268. default:
  269. jj_la1[5] = jj_gen;
  270. break label_4;
  271. }
  272. childNode = importDeclaration();
  273. if (childNode != null) {
  274. rootNode.addChild(childNode);
  275. if (firstNode == null) {
  276. firstNode = childNode;
  277. rootNode.setStartLocation(firstNode.getStartLocation());
  278. }
  279. }
  280. ignoreStatement();
  281. }
  282. label_5:
  283. while (true) {
  284. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  285. case NAMESPACE_SYM:
  286. ;
  287. break;
  288. default:
  289. jj_la1[6] = jj_gen;
  290. break label_5;
  291. }
  292. childNode = namespaceDeclaration();
  293. if (childNode != null) {
  294. rootNode.addChild(childNode);
  295. if (firstNode == null) {
  296. firstNode = childNode;
  297. rootNode.setStartLocation(firstNode.getStartLocation());
  298. }
  299. }
  300. ignoreStatement();
  301. }
  302. children = afterImportDeclaration();
  303. if (children != null && children.size() > 0) {
  304. rootNode.setEndLocation(children.get(children.size() - 1).getEndLocation());
  305. rootNode.addChildren(children);
  306. }
  307. jj_consume_token(0);
  308. } catch (TokenMgrError err) {
  309. addException ( new ParseException ("Unrecognized token, " + err.getMessage()));
  310. }
  311. {if (true) return rootNode;}
  312. throw new Error("Missing return statement in function");
  313. }
  314. final public CSSNode charset() throws ParseException {
  315. Token start = null;
  316. Token middle = null;
  317. Token end = null;
  318. CSSNode node = null;
  319. try {
  320. start = jj_consume_token(CHARSET_SYM);
  321. label_6:
  322. while (true) {
  323. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  324. case S:
  325. ;
  326. break;
  327. default:
  328. jj_la1[7] = jj_gen;
  329. break label_6;
  330. }
  331. jj_consume_token(S);
  332. }
  333. middle = jj_consume_token(STRING);
  334. label_7:
  335. while (true) {
  336. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  337. case S:
  338. ;
  339. break;
  340. default:
  341. jj_la1[8] = jj_gen;
  342. break label_7;
  343. }
  344. jj_consume_token(S);
  345. }
  346. end = jj_consume_token(SEMICOLON);
  347. } catch (ParseException e) {
  348. addException(e);
  349. error_skipto(RBRACE);
  350. {if (true) return null;}
  351. }
  352. if (notNull(start, middle, end)) {
  353. String name = start.image + " " + middle.image;
  354. node = new CSSNode(name);
  355. node.setStartLocation(getStartLocation(start));
  356. node.setEndLocation(getEndLocation(end));
  357. }
  358. {if (true) return node;}
  359. throw new Error("Missing return statement in function");
  360. }
  361. final public List<CSSNode> afterImportDeclaration() throws ParseException {
  362. CSSNode node = null;
  363. List<CSSNode> list = new ArrayList<CSSNode>();
  364. String skip = null;
  365. try {
  366. label_8:
  367. while (true) {
  368. ;
  369. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  370. case IDENT:
  371. case HASHIDENT:
  372. case HASH:
  373. case LBRACKET:
  374. case ANY:
  375. case COLON:
  376. case LENGTH:
  377. case EMS:
  378. case EXS:
  379. case ANGLE:
  380. case TIME:
  381. case FREQ:
  382. case RESOLUTION:
  383. case DIMEN:
  384. case PSEUDOELEMENT_SYM:
  385. case CLASS:
  386. case FUNCTIONNOT:
  387. case 98:
  388. node = ruleSet();
  389. if (node != null) list.add(node);
  390. break;
  391. case MEDIA_SYM:
  392. node = media();
  393. if (node != null) list.add(node);
  394. break;
  395. case PAGE_SYM:
  396. node = page();
  397. if (node != null) list.add(node);
  398. break;
  399. case FONT_FACE_SYM:
  400. node = fontFace();
  401. if (node != null) list.add(node);
  402. break;
  403. case PREF_SYM:
  404. node = preference();
  405. if (node != null) list.add(node);
  406. break;
  407. case COLOR_PROFILE:
  408. node = colorprofile();
  409. if (node != null) list.add(node);
  410. break;
  411. case PHONETIC_ALPHABET_SYM:
  412. node = phoneticAlphabet();
  413. if (node != null) list.add(node);
  414. break;
  415. default:
  416. jj_la1[9] = jj_gen;
  417. skip = skipStatement();
  418. if (skip == null || skip.length() == 0) {
  419. {if (true) return list;}
  420. }
  421. }
  422. ignoreStatement();
  423. }
  424. } catch (ParseException e) {
  425. addException(e);
  426. error_skipto(RBRACE);
  427. {if (true) return null;}
  428. }
  429. {if (true) return list;}
  430. throw new Error("Missing return statement in function");
  431. }
  432. final public void ignoreStatement() throws ParseException {
  433. label_9:
  434. while (true) {
  435. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  436. case CDO:
  437. case CDC:
  438. case ATKEYWORD:
  439. ;
  440. break;
  441. default:
  442. jj_la1[10] = jj_gen;
  443. break label_9;
  444. }
  445. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  446. case CDO:
  447. jj_consume_token(CDO);
  448. break;
  449. case CDC:
  450. jj_consume_token(CDC);
  451. break;
  452. case ATKEYWORD:
  453. atRuleDeclaration();
  454. break;
  455. default:
  456. jj_la1[11] = jj_gen;
  457. jj_consume_token(-1);
  458. throw new ParseException();
  459. }
  460. label_10:
  461. while (true) {
  462. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  463. case S:
  464. ;
  465. break;
  466. default:
  467. jj_la1[12] = jj_gen;
  468. break label_10;
  469. }
  470. jj_consume_token(S);
  471. }
  472. }
  473. }
  474. final public CSSNode namespaceDeclaration() throws ParseException {
  475. CSSNode node = null;
  476. Token start = null;
  477. Token ident = null;
  478. Token uri = null;
  479. Token end = null;
  480. try {
  481. start = jj_consume_token(NAMESPACE_SYM);
  482. label_11:
  483. while (true) {
  484. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  485. case S:
  486. ;
  487. break;
  488. default:
  489. jj_la1[13] = jj_gen;
  490. break label_11;
  491. }
  492. jj_consume_token(S);
  493. }
  494. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  495. case IDENT:
  496. ident = jj_consume_token(IDENT);
  497. label_12:
  498. while (true) {
  499. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  500. case S:
  501. ;
  502. break;
  503. default:
  504. jj_la1[14] = jj_gen;
  505. break label_12;
  506. }
  507. jj_consume_token(S);
  508. }
  509. break;
  510. default:
  511. jj_la1[15] = jj_gen;
  512. ;
  513. }
  514. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  515. case STRING:
  516. uri = jj_consume_token(STRING);
  517. break;
  518. case URL:
  519. uri = jj_consume_token(URL);
  520. break;
  521. default:
  522. jj_la1[16] = jj_gen;
  523. jj_consume_token(-1);
  524. throw new ParseException();
  525. }
  526. label_13:
  527. while (true) {
  528. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  529. case S:
  530. ;
  531. break;
  532. default:
  533. jj_la1[17] = jj_gen;
  534. break label_13;
  535. }
  536. jj_consume_token(S);
  537. }
  538. end = jj_consume_token(SEMICOLON);
  539. label_14:
  540. while (true) {
  541. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  542. case S:
  543. ;
  544. break;
  545. default:
  546. jj_la1[18] = jj_gen;
  547. break label_14;
  548. }
  549. jj_consume_token(S);
  550. }
  551. } catch (ParseException e) {
  552. addException(e);
  553. error_skipto(SEMICOLON);
  554. {if (true) return null;}
  555. }
  556. if (notNull(start, uri, end)) {
  557. String name = start.image + " " + (ident != null ? ident.image : "") + uri.image;
  558. node = new CSSNode(name);
  559. node.setStartLocation(getStartLocation(start));
  560. node.setEndLocation(getEndLocation(end));
  561. }
  562. {if (true) return node;}
  563. throw new Error("Missing return statement in function");
  564. }
  565. /**
  566. * The import statement
  567. *
  568. * @exception ParseException exception during the parse
  569. */
  570. final public CSSNode importDeclaration() throws ParseException {
  571. Token start = null;
  572. CSSNode medium = null;
  573. List<CSSNode> mediumList = new ArrayList<CSSNode>();
  574. Token uri = null;
  575. Token end = null;
  576. CSSNode node = null;
  577. try {
  578. start = jj_consume_token(IMPORT_SYM);
  579. label_15:
  580. while (true) {
  581. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  582. case S:
  583. ;
  584. break;
  585. default:
  586. jj_la1[19] = jj_gen;
  587. break label_15;
  588. }
  589. jj_consume_token(S);
  590. }
  591. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  592. case STRING:
  593. uri = jj_consume_token(STRING);
  594. break;
  595. case URL:
  596. uri = jj_consume_token(URL);
  597. break;
  598. default:
  599. jj_la1[20] = jj_gen;
  600. jj_consume_token(-1);
  601. throw new ParseException();
  602. }
  603. label_16:
  604. while (true) {
  605. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  606. case S:
  607. ;
  608. break;
  609. default:
  610. jj_la1[21] = jj_gen;
  611. break label_16;
  612. }
  613. jj_consume_token(S);
  614. }
  615. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  616. case IDENT:
  617. medium = medium();
  618. if (medium != null) mediumList.add(medium);
  619. label_17:
  620. while (true) {
  621. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  622. case COMMA:
  623. ;
  624. break;
  625. default:
  626. jj_la1[22] = jj_gen;
  627. break label_17;
  628. }
  629. jj_consume_token(COMMA);
  630. label_18:
  631. while (true) {
  632. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  633. case S:
  634. ;
  635. break;
  636. default:
  637. jj_la1[23] = jj_gen;
  638. break label_18;
  639. }
  640. jj_consume_token(S);
  641. }
  642. medium = medium();
  643. if (medium != null) mediumList.add(medium);
  644. }
  645. break;
  646. default:
  647. jj_la1[24] = jj_gen;
  648. ;
  649. }
  650. end = jj_consume_token(SEMICOLON);
  651. label_19:
  652. while (true) {
  653. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  654. case S:
  655. ;
  656. break;
  657. default:
  658. jj_la1[25] = jj_gen;
  659. break label_19;
  660. }
  661. jj_consume_token(S);
  662. }
  663. } catch (ParseException e) {
  664. addException(e);
  665. error_skipto(SEMICOLON);
  666. {if (true) return null;}
  667. }
  668. if (notNull(start, end)) {
  669. StringBuilder sb = new StringBuilder();
  670. for (CSSNode m : mediumList) {
  671. sb.append(m).append(',');
  672. }
  673. String mediumNames = sb.substring(0, Math.max(0, sb.length() - 1)); // trims the trailing comma
  674. String name = start.image + (uri != null ? " " + uri.image : "") + (mediumNames.length() > 0 ? " " + mediumNames : "");
  675. node = new CSSNode(name);
  676. node.setStartLocation(getStartLocation(start));
  677. node.setEndLocation(getEndLocation(end));
  678. }
  679. {if (true) return node;}
  680. throw new Error("Missing return statement in function");
  681. }
  682. final public CSSNode media() throws ParseException {
  683. Token start = null;
  684. Token mr = null;
  685. CSSNode medium = null;
  686. List<CSSNode> mlist = new ArrayList<CSSNode>();
  687. CSSNode mdecl = null;
  688. List<CSSNode> mdeclList = new ArrayList<CSSNode>();
  689. CSSNode ruleset = null;
  690. Token end = null;
  691. try {
  692. start = jj_consume_token(MEDIA_SYM);
  693. label_20:
  694. while (true) {
  695. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  696. case S:
  697. ;
  698. break;
  699. default:
  700. jj_la1[26] = jj_gen;
  701. break label_20;
  702. }
  703. jj_consume_token(S);
  704. }
  705. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  706. case MEDIARESTRICTOR:
  707. mr = jj_consume_token(MEDIARESTRICTOR);
  708. label_21:
  709. while (true) {
  710. jj_consume_token(S);
  711. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  712. case S:
  713. ;
  714. break;
  715. default:
  716. jj_la1[27] = jj_gen;
  717. break label_21;
  718. }
  719. }
  720. break;
  721. default:
  722. jj_la1[28] = jj_gen;
  723. ;
  724. }
  725. // </CSS3>
  726. medium = medium();
  727. if (medium != null) mlist.add(medium);
  728. label_22:
  729. while (true) {
  730. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  731. case COMMA:
  732. ;
  733. break;
  734. default:
  735. jj_la1[29] = jj_gen;
  736. break label_22;
  737. }
  738. jj_consume_token(COMMA);
  739. label_23:
  740. while (true) {
  741. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  742. case S:
  743. ;
  744. break;
  745. default:
  746. jj_la1[30] = jj_gen;
  747. break label_23;
  748. }
  749. jj_consume_token(S);
  750. }
  751. medium = medium();
  752. if (medium != null) mlist.add(medium);
  753. }
  754. label_24:
  755. while (true) {
  756. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  757. case AND:
  758. ;
  759. break;
  760. default:
  761. jj_la1[31] = jj_gen;
  762. break label_24;
  763. }
  764. jj_consume_token(AND);
  765. label_25:
  766. while (true) {
  767. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  768. case S:
  769. ;
  770. break;
  771. default:
  772. jj_la1[32] = jj_gen;
  773. break label_25;
  774. }
  775. jj_consume_token(S);
  776. }
  777. jj_consume_token(LPARAN);
  778. label_26:
  779. while (true) {
  780. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  781. case S:
  782. ;
  783. break;
  784. default:
  785. jj_la1[33] = jj_gen;
  786. break label_26;
  787. }
  788. jj_consume_token(S);
  789. }
  790. mdecl = mediadeclaration();
  791. if(mdecl != null) mdeclList.add(mdecl);
  792. jj_consume_token(RPARAN);
  793. label_27:
  794. while (true) {
  795. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  796. case S:
  797. ;
  798. break;
  799. default:
  800. jj_la1[34] = jj_gen;
  801. break label_27;
  802. }
  803. jj_consume_token(S);
  804. }
  805. }
  806. jj_consume_token(LBRACE);
  807. label_28:
  808. while (true) {
  809. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  810. case S:
  811. ;
  812. break;
  813. default:
  814. jj_la1[35] = jj_gen;
  815. break label_28;
  816. }
  817. jj_consume_token(S);
  818. }
  819. label_29:
  820. while (true) {
  821. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  822. case IDENT:
  823. case HASHIDENT:
  824. case HASH:
  825. case LBRACKET:
  826. case ANY:
  827. case COLON:
  828. case LENGTH:
  829. case EMS:
  830. case EXS:
  831. case ANGLE:
  832. case TIME:
  833. case FREQ:
  834. case RESOLUTION:
  835. case DIMEN:
  836. case PSEUDOELEMENT_SYM:
  837. case CLASS:
  838. case FUNCTIONNOT:
  839. case 98:
  840. ;
  841. break;
  842. default:
  843. jj_la1[36] = jj_gen;
  844. break label_29;
  845. }
  846. ruleset = ruleSet();
  847. }
  848. end = jj_consume_token(RBRACE);
  849. label_30:
  850. while (true) {
  851. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  852. case S:
  853. ;
  854. break;
  855. default:
  856. jj_la1[37] = jj_gen;
  857. break label_30;
  858. }
  859. jj_consume_token(S);
  860. }
  861. } catch (ParseException e) {
  862. addException(e);
  863. error_skipto(RBRACE);
  864. {if (true) return null;}
  865. }
  866. if (notNull(start, end)) {
  867. CSSNode node = new CSSNode(start.image);
  868. if (mr != null) {
  869. node.addChild(createNode(mr));
  870. }
  871. node.addChildren(mlist);
  872. node.addChildren(mdeclList);
  873. node.setStartLocation(getStartLocation(start));
  874. node.setEndLocation(getEndLocation(end));
  875. {if (true) return node;}
  876. }
  877. {if (true) return null;}
  878. throw new Error("Missing return statement in function");
  879. }
  880. final public CSSNode medium() throws ParseException {
  881. Token t = null;
  882. t = jj_consume_token(IDENT);
  883. label_31:
  884. while (true) {
  885. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  886. case S:
  887. ;
  888. break;
  889. default:
  890. jj_la1[38] = jj_gen;
  891. break label_31;
  892. }
  893. jj_consume_token(S);
  894. }
  895. if (notNull(t)) {
  896. {if (true) return createNode(t);}
  897. }
  898. {if (true) return null;}
  899. throw new Error("Missing return statement in function");
  900. }
  901. final public CSSNode unused_production_generic_syntax() throws ParseException {
  902. Token start = null;
  903. CSSNode term = null;
  904. Token end = null;
  905. try {
  906. start = jj_consume_token(LPARAN);
  907. label_32:
  908. while (true) {
  909. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  910. case S:
  911. ;
  912. break;
  913. default:
  914. jj_la1[39] = jj_gen;
  915. break label_32;
  916. }
  917. jj_consume_token(S);
  918. }
  919. term = term();
  920. end = jj_consume_token(RPARAN);
  921. } catch (ParseException e) {
  922. addException(e);
  923. error_skipto(RPARAN);
  924. {if (true) return null;}
  925. }
  926. if (notNull(start, term, end)) {
  927. CSSNode node = new CSSNode('[' + term.getName() + ']');
  928. node.addChildren(term.getChildren());
  929. node.setStartLocation(getStartLocation(start));
  930. node.setEndLocation(getEndLocation(end));
  931. {if (true) return node;}
  932. }
  933. {if (true) return null;}
  934. throw new Error("Missing return statement in function");
  935. }
  936. final public CSSNode definition() throws ParseException {
  937. Token start = null;
  938. CSSNode term = null;
  939. Token end = null;
  940. try {
  941. start = jj_consume_token(LBRACKET);
  942. label_33:
  943. while (true) {
  944. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  945. case S:
  946. ;
  947. break;
  948. default:
  949. jj_la1[40] = jj_gen;
  950. break label_33;
  951. }
  952. jj_consume_token(S);
  953. }
  954. term = term();
  955. end = jj_consume_token(RBRACKET);
  956. } catch (ParseException e) {
  957. addException(e);
  958. error_skipto(RBRACKET);
  959. {if (true) return null;}
  960. }
  961. if (notNull(start, term, end)) {
  962. CSSNode node = new CSSNode('[' + term.getName() + ']');
  963. node.addChildren(term.getChildren());
  964. node.setStartLocation(getStartLocation(start));
  965. node.setEndLocation(getEndLocation(end));
  966. }
  967. throw new Error("Missing return statement in function");
  968. }
  969. final public CSSNode page() throws ParseException {
  970. CSSNode node = new CSSNode();
  971. CSSNode child = null;
  972. List<CSSNode> contents = null;
  973. Token start = null;
  974. Token i = null;
  975. Token end = null;
  976. try {
  977. start = jj_consume_token(PAGE_SYM);
  978. if (start != null) node.setName(start.image);
  979. label_34:
  980. while (true) {
  981. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  982. case S:
  983. ;
  984. break;
  985. default:
  986. jj_la1[41] = jj_gen;
  987. break label_34;
  988. }
  989. jj_consume_token(S);
  990. }
  991. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  992. case IDENT:
  993. i = jj_consume_token(IDENT);
  994. if (i != null) node.setName(node.getName() + ' ' + i.image);
  995. label_35:
  996. while (true) {
  997. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  998. case S:
  999. ;
  1000. break;
  1001. default:
  1002. jj_la1[42] = jj_gen;
  1003. break label_35;
  1004. }
  1005. jj_consume_token(S);
  1006. }
  1007. break;
  1008. default:
  1009. jj_la1[43] = jj_gen;
  1010. ;
  1011. }
  1012. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1013. case COLON:
  1014. child = pseudo_page();
  1015. if (child != null) node.addChild(child);
  1016. break;
  1017. default:
  1018. jj_la1[44] = jj_gen;
  1019. ;
  1020. }
  1021. jj_consume_token(LBRACE);
  1022. label_36:
  1023. while (true) {
  1024. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1025. case S:
  1026. ;
  1027. break;
  1028. default:
  1029. jj_la1[45] = jj_gen;
  1030. break label_36;
  1031. }
  1032. jj_consume_token(S);
  1033. }
  1034. contents = pageContent();
  1035. if (contents != null) node.addChildren(contents);
  1036. end = jj_consume_token(RBRACE);
  1037. label_37:
  1038. while (true) {
  1039. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1040. case S:
  1041. ;
  1042. break;
  1043. default:
  1044. jj_la1[46] = jj_gen;
  1045. break label_37;
  1046. }
  1047. jj_consume_token(S);
  1048. }
  1049. } catch (ParseException e) {
  1050. addException(e);
  1051. error_skipto(RBRACE);
  1052. {if (true) return null;}
  1053. }
  1054. if (notNull(start, end)) {
  1055. node.setStartLocation(getStartLocation(start));
  1056. node.setEndLocation(getEndLocation(end));
  1057. {if (true) return node;}
  1058. }
  1059. {if (true) return null;}
  1060. throw new Error("Missing return statement in function");
  1061. }
  1062. final public List<CSSNode> pageContent() throws ParseException {
  1063. CSSNode node = null;
  1064. List<CSSNode> list = null;
  1065. try {
  1066. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1067. case ATTOP:
  1068. case ATRIGHT:
  1069. case ATBOTTOM:
  1070. case ATLEFT:
  1071. node = prefAtRule();
  1072. break;
  1073. default:
  1074. jj_la1[47] = jj_gen;
  1075. list = declarations();
  1076. }
  1077. } catch (ParseException e) {
  1078. addException(e);
  1079. error_skipto(RBRACE);
  1080. {if (true) return null;}
  1081. }
  1082. if (node != null) {
  1083. list = new ArrayList<CSSNode>();
  1084. list.add(node);
  1085. {if (true) return list;}
  1086. }
  1087. else if (list != null) {
  1088. {if (true) return list;}
  1089. }
  1090. {if (true) return null;}
  1091. throw new Error("Missing return statement in function");
  1092. }
  1093. final public CSSNode prefAtRule() throws ParseException {
  1094. Token start = null;
  1095. List<CSSNode> decls = null;
  1096. Token end = null;
  1097. try {
  1098. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1099. case ATTOP:
  1100. start = jj_consume_token(ATTOP);
  1101. break;
  1102. case ATBOTTOM:
  1103. start = jj_consume_token(ATBOTTOM);
  1104. break;
  1105. case ATLEFT:
  1106. start = jj_consume_token(ATLEFT);
  1107. break;
  1108. case ATRIGHT:
  1109. start = jj_consume_token(ATRIGHT);
  1110. break;
  1111. default:
  1112. jj_la1[48] = jj_gen;
  1113. jj_consume_token(-1);
  1114. throw new ParseException();
  1115. }
  1116. label_38:
  1117. while (true) {
  1118. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1119. case S:
  1120. ;
  1121. break;
  1122. default:
  1123. jj_la1[49] = jj_gen;
  1124. break label_38;
  1125. }
  1126. jj_consume_token(S);
  1127. }
  1128. jj_consume_token(LBRACE);
  1129. label_39:
  1130. while (true) {
  1131. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1132. case S:
  1133. ;
  1134. break;
  1135. default:
  1136. jj_la1[50] = jj_gen;
  1137. break label_39;
  1138. }
  1139. jj_consume_token(S);
  1140. }
  1141. decls = declarations();
  1142. end = jj_consume_token(RBRACE);
  1143. label_40:
  1144. while (true) {
  1145. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1146. case S:
  1147. ;
  1148. break;
  1149. default:
  1150. jj_la1[51] = jj_gen;
  1151. break label_40;
  1152. }
  1153. jj_consume_token(S);
  1154. }
  1155. } catch (ParseException e) {
  1156. addException(e);
  1157. error_skipto(RBRACE);
  1158. {if (true) return null;}
  1159. }
  1160. if (notNull(start, decls, end)) {
  1161. CSSNode node = new CSSNode(start.image);
  1162. node.addChildren(decls);
  1163. node.setStartLocation(getStartLocation(start));
  1164. node.setEndLocation(getEndLocation(end));
  1165. {if (true) return node;}
  1166. }
  1167. {if (true) return null;}
  1168. throw new Error("Missing return statement in function");
  1169. }
  1170. final public CSSNode pseudo_page() throws ParseException {
  1171. Token start = null;
  1172. Token t = null;
  1173. try {
  1174. start = jj_consume_token(COLON);
  1175. t = jj_consume_token(IDENT);
  1176. label_41:
  1177. while (true) {
  1178. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1179. case S:
  1180. ;
  1181. break;
  1182. default:
  1183. jj_la1[52] = jj_gen;
  1184. break label_41;
  1185. }
  1186. jj_consume_token(S);
  1187. }
  1188. } catch (ParseException e) {
  1189. addException(e);
  1190. {if (true) return null;}
  1191. }
  1192. if (notNull(t)) {
  1193. CSSNode node = new CSSNode(':' + t.image);
  1194. node.setStartLocation(getStartLocation(start));
  1195. node.setEndLocation(getEndLocation(start));
  1196. {if (true) return node;}
  1197. }
  1198. {if (true) return null;}
  1199. throw new Error("Missing return statement in function");
  1200. }
  1201. final public CSSNode fontFace() throws ParseException {
  1202. Token start = null;
  1203. List<CSSNode> decls = null;
  1204. Token end = null;
  1205. try {
  1206. start = jj_consume_token(FONT_FACE_SYM);
  1207. label_42:
  1208. while (true) {
  1209. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1210. case S:
  1211. ;
  1212. break;
  1213. default:
  1214. jj_la1[53] = jj_gen;
  1215. break label_42;
  1216. }
  1217. jj_consume_token(S);
  1218. }
  1219. jj_consume_token(LBRACE);
  1220. label_43:
  1221. while (true) {
  1222. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1223. case S:
  1224. ;
  1225. break;
  1226. default:
  1227. jj_la1[54] = jj_gen;
  1228. break label_43;
  1229. }
  1230. jj_consume_token(S);
  1231. }
  1232. decls = declarations();
  1233. end = jj_consume_token(RBRACE);
  1234. label_44:
  1235. while (true) {
  1236. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1237. case S:
  1238. ;
  1239. break;
  1240. default:
  1241. jj_la1[55] = jj_gen;
  1242. break label_44;
  1243. }
  1244. jj_consume_token(S);
  1245. }
  1246. } catch (ParseException e) {
  1247. addException(e);
  1248. error_skipto(RBRACE);
  1249. {if (true) return null;}
  1250. }
  1251. if (notNull(start, decls, end)) {
  1252. CSSNode node = new CSSNode(start.image);
  1253. node.addChildren(decls);
  1254. node.setStartLocation(getStartLocation(start));
  1255. node.setEndLocation(getEndLocation(end));
  1256. {if (true) return node;}
  1257. }
  1258. {if (true) return null;}
  1259. throw new Error("Missing return statement in function");
  1260. }
  1261. final public CSSNode colorprofile() throws ParseException {
  1262. Token start = null;
  1263. List<CSSNode> decls = null;
  1264. Token end = null;
  1265. try {
  1266. start = jj_consume_token(COLOR_PROFILE);
  1267. label_45:
  1268. while (true) {
  1269. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1270. case S:
  1271. ;
  1272. break;
  1273. default:
  1274. jj_la1[56] = jj_gen;
  1275. break label_45;
  1276. }
  1277. jj_consume_token(S);
  1278. }
  1279. jj_consume_token(LBRACE);
  1280. label_46:
  1281. while (true) {
  1282. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1283. case S:
  1284. ;
  1285. break;
  1286. default:
  1287. jj_la1[57] = jj_gen;
  1288. break label_46;
  1289. }
  1290. jj_consume_token(S);
  1291. }
  1292. decls = declarations();
  1293. end = jj_consume_token(RBRACE);
  1294. label_47:
  1295. while (true) {
  1296. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1297. case S:
  1298. ;
  1299. break;
  1300. default:
  1301. jj_la1[58] = jj_gen;
  1302. break label_47;
  1303. }
  1304. jj_consume_token(S);
  1305. }
  1306. } catch (ParseException e) {
  1307. addException(e);
  1308. error_skipto(RBRACE);
  1309. {if (true) return null;}
  1310. }
  1311. if (notNull(start, decls, end)) {
  1312. CSSNode node = new CSSNode(start.image);
  1313. node.addChildren(decls);
  1314. node.setStartLocation(getStartLocation(start));
  1315. node.setEndLocation(getEndLocation(end));
  1316. {if (true) return node;}
  1317. }
  1318. {if (true) return null;}
  1319. throw new Error("Missing return statement in function");
  1320. }
  1321. final public CSSNode preference() throws ParseException {
  1322. Token start = null;
  1323. List<CSSNode> decls = null;
  1324. Token end = null;
  1325. try {
  1326. start = jj_consume_token(PREF_SYM);
  1327. label_48:
  1328. while (true) {
  1329. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1330. case S:
  1331. ;
  1332. break;
  1333. default:
  1334. jj_la1[59] = jj_gen;
  1335. break label_48;
  1336. }
  1337. jj_consume_token(S);
  1338. }
  1339. jj_consume_token(LBRACE);
  1340. label_49:
  1341. while (true) {
  1342. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1343. case S:
  1344. ;
  1345. break;
  1346. default:
  1347. jj_la1[60] = jj_gen;
  1348. break label_49;
  1349. }
  1350. jj_consume_token(S);
  1351. }
  1352. decls = declarations();
  1353. end = jj_consume_token(RBRACE);
  1354. label_50:
  1355. while (true) {
  1356. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1357. case S:
  1358. ;
  1359. break;
  1360. default:
  1361. jj_la1[61] = jj_gen;
  1362. break label_50;
  1363. }
  1364. jj_consume_token(S);
  1365. }
  1366. } catch (ParseException e) {
  1367. addException(e);
  1368. error_skipto(RBRACE);
  1369. {if (true) return null;}
  1370. }
  1371. if (notNull(start, decls, end)) {
  1372. CSSNode node = new CSSNode(start.image);
  1373. node.addChildren(decls);
  1374. node.setStartLocation(getStartLocation(start));
  1375. node.setEndLocation(getEndLocation(end));
  1376. {if (true) return node;}
  1377. }
  1378. {if (true) return null;}
  1379. throw new Error("Missing return statement in function");
  1380. }
  1381. final public CSSNode phoneticAlphabet() throws ParseException {
  1382. Token start = null;
  1383. Token middle = null;
  1384. Token end = null;
  1385. try {
  1386. start = jj_consume_token(PHONETIC_ALPHABET_SYM);
  1387. label_51:
  1388. while (true) {
  1389. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1390. case S:
  1391. ;
  1392. break;
  1393. default:
  1394. jj_la1[62] = jj_gen;
  1395. break label_51;
  1396. }
  1397. jj_consume_token(S);
  1398. }
  1399. middle = jj_consume_token(STRING);
  1400. label_52:
  1401. while (true) {
  1402. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1403. case S:
  1404. ;
  1405. break;
  1406. default:
  1407. jj_la1[63] = jj_gen;
  1408. break label_52;
  1409. }
  1410. jj_consume_token(S);
  1411. }
  1412. end = jj_consume_token(SEMICOLON);
  1413. } catch (ParseException e) {
  1414. addException(e);
  1415. error_skipto(SEMICOLON);
  1416. {if (true) return null;}
  1417. }
  1418. if (notNull(start, middle, end)) {
  1419. StringBuilder name = new StringBuilder();
  1420. name.append(start.image).append(' ').append(middle.image);
  1421. CSSNode node = new CSSNode(name.toString());
  1422. node.setStartLocation(getStartLocation(start));
  1423. node.setEndLocation(getEndLocation(end));
  1424. {if (true) return node;}
  1425. }
  1426. {if (true) return null;}
  1427. throw new Error("Missing return statement in function");
  1428. }
  1429. final public CSSNode atRuleDeclaration() throws ParseException {
  1430. Token t = null;
  1431. try {
  1432. t = jj_consume_token(ATKEYWORD);
  1433. } catch (ParseException e) {
  1434. addException(e);
  1435. error_skipto(RBRACE);
  1436. {if (true) return null;}
  1437. }
  1438. if (notNull(t)) {
  1439. {if (true) return createNode(t);}
  1440. }
  1441. {if (true) return null;}
  1442. throw new Error("Missing return statement in function");
  1443. }
  1444. final public char operator() throws ParseException {
  1445. char op = ' ';
  1446. try {
  1447. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1448. case COMMA:
  1449. case DIV:
  1450. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1451. case DIV:
  1452. jj_consume_token(DIV);
  1453. op = '/';
  1454. break;
  1455. case COMMA:
  1456. jj_consume_token(COMMA);
  1457. op = ',';
  1458. break;
  1459. default:
  1460. jj_la1[64] = jj_gen;
  1461. jj_consume_token(-1);
  1462. throw new ParseException();
  1463. }
  1464. label_53:
  1465. while (true) {
  1466. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1467. case S:
  1468. ;
  1469. break;
  1470. default:
  1471. jj_la1[65] = jj_gen;
  1472. break label_53;
  1473. }
  1474. jj_consume_token(S);
  1475. }
  1476. break;
  1477. default:
  1478. jj_la1[66] = jj_gen;
  1479. ;
  1480. }
  1481. } catch (ParseException e) {
  1482. addException(e);
  1483. error_skipto(RBRACE);
  1484. {if (true) return op;}
  1485. }
  1486. {if (true) return op;}
  1487. throw new Error("Missing return statement in function");
  1488. }
  1489. final public char combinator() throws ParseException {
  1490. char connector = ' ';
  1491. try {
  1492. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1493. case PLUS:
  1494. case GREATER:
  1495. case TILDE:
  1496. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1497. case PLUS:
  1498. jj_consume_token(PLUS);
  1499. connector = '+' ;
  1500. break;
  1501. case GREATER:
  1502. jj_consume_token(GREATER);
  1503. connector = '>' ;
  1504. break;
  1505. case TILDE:
  1506. jj_consume_token(TILDE);
  1507. connector = '~' ;
  1508. break;
  1509. default:
  1510. jj_la1[67] = jj_gen;
  1511. jj_consume_token(-1);
  1512. throw new ParseException();
  1513. }
  1514. label_54:
  1515. while (true) {
  1516. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1517. case S:
  1518. ;
  1519. break;
  1520. default:
  1521. jj_la1[68] = jj_gen;
  1522. break label_54;
  1523. }
  1524. jj_consume_token(S);
  1525. }
  1526. break;
  1527. case S:
  1528. label_55:
  1529. while (true) {
  1530. jj_consume_token(S);
  1531. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1532. case S:
  1533. ;
  1534. break;
  1535. default:
  1536. jj_la1[69] = jj_gen;
  1537. break label_55;
  1538. }
  1539. }
  1540. connector = ' ' ;
  1541. break;
  1542. default:
  1543. jj_la1[70] = jj_gen;
  1544. jj_consume_token(-1);
  1545. throw new ParseException();
  1546. }
  1547. } catch (ParseException e) {
  1548. addException(e);
  1549. error_skipto(RBRACE);
  1550. {if (true) return connector;}
  1551. }
  1552. {if (true) return connector;}
  1553. throw new Error("Missing return statement in function");
  1554. }
  1555. final public char unaryOperator() throws ParseException {
  1556. char unary;
  1557. try {
  1558. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1559. case MINUS:
  1560. jj_consume_token(MINUS);
  1561. unary = '-';
  1562. break;
  1563. case PLUS:
  1564. jj_consume_token(PLUS);
  1565. unary = '+';
  1566. break;
  1567. default:
  1568. jj_la1[71] = jj_gen;
  1569. jj_consume_token(-1);
  1570. throw new ParseException();
  1571. }
  1572. } catch (ParseException e) {
  1573. addException(e);
  1574. error_skipto(RBRACE);
  1575. {if (true) return ' ';}
  1576. }
  1577. {if (true) return unary;}
  1578. throw new Error("Missing return statement in function");
  1579. }
  1580. final public CSSNode property() throws ParseException {
  1581. Token t = null;
  1582. try {
  1583. t = jj_consume_token(IDENT);
  1584. label_56:
  1585. while (true) {
  1586. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1587. case S:
  1588. ;
  1589. break;
  1590. default:
  1591. jj_la1[72] = jj_gen;
  1592. break label_56;
  1593. }
  1594. jj_consume_token(S);
  1595. }
  1596. } catch (ParseException e) {
  1597. addException(e);
  1598. error_skipto(RBRACE);
  1599. {if (true) return null;}
  1600. }
  1601. if (notNull(t)) {
  1602. {if (true) return createNode(t);}
  1603. }
  1604. {if (true) return null;}
  1605. throw new Error("Missing return statement in function");
  1606. }
  1607. final public CSSNode ruleSet() throws ParseException {
  1608. CSSNode sel = null;
  1609. List<CSSNode> selectors = new ArrayList<CSSNode>();
  1610. List<CSSNode> decls = null;
  1611. Token end = null;
  1612. try {
  1613. sel = selector();
  1614. if (sel != null) selectors.add(sel);
  1615. label_57:
  1616. while (true) {
  1617. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1618. case COMMA:
  1619. ;
  1620. break;
  1621. default:
  1622. jj_la1[73] = jj_gen;
  1623. break label_57;
  1624. }
  1625. jj_consume_token(COMMA);
  1626. label_58:
  1627. while (true) {
  1628. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1629. case S:
  1630. ;
  1631. break;
  1632. default:
  1633. jj_la1[74] = jj_gen;
  1634. break label_58;
  1635. }
  1636. jj_consume_token(S);
  1637. }
  1638. sel = selector();
  1639. if (sel != null) selectors.add(sel);
  1640. }
  1641. jj_consume_token(LBRACE);
  1642. label_59:
  1643. while (true) {
  1644. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1645. case S:
  1646. ;
  1647. break;
  1648. default:
  1649. jj_la1[75] = jj_gen;
  1650. break label_59;
  1651. }
  1652. jj_consume_token(S);
  1653. }
  1654. decls = declarations();
  1655. end = jj_consume_token(RBRACE);
  1656. label_60:
  1657. while (true) {
  1658. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1659. case S:
  1660. ;
  1661. break;
  1662. default:
  1663. jj_la1[76] = jj_gen;
  1664. break label_60;
  1665. }
  1666. jj_consume_token(S);
  1667. }
  1668. } catch (ParseException e) {
  1669. addException(e);
  1670. error_skipto(RBRACE);
  1671. {if (true) return null;}
  1672. }
  1673. if (selectors.size() > 0 && notNull(decls, end)) {
  1674. StringBuilder sb = new StringBuilder();
  1675. for (CSSNode s : selectors) {
  1676. sb.append(s.getName()).append(',');
  1677. }
  1678. String name = sb.substring(0, Math.max(0, sb.length() - 1));
  1679. CSSNode node = new CSSNode(name);
  1680. node.addChildren(decls);
  1681. node.setStartLocation(selectors.get(0).getStartLocation());
  1682. node.setEndLocation(getEndLocation(end));
  1683. {if (true) return node;}
  1684. }
  1685. {if (true) return null;}
  1686. throw new Error("Missing return statement in function");
  1687. }
  1688. final public List<CSSNode> declarations() throws ParseException {
  1689. CSSNode node = null;
  1690. List<CSSNode> nodes = new ArrayList<CSSNode>();
  1691. Token semi;
  1692. try {
  1693. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1694. case IDENT:
  1695. node = declaration();
  1696. if (node != null) nodes.add(node);
  1697. break;
  1698. default:
  1699. jj_la1[77] = jj_gen;
  1700. ;
  1701. }
  1702. label_61:
  1703. while (true) {
  1704. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1705. case SEMICOLON:
  1706. ;
  1707. break;
  1708. default:
  1709. jj_la1[78] = jj_gen;
  1710. break label_61;
  1711. }
  1712. semi = jj_consume_token(SEMICOLON);
  1713. node.setEndLocation(getEndLocation(semi));
  1714. label_62:
  1715. while (true) {
  1716. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1717. case S:
  1718. ;
  1719. break;
  1720. default:
  1721. jj_la1[79] = jj_gen;
  1722. break label_62;
  1723. }
  1724. jj_consume_token(S);
  1725. }
  1726. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1727. case IDENT:
  1728. node = declaration();
  1729. if (node != null) nodes.add(node);
  1730. break;
  1731. default:
  1732. jj_la1[80] = jj_gen;
  1733. ;
  1734. }
  1735. }
  1736. } catch (ParseException e) {
  1737. addException(e);
  1738. error_skipto(RBRACE);
  1739. {if (true) return null;}
  1740. }
  1741. {if (true) return nodes;}
  1742. throw new Error("Missing return statement in function");
  1743. }
  1744. final public CSSNode selector() throws ParseException {
  1745. CSSNode node = null;
  1746. List<CSSNode> nodes = new ArrayList<CSSNode>();
  1747. char c;
  1748. List<Character> combs = new ArrayList<Character>();
  1749. try {
  1750. node = simple_selector();
  1751. if(node != null) nodes.add(node);
  1752. label_63:
  1753. while (true) {
  1754. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1755. case S:
  1756. case PLUS:
  1757. case GREATER:
  1758. case TILDE:
  1759. ;
  1760. break;
  1761. default:
  1762. jj_la1[81] = jj_gen;
  1763. break label_63;
  1764. }
  1765. c = combinator();
  1766. combs.add(c);
  1767. node = simple_selector();
  1768. if(node != null) nodes.add(node);
  1769. }
  1770. } catch (ParseException e) {
  1771. addException(e);
  1772. error_skipto(RBRACE);
  1773. {if (true) return null;}
  1774. }
  1775. if (nodes.size() > 0) {
  1776. StringBuilder sb = new StringBuilder();
  1777. for (int i = 0; i < nodes.size(); i++) {
  1778. sb.append(nodes.get(i).getName());
  1779. if (combs.size() < i) {
  1780. sb.append(combs.get(i));
  1781. }
  1782. }
  1783. node = new CSSNode(sb.toString());
  1784. node.setStartLocation(nodes.get(0).getStartLocation());
  1785. node.setEndLocation(nodes.get(nodes.size() - 1).getEndLocation());
  1786. {if (true) return node;}
  1787. }
  1788. {if (true) return null;}
  1789. throw new E

Large files files are truncated, but you can click here to view the full file