1. /* Generated By:JavaCC: Do not edit this line. XPathParser.java */
  2. package org.apache.commons.jxpath.ri.parser;
  3. import org.apache.commons.jxpath.ri.Compiler;
  4. import java.util.ArrayList;
  5. public class XPathParser implements XPathParserConstants {
  6. private Compiler compiler;
  7. public void setCompiler(Compiler compiler){
  8. this.compiler = compiler;
  9. }
  10. private String unescape(String string){
  11. int index = string.indexOf("'");
  12. while (index != -1){
  13. string = string.substring(0, index) + "\'" + string.substring(index + 6);
  14. index = string.indexOf("'");
  15. }
  16. index = string.indexOf(""");
  17. while (index != -1){
  18. string = string.substring(0, index) + "\"" + string.substring(index + 6);
  19. index = string.indexOf(""");
  20. }
  21. return string;
  22. }
  23. // Note: XPath does not have reserved words, so we have to include all these terminals
  24. final public String NCName() throws ParseException {
  25. switch (jj_nt.kind) {
  26. case OR:
  27. case AND:
  28. case MOD:
  29. case DIV:
  30. case NCName:
  31. NCName_Without_CoreFunctions();
  32. break;
  33. case NODE:
  34. jj_consume_token(NODE);
  35. break;
  36. case TEXT:
  37. jj_consume_token(TEXT);
  38. break;
  39. case COMMENT:
  40. jj_consume_token(COMMENT);
  41. break;
  42. case PI:
  43. jj_consume_token(PI);
  44. break;
  45. case FUNCTION_LAST:
  46. jj_consume_token(FUNCTION_LAST);
  47. break;
  48. case FUNCTION_POSITION:
  49. jj_consume_token(FUNCTION_POSITION);
  50. break;
  51. case FUNCTION_COUNT:
  52. jj_consume_token(FUNCTION_COUNT);
  53. break;
  54. case FUNCTION_ID:
  55. jj_consume_token(FUNCTION_ID);
  56. break;
  57. case FUNCTION_LOCAL_NAME:
  58. jj_consume_token(FUNCTION_LOCAL_NAME);
  59. break;
  60. case FUNCTION_NAMESPACE_URI:
  61. jj_consume_token(FUNCTION_NAMESPACE_URI);
  62. break;
  63. case FUNCTION_NAME:
  64. jj_consume_token(FUNCTION_NAME);
  65. break;
  66. case FUNCTION_STRING:
  67. jj_consume_token(FUNCTION_STRING);
  68. break;
  69. case FUNCTION_CONCAT:
  70. jj_consume_token(FUNCTION_CONCAT);
  71. break;
  72. case FUNCTION_STARTS_WITH:
  73. jj_consume_token(FUNCTION_STARTS_WITH);
  74. break;
  75. case FUNCTION_CONTAINS:
  76. jj_consume_token(FUNCTION_CONTAINS);
  77. break;
  78. case FUNCTION_SUBSTRING_BEFORE:
  79. jj_consume_token(FUNCTION_SUBSTRING_BEFORE);
  80. break;
  81. case FUNCTION_SUBSTRING_AFTER:
  82. jj_consume_token(FUNCTION_SUBSTRING_AFTER);
  83. break;
  84. case FUNCTION_SUBSTRING:
  85. jj_consume_token(FUNCTION_SUBSTRING);
  86. break;
  87. case FUNCTION_STRING_LENGTH:
  88. jj_consume_token(FUNCTION_STRING_LENGTH);
  89. break;
  90. case FUNCTION_NORMALIZE_SPACE:
  91. jj_consume_token(FUNCTION_NORMALIZE_SPACE);
  92. break;
  93. case FUNCTION_TRANSLATE:
  94. jj_consume_token(FUNCTION_TRANSLATE);
  95. break;
  96. case FUNCTION_BOOLEAN:
  97. jj_consume_token(FUNCTION_BOOLEAN);
  98. break;
  99. case FUNCTION_NOT:
  100. jj_consume_token(FUNCTION_NOT);
  101. break;
  102. case FUNCTION_TRUE:
  103. jj_consume_token(FUNCTION_TRUE);
  104. break;
  105. case FUNCTION_FALSE:
  106. jj_consume_token(FUNCTION_FALSE);
  107. break;
  108. case FUNCTION_NULL:
  109. jj_consume_token(FUNCTION_NULL);
  110. break;
  111. case FUNCTION_LANG:
  112. jj_consume_token(FUNCTION_LANG);
  113. break;
  114. case FUNCTION_NUMBER:
  115. jj_consume_token(FUNCTION_NUMBER);
  116. break;
  117. case FUNCTION_SUM:
  118. jj_consume_token(FUNCTION_SUM);
  119. break;
  120. case FUNCTION_FLOOR:
  121. jj_consume_token(FUNCTION_FLOOR);
  122. break;
  123. case FUNCTION_CEILING:
  124. jj_consume_token(FUNCTION_CEILING);
  125. break;
  126. case FUNCTION_ROUND:
  127. jj_consume_token(FUNCTION_ROUND);
  128. break;
  129. case FUNCTION_KEY:
  130. jj_consume_token(FUNCTION_KEY);
  131. break;
  132. case FUNCTION_FORMAT_NUMBER:
  133. jj_consume_token(FUNCTION_FORMAT_NUMBER);
  134. break;
  135. default:
  136. jj_la1[0] = jj_gen;
  137. jj_consume_token(-1);
  138. throw new ParseException();
  139. }
  140. {if (true) return token.image;}
  141. throw new Error("Missing return statement in function");
  142. }
  143. final public String NCName_Without_CoreFunctions() throws ParseException {
  144. switch (jj_nt.kind) {
  145. case NCName:
  146. jj_consume_token(NCName);
  147. break;
  148. case OR:
  149. jj_consume_token(OR);
  150. break;
  151. case AND:
  152. jj_consume_token(AND);
  153. break;
  154. case MOD:
  155. jj_consume_token(MOD);
  156. break;
  157. case DIV:
  158. jj_consume_token(DIV);
  159. break;
  160. default:
  161. jj_la1[1] = jj_gen;
  162. jj_consume_token(-1);
  163. throw new ParseException();
  164. }
  165. {if (true) return token.image;}
  166. throw new Error("Missing return statement in function");
  167. }
  168. final public int CoreFunctionName() throws ParseException {
  169. int code;
  170. switch (jj_nt.kind) {
  171. case FUNCTION_LAST:
  172. jj_consume_token(FUNCTION_LAST);
  173. code = Compiler.FUNCTION_LAST;
  174. break;
  175. case FUNCTION_POSITION:
  176. jj_consume_token(FUNCTION_POSITION);
  177. code = Compiler.FUNCTION_POSITION;
  178. break;
  179. case FUNCTION_COUNT:
  180. jj_consume_token(FUNCTION_COUNT);
  181. code = Compiler.FUNCTION_COUNT;
  182. break;
  183. case FUNCTION_ID:
  184. jj_consume_token(FUNCTION_ID);
  185. code = Compiler.FUNCTION_ID;
  186. break;
  187. case FUNCTION_LOCAL_NAME:
  188. jj_consume_token(FUNCTION_LOCAL_NAME);
  189. code = Compiler.FUNCTION_LOCAL_NAME;
  190. break;
  191. case FUNCTION_NAMESPACE_URI:
  192. jj_consume_token(FUNCTION_NAMESPACE_URI);
  193. code = Compiler.FUNCTION_NAMESPACE_URI;
  194. break;
  195. case FUNCTION_NAME:
  196. jj_consume_token(FUNCTION_NAME);
  197. code = Compiler.FUNCTION_NAME;
  198. break;
  199. case FUNCTION_STRING:
  200. jj_consume_token(FUNCTION_STRING);
  201. code = Compiler.FUNCTION_STRING;
  202. break;
  203. case FUNCTION_CONCAT:
  204. jj_consume_token(FUNCTION_CONCAT);
  205. code = Compiler.FUNCTION_CONCAT;
  206. break;
  207. case FUNCTION_STARTS_WITH:
  208. jj_consume_token(FUNCTION_STARTS_WITH);
  209. code = Compiler.FUNCTION_STARTS_WITH;
  210. break;
  211. case FUNCTION_CONTAINS:
  212. jj_consume_token(FUNCTION_CONTAINS);
  213. code = Compiler.FUNCTION_CONTAINS;
  214. break;
  215. case FUNCTION_SUBSTRING_BEFORE:
  216. jj_consume_token(FUNCTION_SUBSTRING_BEFORE);
  217. code = Compiler.FUNCTION_SUBSTRING_BEFORE;
  218. break;
  219. case FUNCTION_SUBSTRING_AFTER:
  220. jj_consume_token(FUNCTION_SUBSTRING_AFTER);
  221. code = Compiler.FUNCTION_SUBSTRING_AFTER;
  222. break;
  223. case FUNCTION_SUBSTRING:
  224. jj_consume_token(FUNCTION_SUBSTRING);
  225. code = Compiler.FUNCTION_SUBSTRING;
  226. break;
  227. case FUNCTION_STRING_LENGTH:
  228. jj_consume_token(FUNCTION_STRING_LENGTH);
  229. code = Compiler.FUNCTION_STRING_LENGTH;
  230. break;
  231. case FUNCTION_NORMALIZE_SPACE:
  232. jj_consume_token(FUNCTION_NORMALIZE_SPACE);
  233. code = Compiler.FUNCTION_NORMALIZE_SPACE;
  234. break;
  235. case FUNCTION_TRANSLATE:
  236. jj_consume_token(FUNCTION_TRANSLATE);
  237. code = Compiler.FUNCTION_TRANSLATE;
  238. break;
  239. case FUNCTION_BOOLEAN:
  240. jj_consume_token(FUNCTION_BOOLEAN);
  241. code = Compiler.FUNCTION_BOOLEAN;
  242. break;
  243. case FUNCTION_NOT:
  244. jj_consume_token(FUNCTION_NOT);
  245. code = Compiler.FUNCTION_NOT;
  246. break;
  247. case FUNCTION_TRUE:
  248. jj_consume_token(FUNCTION_TRUE);
  249. code = Compiler.FUNCTION_TRUE;
  250. break;
  251. case FUNCTION_FALSE:
  252. jj_consume_token(FUNCTION_FALSE);
  253. code = Compiler.FUNCTION_FALSE;
  254. break;
  255. case FUNCTION_NULL:
  256. jj_consume_token(FUNCTION_NULL);
  257. code = Compiler.FUNCTION_NULL;
  258. break;
  259. case FUNCTION_LANG:
  260. jj_consume_token(FUNCTION_LANG);
  261. code = Compiler.FUNCTION_LANG;
  262. break;
  263. case FUNCTION_NUMBER:
  264. jj_consume_token(FUNCTION_NUMBER);
  265. code = Compiler.FUNCTION_NUMBER;
  266. break;
  267. case FUNCTION_SUM:
  268. jj_consume_token(FUNCTION_SUM);
  269. code = Compiler.FUNCTION_SUM;
  270. break;
  271. case FUNCTION_FLOOR:
  272. jj_consume_token(FUNCTION_FLOOR);
  273. code = Compiler.FUNCTION_FLOOR;
  274. break;
  275. case FUNCTION_CEILING:
  276. jj_consume_token(FUNCTION_CEILING);
  277. code = Compiler.FUNCTION_CEILING;
  278. break;
  279. case FUNCTION_ROUND:
  280. jj_consume_token(FUNCTION_ROUND);
  281. code = Compiler.FUNCTION_ROUND;
  282. break;
  283. case FUNCTION_KEY:
  284. jj_consume_token(FUNCTION_KEY);
  285. code = Compiler.FUNCTION_KEY;
  286. break;
  287. case FUNCTION_FORMAT_NUMBER:
  288. jj_consume_token(FUNCTION_FORMAT_NUMBER);
  289. code = Compiler.FUNCTION_FORMAT_NUMBER;
  290. break;
  291. default:
  292. jj_la1[2] = jj_gen;
  293. jj_consume_token(-1);
  294. throw new ParseException();
  295. }
  296. {if (true) return code;}
  297. throw new Error("Missing return statement in function");
  298. }
  299. final public Object QName() throws ParseException {
  300. String nc1, nc2 = null;
  301. nc1 = NCName();
  302. switch (jj_nt.kind) {
  303. case 79:
  304. jj_consume_token(79);
  305. nc2 = NCName();
  306. break;
  307. default:
  308. jj_la1[3] = jj_gen;
  309. ;
  310. }
  311. if (nc2 == null){
  312. {if (true) return compiler.qname(null, nc1);}
  313. }
  314. else {
  315. {if (true) return compiler.qname(nc1, nc2);}
  316. }
  317. throw new Error("Missing return statement in function");
  318. }
  319. final public Object QName_Without_CoreFunctions() throws ParseException {
  320. String nc1, nc2 = null;
  321. if (jj_2_1(2147483647)) {
  322. nc1 = NCName();
  323. jj_consume_token(79);
  324. nc2 = NCName();
  325. } else {
  326. switch (jj_nt.kind) {
  327. case OR:
  328. case AND:
  329. case MOD:
  330. case DIV:
  331. case NCName:
  332. nc1 = NCName_Without_CoreFunctions();
  333. break;
  334. default:
  335. jj_la1[4] = jj_gen;
  336. jj_consume_token(-1);
  337. throw new ParseException();
  338. }
  339. }
  340. if (nc2 == null){
  341. {if (true) return compiler.qname(null, nc1);}
  342. }
  343. else {
  344. {if (true) return compiler.qname(nc1, nc2);}
  345. }
  346. throw new Error("Missing return statement in function");
  347. }
  348. final public Object parseExpression() throws ParseException {
  349. Object ex;
  350. ex = Expression();
  351. jj_consume_token(0);
  352. {if (true) return ex;}
  353. throw new Error("Missing return statement in function");
  354. }
  355. /* ################################################################################### */
  356. /* XSLT Patterns (http://www.w3.org/1999/08/WD-xslt-19990813) */
  357. /* ################################################################################### */
  358. /* [XSLT1] Pattern ::= LocationPathPattern | Pattern '|' LocationPathPattern */
  359. //void Pattern() :
  360. //{}
  361. //{
  362. // LocationPathPattern() ( <UNION> LocationPathPattern() )* <EOF>
  363. //}
  364. //
  365. //
  366. ///* [XSLT2] LocationPathPattern ::=
  367. // '/' RelativePathPattern? | IdKeyPattern (('/' | '//' RelativePathPattern)? | '//'? RelativePathPattern
  368. //*/
  369. //
  370. //void LocationPathPattern() :
  371. //{}
  372. //{
  373. // <SLASH> ( RelativePathPattern() )?
  374. // | (
  375. // LOOKAHEAD(IdKeyPattern())
  376. // IdKeyPattern() ( ( <SLASH> | <SLASHSLASH>) RelativePathPattern() )?
  377. // | ( <SLASHSLASH> )? RelativePathPattern()
  378. // )
  379. //}
  380. //
  381. //
  382. //
  383. ///* [XSLT3] IdKeyPattern ::= 'id' '(' Literal ')' | 'key' '(' Literal ',' Literal ')' */
  384. //
  385. //void IdKeyPattern() :
  386. //{}
  387. //{
  388. // <ID> "(" <Literal> ")"
  389. // | <KEY> "(" <Literal> "," <Literal> ")"
  390. //}
  391. //
  392. //
  393. ///* [XSLT4] RelativePathPattern ::= StepPattern | RelativePathPattern '/' StepPattern
  394. // | RelativePathPattern '//' StepPattern
  395. //*/
  396. //void RelativePathPattern() :
  397. //{}
  398. //{
  399. // StepPattern() ( ( <SLASH>| <SLASHSLASH> ) StepPattern() )*
  400. //}
  401. //
  402. //
  403. ///* [XSLT5] StepPattern ::= AbbreviatedAxisSpecifier NodeTest Predicate* */
  404. //void StepPattern() :
  405. //{}
  406. //{
  407. // AbbreviatedAxisSpecifier() NodeTest() (Predicate())*
  408. //}
  409. // See XPath Syntax (http://www.w3.org/TR/xpath )
  410. //void XPath() :
  411. //{}
  412. //{
  413. // LocationPath()
  414. // <EOF>
  415. //}
  416. /* [1] LocationPath ::= RelativeLocationPath | AbsoluteLocationPath */
  417. final public Object LocationPath() throws ParseException {
  418. Object ex = null;
  419. switch (jj_nt.kind) {
  420. case OR:
  421. case AND:
  422. case MOD:
  423. case DIV:
  424. case NODE:
  425. case TEXT:
  426. case COMMENT:
  427. case PI:
  428. case AXIS_SELF:
  429. case AXIS_CHILD:
  430. case AXIS_PARENT:
  431. case AXIS_ANCESTOR:
  432. case AXIS_ATTRIBUTE:
  433. case AXIS_NAMESPACE:
  434. case AXIS_PRECEDING:
  435. case AXIS_FOLLOWING:
  436. case AXIS_DESCENDANT:
  437. case AXIS_ANCESTOR_OR_SELF:
  438. case AXIS_FOLLOWING_SIBLING:
  439. case AXIS_PRECEDING_SIBLING:
  440. case AXIS_DESCENDANT_OR_SELF:
  441. case FUNCTION_LAST:
  442. case FUNCTION_POSITION:
  443. case FUNCTION_COUNT:
  444. case FUNCTION_ID:
  445. case FUNCTION_KEY:
  446. case FUNCTION_LOCAL_NAME:
  447. case FUNCTION_NAMESPACE_URI:
  448. case FUNCTION_NAME:
  449. case FUNCTION_STRING:
  450. case FUNCTION_CONCAT:
  451. case FUNCTION_STARTS_WITH:
  452. case FUNCTION_CONTAINS:
  453. case FUNCTION_SUBSTRING_BEFORE:
  454. case FUNCTION_SUBSTRING_AFTER:
  455. case FUNCTION_SUBSTRING:
  456. case FUNCTION_STRING_LENGTH:
  457. case FUNCTION_NORMALIZE_SPACE:
  458. case FUNCTION_TRANSLATE:
  459. case FUNCTION_BOOLEAN:
  460. case FUNCTION_NOT:
  461. case FUNCTION_TRUE:
  462. case FUNCTION_FALSE:
  463. case FUNCTION_NULL:
  464. case FUNCTION_LANG:
  465. case FUNCTION_NUMBER:
  466. case FUNCTION_SUM:
  467. case FUNCTION_FLOOR:
  468. case FUNCTION_CEILING:
  469. case FUNCTION_ROUND:
  470. case FUNCTION_FORMAT_NUMBER:
  471. case NCName:
  472. case 82:
  473. case 83:
  474. case 86:
  475. case 88:
  476. ex = RelativeLocationPath();
  477. break;
  478. case SLASH:
  479. case SLASHSLASH:
  480. ex = AbsoluteLocationPath();
  481. break;
  482. default:
  483. jj_la1[5] = jj_gen;
  484. jj_consume_token(-1);
  485. throw new ParseException();
  486. }
  487. {if (true) return ex;}
  488. throw new Error("Missing return statement in function");
  489. }
  490. /* [2] AbsoluteLocationPath ::= '/' RelativeLocationPath? | AbbreviatedAbsoluteLocationPath */
  491. /* [10] AbbreviatedAbsoluteLocationPath ::= '//' RelativeLocationPath */
  492. final public Object AbsoluteLocationPath() throws ParseException {
  493. ArrayList steps = new ArrayList();
  494. if (jj_2_2(2147483647)) {
  495. LocationStep(steps);
  496. label_1:
  497. while (true) {
  498. switch (jj_nt.kind) {
  499. case SLASH:
  500. case SLASHSLASH:
  501. ;
  502. break;
  503. default:
  504. jj_la1[6] = jj_gen;
  505. break label_1;
  506. }
  507. LocationStep(steps);
  508. }
  509. } else {
  510. switch (jj_nt.kind) {
  511. case SLASH:
  512. jj_consume_token(SLASH);
  513. break;
  514. default:
  515. jj_la1[7] = jj_gen;
  516. jj_consume_token(-1);
  517. throw new ParseException();
  518. }
  519. }
  520. {if (true) return compiler.locationPath(true, steps.toArray());}
  521. throw new Error("Missing return statement in function");
  522. }
  523. /* [3] RelativeLocationPath ::= Step | RelativeLocationPath '/' Step | AbbreviatedRelativeLocationPath */
  524. final public Object RelativeLocationPath() throws ParseException {
  525. ArrayList steps = new ArrayList();
  526. NodeTest(steps);
  527. label_2:
  528. while (true) {
  529. switch (jj_nt.kind) {
  530. case SLASH:
  531. case SLASHSLASH:
  532. ;
  533. break;
  534. default:
  535. jj_la1[8] = jj_gen;
  536. break label_2;
  537. }
  538. LocationStep(steps);
  539. }
  540. {if (true) return compiler.locationPath(false, steps.toArray());}
  541. throw new Error("Missing return statement in function");
  542. }
  543. /* [3] RelativeLocationPath ::= Step | RelativeLocationPath '/' Step | AbbreviatedRelativeLocationPath */
  544. /* [11] AbbreviatedRelativeLocationPath ::= RelativeLocationPath '//' Step */
  545. /*--------------------*/
  546. /* 2.1 Location Steps */
  547. /*--------------------*/
  548. /* [4] Step ::= AxisSpecifier NodeTest Predicate* | AbbreviatedStep */
  549. final public void LocationStep(ArrayList steps) throws ParseException {
  550. Object t;
  551. Object s;
  552. switch (jj_nt.kind) {
  553. case SLASH:
  554. jj_consume_token(SLASH);
  555. break;
  556. case SLASHSLASH:
  557. jj_consume_token(SLASHSLASH);
  558. // Abbreviated step: descendant-or-self::node()
  559. t = compiler.nodeTypeTest(Compiler.NODE_TYPE_NODE);
  560. steps.add(compiler.step(Compiler.AXIS_DESCENDANT_OR_SELF, t, null));
  561. break;
  562. default:
  563. jj_la1[9] = jj_gen;
  564. jj_consume_token(-1);
  565. throw new ParseException();
  566. }
  567. NodeTest(steps);
  568. }
  569. /* [7] NodeTest ::= WildcardName | NodeType '(' ')' | 'processing-instruction' '(' Literal ')' */
  570. final public void NodeTest(ArrayList steps) throws ParseException {
  571. int axis;
  572. int type = -1;
  573. String instruction = null;
  574. Object name = null;
  575. Object s;
  576. Object p;
  577. ArrayList ps = new ArrayList();
  578. switch (jj_nt.kind) {
  579. case OR:
  580. case AND:
  581. case MOD:
  582. case DIV:
  583. case NODE:
  584. case TEXT:
  585. case COMMENT:
  586. case PI:
  587. case AXIS_SELF:
  588. case AXIS_CHILD:
  589. case AXIS_PARENT:
  590. case AXIS_ANCESTOR:
  591. case AXIS_ATTRIBUTE:
  592. case AXIS_NAMESPACE:
  593. case AXIS_PRECEDING:
  594. case AXIS_FOLLOWING:
  595. case AXIS_DESCENDANT:
  596. case AXIS_ANCESTOR_OR_SELF:
  597. case AXIS_FOLLOWING_SIBLING:
  598. case AXIS_PRECEDING_SIBLING:
  599. case AXIS_DESCENDANT_OR_SELF:
  600. case FUNCTION_LAST:
  601. case FUNCTION_POSITION:
  602. case FUNCTION_COUNT:
  603. case FUNCTION_ID:
  604. case FUNCTION_KEY:
  605. case FUNCTION_LOCAL_NAME:
  606. case FUNCTION_NAMESPACE_URI:
  607. case FUNCTION_NAME:
  608. case FUNCTION_STRING:
  609. case FUNCTION_CONCAT:
  610. case FUNCTION_STARTS_WITH:
  611. case FUNCTION_CONTAINS:
  612. case FUNCTION_SUBSTRING_BEFORE:
  613. case FUNCTION_SUBSTRING_AFTER:
  614. case FUNCTION_SUBSTRING:
  615. case FUNCTION_STRING_LENGTH:
  616. case FUNCTION_NORMALIZE_SPACE:
  617. case FUNCTION_TRANSLATE:
  618. case FUNCTION_BOOLEAN:
  619. case FUNCTION_NOT:
  620. case FUNCTION_TRUE:
  621. case FUNCTION_FALSE:
  622. case FUNCTION_NULL:
  623. case FUNCTION_LANG:
  624. case FUNCTION_NUMBER:
  625. case FUNCTION_SUM:
  626. case FUNCTION_FLOOR:
  627. case FUNCTION_CEILING:
  628. case FUNCTION_ROUND:
  629. case FUNCTION_FORMAT_NUMBER:
  630. case NCName:
  631. case 86:
  632. case 88:
  633. axis = AxisSpecifier();
  634. if (jj_2_3(2147483647)) {
  635. type = NodeType();
  636. jj_consume_token(80);
  637. jj_consume_token(81);
  638. } else if (jj_2_4(2147483647)) {
  639. jj_consume_token(PI);
  640. jj_consume_token(80);
  641. jj_consume_token(Literal);
  642. instruction = unescape(token.image.substring(1, token.image.length() - 1));
  643. jj_consume_token(81);
  644. } else {
  645. switch (jj_nt.kind) {
  646. case OR:
  647. case AND:
  648. case MOD:
  649. case DIV:
  650. case NODE:
  651. case TEXT:
  652. case COMMENT:
  653. case PI:
  654. case FUNCTION_LAST:
  655. case FUNCTION_POSITION:
  656. case FUNCTION_COUNT:
  657. case FUNCTION_ID:
  658. case FUNCTION_KEY:
  659. case FUNCTION_LOCAL_NAME:
  660. case FUNCTION_NAMESPACE_URI:
  661. case FUNCTION_NAME:
  662. case FUNCTION_STRING:
  663. case FUNCTION_CONCAT:
  664. case FUNCTION_STARTS_WITH:
  665. case FUNCTION_CONTAINS:
  666. case FUNCTION_SUBSTRING_BEFORE:
  667. case FUNCTION_SUBSTRING_AFTER:
  668. case FUNCTION_SUBSTRING:
  669. case FUNCTION_STRING_LENGTH:
  670. case FUNCTION_NORMALIZE_SPACE:
  671. case FUNCTION_TRANSLATE:
  672. case FUNCTION_BOOLEAN:
  673. case FUNCTION_NOT:
  674. case FUNCTION_TRUE:
  675. case FUNCTION_FALSE:
  676. case FUNCTION_NULL:
  677. case FUNCTION_LANG:
  678. case FUNCTION_NUMBER:
  679. case FUNCTION_SUM:
  680. case FUNCTION_FLOOR:
  681. case FUNCTION_CEILING:
  682. case FUNCTION_ROUND:
  683. case FUNCTION_FORMAT_NUMBER:
  684. case NCName:
  685. case 88:
  686. name = WildcardName();
  687. break;
  688. default:
  689. jj_la1[10] = jj_gen;
  690. jj_consume_token(-1);
  691. throw new ParseException();
  692. }
  693. }
  694. break;
  695. case 82:
  696. jj_consume_token(82);
  697. axis = Compiler.AXIS_SELF;
  698. type = Compiler.NODE_TYPE_NODE;
  699. break;
  700. case 83:
  701. jj_consume_token(83);
  702. axis = Compiler.AXIS_PARENT;
  703. type = Compiler.NODE_TYPE_NODE;
  704. break;
  705. default:
  706. jj_la1[11] = jj_gen;
  707. jj_consume_token(-1);
  708. throw new ParseException();
  709. }
  710. label_3:
  711. while (true) {
  712. switch (jj_nt.kind) {
  713. case 84:
  714. ;
  715. break;
  716. default:
  717. jj_la1[12] = jj_gen;
  718. break label_3;
  719. }
  720. p = Predicate();
  721. ps.add(p);
  722. }
  723. if (name != null){
  724. s = compiler.nodeNameTest(name);
  725. }
  726. else if (instruction != null){
  727. s = compiler.processingInstructionTest(instruction);
  728. }
  729. else {
  730. s = compiler.nodeTypeTest(type);
  731. }
  732. steps.add(compiler.step(axis, s, ps.toArray()));
  733. }
  734. /* [5] AxisSpecifier ::= AxisName '::' | AbbreviatedAxisSpecifier */
  735. final public int AxisSpecifier() throws ParseException {
  736. int axis;
  737. switch (jj_nt.kind) {
  738. case AXIS_SELF:
  739. case AXIS_CHILD:
  740. case AXIS_PARENT:
  741. case AXIS_ANCESTOR:
  742. case AXIS_ATTRIBUTE:
  743. case AXIS_NAMESPACE:
  744. case AXIS_PRECEDING:
  745. case AXIS_FOLLOWING:
  746. case AXIS_DESCENDANT:
  747. case AXIS_ANCESTOR_OR_SELF:
  748. case AXIS_FOLLOWING_SIBLING:
  749. case AXIS_PRECEDING_SIBLING:
  750. case AXIS_DESCENDANT_OR_SELF:
  751. axis = AxisName();
  752. break;
  753. default:
  754. jj_la1[13] = jj_gen;
  755. axis = AbbreviatedAxisSpecifier();
  756. }
  757. {if (true) return axis;}
  758. throw new Error("Missing return statement in function");
  759. }
  760. /*----------*/
  761. /* 2.2 Axes */
  762. /*----------*/
  763. /* [6] AxisName ::= 'ancestor' | 'ancestor-or-self' | 'attribute' | 'child' | 'descendant'
  764. | 'descendant-or-self' | 'following' | 'following-sibling' | 'namespace'
  765. | 'parent' | 'preceding' | 'preceding-sibling' | 'self'
  766. */
  767. final public int AxisName() throws ParseException {
  768. int axis = 0;
  769. switch (jj_nt.kind) {
  770. case AXIS_SELF:
  771. jj_consume_token(AXIS_SELF);
  772. axis = Compiler.AXIS_SELF;
  773. break;
  774. case AXIS_CHILD:
  775. jj_consume_token(AXIS_CHILD);
  776. axis = Compiler.AXIS_CHILD;
  777. break;
  778. case AXIS_PARENT:
  779. jj_consume_token(AXIS_PARENT);
  780. axis = Compiler.AXIS_PARENT;
  781. break;
  782. case AXIS_ANCESTOR:
  783. jj_consume_token(AXIS_ANCESTOR);
  784. axis = Compiler.AXIS_ANCESTOR;
  785. break;
  786. case AXIS_ATTRIBUTE:
  787. jj_consume_token(AXIS_ATTRIBUTE);
  788. axis = Compiler.AXIS_ATTRIBUTE;
  789. break;
  790. case AXIS_NAMESPACE:
  791. jj_consume_token(AXIS_NAMESPACE);
  792. axis = Compiler.AXIS_NAMESPACE;
  793. break;
  794. case AXIS_PRECEDING:
  795. jj_consume_token(AXIS_PRECEDING);
  796. axis = Compiler.AXIS_PRECEDING;
  797. break;
  798. case AXIS_FOLLOWING:
  799. jj_consume_token(AXIS_FOLLOWING);
  800. axis = Compiler.AXIS_FOLLOWING;
  801. break;
  802. case AXIS_DESCENDANT:
  803. jj_consume_token(AXIS_DESCENDANT);
  804. axis = Compiler.AXIS_DESCENDANT;
  805. break;
  806. case AXIS_ANCESTOR_OR_SELF:
  807. jj_consume_token(AXIS_ANCESTOR_OR_SELF);
  808. axis = Compiler.AXIS_ANCESTOR_OR_SELF;
  809. break;
  810. case AXIS_FOLLOWING_SIBLING:
  811. jj_consume_token(AXIS_FOLLOWING_SIBLING);
  812. axis = Compiler.AXIS_FOLLOWING_SIBLING;
  813. break;
  814. case AXIS_PRECEDING_SIBLING:
  815. jj_consume_token(AXIS_PRECEDING_SIBLING);
  816. axis = Compiler.AXIS_PRECEDING_SIBLING;
  817. break;
  818. case AXIS_DESCENDANT_OR_SELF:
  819. jj_consume_token(AXIS_DESCENDANT_OR_SELF);
  820. axis = Compiler.AXIS_DESCENDANT_OR_SELF;
  821. break;
  822. default:
  823. jj_la1[14] = jj_gen;
  824. jj_consume_token(-1);
  825. throw new ParseException();
  826. }
  827. {if (true) return axis;}
  828. throw new Error("Missing return statement in function");
  829. }
  830. /*----------------*/
  831. /* 2.3 Node Tests */
  832. /*----------------*/
  833. /*----------------*/
  834. /* 2.4 Predicates */
  835. /*----------------*/
  836. /* [8] Predicate ::= '[' PredicateExpr ']' */
  837. /* [9] PredicateExpr ::= Expr */
  838. final public Object Predicate() throws ParseException {
  839. Object ex;
  840. jj_consume_token(84);
  841. ex = Expression();
  842. jj_consume_token(85);
  843. {if (true) return ex;}
  844. throw new Error("Missing return statement in function");
  845. }
  846. /* [12] AbbreviatedStep ::= '.' | '..' */
  847. /* [13] AbbreviatedAxisSpecifier ::= '@'? */
  848. final public int AbbreviatedAxisSpecifier() throws ParseException {
  849. int axis = Compiler.AXIS_CHILD;
  850. switch (jj_nt.kind) {
  851. case 86:
  852. jj_consume_token(86);
  853. axis = Compiler.AXIS_ATTRIBUTE;
  854. break;
  855. default:
  856. jj_la1[15] = jj_gen;
  857. ;
  858. }
  859. {if (true) return axis;}
  860. throw new Error("Missing return statement in function");
  861. }
  862. /*---------------*/
  863. /* 3 Expressions */
  864. /*---------------*/
  865. /*------------*/
  866. /* 3.1 Basics */
  867. /*------------*/
  868. /*
  869. The effect of the grammar is that the order of precedence is (lowest precedence first):
  870. or
  871. and
  872. =, !=
  873. <=, <, >=, >
  874. and all operators are left associative.
  875. For example, 3 > 2 > 1 is equivalent to (3 > 2) > 1, which evaluates to false.
  876. */
  877. /* [14] Expr ::= OrExpr */
  878. final public Object Expression() throws ParseException {
  879. Object ex;
  880. ex = OrExpr();
  881. {if (true) return ex;}
  882. throw new Error("Missing return statement in function");
  883. }
  884. /* [15] PrimaryExpr ::= VariableReference | '(' Expr ')' | Literal | Number | FunctionCall */
  885. final public Object PrimaryExpr() throws ParseException {
  886. Object ex = null;
  887. switch (jj_nt.kind) {
  888. case VARIABLE:
  889. ex = VariableReference();
  890. break;
  891. case 80:
  892. jj_consume_token(80);
  893. ex = Expression();
  894. jj_consume_token(81);
  895. break;
  896. case Literal:
  897. jj_consume_token(Literal);
  898. ex = compiler.literal(unescape(token.image.substring(1, token.image.length() - 1)));
  899. break;
  900. case Number:
  901. jj_consume_token(Number);
  902. ex = compiler.number(token.image);
  903. break;
  904. default:
  905. jj_la1[16] = jj_gen;
  906. if (jj_2_5(2147483647)) {
  907. ex = CoreFunctionCall();
  908. } else {
  909. switch (jj_nt.kind) {
  910. case OR:
  911. case AND:
  912. case MOD:
  913. case DIV:
  914. case NODE:
  915. case TEXT:
  916. case COMMENT:
  917. case PI:
  918. case FUNCTION_LAST:
  919. case FUNCTION_POSITION:
  920. case FUNCTION_COUNT:
  921. case FUNCTION_ID:
  922. case FUNCTION_KEY:
  923. case FUNCTION_LOCAL_NAME:
  924. case FUNCTION_NAMESPACE_URI:
  925. case FUNCTION_NAME:
  926. case FUNCTION_STRING:
  927. case FUNCTION_CONCAT:
  928. case FUNCTION_STARTS_WITH:
  929. case FUNCTION_CONTAINS:
  930. case FUNCTION_SUBSTRING_BEFORE:
  931. case FUNCTION_SUBSTRING_AFTER:
  932. case FUNCTION_SUBSTRING:
  933. case FUNCTION_STRING_LENGTH:
  934. case FUNCTION_NORMALIZE_SPACE:
  935. case FUNCTION_TRANSLATE:
  936. case FUNCTION_BOOLEAN:
  937. case FUNCTION_NOT:
  938. case FUNCTION_TRUE:
  939. case FUNCTION_FALSE:
  940. case FUNCTION_NULL:
  941. case FUNCTION_LANG:
  942. case FUNCTION_NUMBER:
  943. case FUNCTION_SUM:
  944. case FUNCTION_FLOOR:
  945. case FUNCTION_CEILING:
  946. case FUNCTION_ROUND:
  947. case FUNCTION_FORMAT_NUMBER:
  948. case NCName:
  949. ex = FunctionCall();
  950. break;
  951. default:
  952. jj_la1[17] = jj_gen;
  953. jj_consume_token(-1);
  954. throw new ParseException();
  955. }
  956. }
  957. }
  958. {if (true) return ex;}
  959. throw new Error("Missing return statement in function");
  960. }
  961. /*--------------------*/
  962. /* 3.2 Function Calls */
  963. /*--------------------*/
  964. /* [16] FunctionCall ::= FunctionName '(' ( Argument ( ',' Argument)*)? ')' */
  965. final public Object FunctionCall() throws ParseException {
  966. Object name;
  967. ArrayList args;
  968. name = FunctionName();
  969. args = ArgumentList();
  970. if (args == null){
  971. {if (true) return compiler.function(name, null);}
  972. }
  973. else {
  974. {if (true) return compiler.function(name, args.toArray());}
  975. }
  976. throw new Error("Missing return statement in function");
  977. }
  978. final public Object CoreFunctionCall() throws ParseException {
  979. int code = 0;
  980. ArrayList args;
  981. code = CoreFunctionName();
  982. args = ArgumentList();
  983. if (args == null){
  984. {if (true) return compiler.function(code, null);}
  985. }
  986. else {
  987. {if (true) return compiler.function(code, args.toArray());}
  988. }
  989. throw new Error("Missing return statement in function");
  990. }
  991. final public ArrayList ArgumentList() throws ParseException {
  992. ArrayList args = null;
  993. Object arg;
  994. jj_consume_token(80);
  995. switch (jj_nt.kind) {
  996. case SLASH:
  997. case SLASHSLASH:
  998. case MINUS:
  999. case VARIABLE:
  1000. case Literal:
  1001. case Number:
  1002. case OR:
  1003. case AND:
  1004. case MOD:
  1005. case DIV:
  1006. case NODE:
  1007. case TEXT:
  1008. case COMMENT:
  1009. case PI:
  1010. case AXIS_SELF:
  1011. case AXIS_CHILD:
  1012. case AXIS_PARENT:
  1013. case AXIS_ANCESTOR:
  1014. case AXIS_ATTRIBUTE:
  1015. case AXIS_NAMESPACE:
  1016. case AXIS_PRECEDING:
  1017. case AXIS_FOLLOWING:
  1018. case AXIS_DESCENDANT:
  1019. case AXIS_ANCESTOR_OR_SELF:
  1020. case AXIS_FOLLOWING_SIBLING:
  1021. case AXIS_PRECEDING_SIBLING:
  1022. case AXIS_DESCENDANT_OR_SELF:
  1023. case FUNCTION_LAST:
  1024. case FUNCTION_POSITION:
  1025. case FUNCTION_COUNT:
  1026. case FUNCTION_ID:
  1027. case FUNCTION_KEY:
  1028. case FUNCTION_LOCAL_NAME:
  1029. case FUNCTION_NAMESPACE_URI:
  1030. case FUNCTION_NAME:
  1031. case FUNCTION_STRING:
  1032. case FUNCTION_CONCAT:
  1033. case FUNCTION_STARTS_WITH:
  1034. case FUNCTION_CONTAINS:
  1035. case FUNCTION_SUBSTRING_BEFORE:
  1036. case FUNCTION_SUBSTRING_AFTER:
  1037. case FUNCTION_SUBSTRING:
  1038. case FUNCTION_STRING_LENGTH:
  1039. case FUNCTION_NORMALIZE_SPACE:
  1040. case FUNCTION_TRANSLATE:
  1041. case FUNCTION_BOOLEAN:
  1042. case FUNCTION_NOT:
  1043. case FUNCTION_TRUE:
  1044. case FUNCTION_FALSE:
  1045. case FUNCTION_NULL:
  1046. case FUNCTION_LANG:
  1047. case FUNCTION_NUMBER:
  1048. case FUNCTION_SUM:
  1049. case FUNCTION_FLOOR:
  1050. case FUNCTION_CEILING:
  1051. case FUNCTION_ROUND:
  1052. case FUNCTION_FORMAT_NUMBER:
  1053. case NCName:
  1054. case 80:
  1055. case 82:
  1056. case 83:
  1057. case 86:
  1058. case 88:
  1059. arg = Argument();
  1060. args = new ArrayList(); args.add(arg);
  1061. label_4:
  1062. while (true) {
  1063. switch (jj_nt.kind) {
  1064. case 87:
  1065. ;
  1066. break;
  1067. default:
  1068. jj_la1[18] = jj_gen;
  1069. break label_4;
  1070. }
  1071. jj_consume_token(87);
  1072. arg = Argument();
  1073. args.add(arg);
  1074. }
  1075. break;
  1076. default:
  1077. jj_la1[19] = jj_gen;
  1078. ;
  1079. }
  1080. jj_consume_token(81);
  1081. {if (true) return args;}
  1082. throw new Error("Missing return statement in function");
  1083. }
  1084. /* [17] Argument ::= Expr */
  1085. final public Object Argument() throws ParseException {
  1086. Object ex;
  1087. ex = Expression();
  1088. {if (true) return ex;}
  1089. throw new Error("Missing return statement in function");
  1090. }
  1091. /*---------------*/
  1092. /* 3.3 Node-sets */
  1093. /*---------------*/
  1094. /* [18] UnionExpr ::= PathExpr | UnionExpr '|' PathExpr */
  1095. final public Object UnionExpr() throws ParseException {
  1096. Object ex, r;
  1097. ArrayList list = null;
  1098. ex = PathExpr();
  1099. label_5:
  1100. while (true) {
  1101. switch (jj_nt.kind) {
  1102. case UNION:
  1103. ;
  1104. break;
  1105. default:
  1106. jj_la1[20] = jj_gen;
  1107. break label_5;
  1108. }
  1109. jj_consume_token(UNION);
  1110. r = PathExpr();
  1111. if (list == null){
  1112. list = new ArrayList();
  1113. list.add(ex);
  1114. }
  1115. list.add(r);
  1116. }
  1117. if (list != null){
  1118. ex = compiler.union(list.toArray());
  1119. }
  1120. {if (true) return ex;}
  1121. throw new Error("Missing return statement in function");
  1122. }
  1123. /* [19] PathExpr ::= LocationPath | FilterExpr | FilterExpr '/' RelativeLocationPath | FilterExpr '//' RelativeLocationPath */
  1124. final public Object PathExpr() throws ParseException {
  1125. Object ex = null;
  1126. Object[] steps;
  1127. if (jj_2_6(2147483647)) {
  1128. ex = FilterExpr();
  1129. } else {
  1130. switch (jj_nt.kind) {
  1131. case SLASH:
  1132. case SLASHSLASH:
  1133. case OR:
  1134. case AND:
  1135. case MOD:
  1136. case DIV:
  1137. case NODE:
  1138. case TEXT:
  1139. case COMMENT:
  1140. case PI:
  1141. case AXIS_SELF:
  1142. case AXIS_CHILD:
  1143. case AXIS_PARENT:
  1144. case AXIS_ANCESTOR:
  1145. case AXIS_ATTRIBUTE:
  1146. case AXIS_NAMESPACE:
  1147. case AXIS_PRECEDING:
  1148. case AXIS_FOLLOWING:
  1149. case AXIS_DESCENDANT:
  1150. case AXIS_ANCESTOR_OR_SELF:
  1151. case AXIS_FOLLOWING_SIBLING:
  1152. case AXIS_PRECEDING_SIBLING:
  1153. case AXIS_DESCENDANT_OR_SELF:
  1154. case FUNCTION_LAST:
  1155. case FUNCTION_POSITION:
  1156. case FUNCTION_COUNT:
  1157. case FUNCTION_ID:
  1158. case FUNCTION_KEY:
  1159. case FUNCTION_LOCAL_NAME:
  1160. case FUNCTION_NAMESPACE_URI:
  1161. case FUNCTION_NAME:
  1162. case FUNCTION_STRING:
  1163. case FUNCTION_CONCAT:
  1164. case FUNCTION_STARTS_WITH:
  1165. case FUNCTION_CONTAINS:
  1166. case FUNCTION_SUBSTRING_BEFORE:
  1167. case FUNCTION_SUBSTRING_AFTER:
  1168. case FUNCTION_SUBSTRING:
  1169. case FUNCTION_STRING_LENGTH:
  1170. case FUNCTION_NORMALIZE_SPACE:
  1171. case FUNCTION_TRANSLATE:
  1172. case FUNCTION_BOOLEAN:
  1173. case FUNCTION_NOT:
  1174. case FUNCTION_TRUE:
  1175. case FUNCTION_FALSE:
  1176. case FUNCTION_NULL:
  1177. case FUNCTION_LANG:
  1178. case FUNCTION_NUMBER:
  1179. case FUNCTION_SUM:
  1180. case FUNCTION_FLOOR:
  1181. case FUNCTION_CEILING:
  1182. case FUNCTION_ROUND:
  1183. case FUNCTION_FORMAT_NUMBER:
  1184. case NCName:
  1185. case 82:
  1186. case 83:
  1187. case 86:
  1188. case 88:
  1189. ex = LocationPath();
  1190. break;
  1191. default:
  1192. jj_la1[21] = jj_gen;
  1193. jj_consume_token(-1);
  1194. throw new ParseException();
  1195. }
  1196. }
  1197. {if (true) return ex;}
  1198. throw new Error("Missing return statement in function");
  1199. }
  1200. /* [20] FilterExpr ::= PrimaryExpr | FilterExpr Predicate */
  1201. final public Object FilterExpr() throws ParseException {
  1202. Object ex, p;
  1203. ArrayList ps = new ArrayList();
  1204. boolean path = false;
  1205. ArrayList steps = new ArrayList();
  1206. ex = PrimaryExpr();
  1207. label_6:
  1208. while (true) {
  1209. switch (jj_nt.kind) {
  1210. case 84:
  1211. ;
  1212. break;
  1213. default:
  1214. jj_la1[22] = jj_gen;
  1215. break label_6;
  1216. }
  1217. p = Predicate();
  1218. path = true;
  1219. ps.add(p);
  1220. }
  1221. label_7:
  1222. while (true) {
  1223. switch (jj_nt.kind) {
  1224. case SLASH:
  1225. case SLASHSLASH:
  1226. ;
  1227. break;
  1228. default:
  1229. jj_la1[23] = jj_gen;
  1230. break label_7;
  1231. }
  1232. LocationStep(steps);
  1233. path = true;
  1234. }
  1235. if (path){
  1236. {if (true) return compiler.expressionPath(ex, ps.toArray(), steps.toArray());}
  1237. }
  1238. else {
  1239. {if (true) return ex;}
  1240. }
  1241. throw new Error("Missing return statement in function");
  1242. }
  1243. /*--------------*/
  1244. /* 3.4 Booleans */
  1245. /*--------------*/
  1246. /* [21] OrExpr ::= AndExpr | OrExpr 'or' AndExpr */
  1247. final public Object OrExpr() throws ParseException {
  1248. Object ex, r;
  1249. ArrayList list = null;
  1250. ex = AndExpr();
  1251. label_8:
  1252. while (true) {
  1253. switch (jj_nt.kind) {
  1254. case OR:
  1255. ;
  1256. break;
  1257. default:
  1258. jj_la1[24] = jj_gen;
  1259. break label_8;
  1260. }
  1261. jj_consume_token(OR);
  1262. r = AndExpr();
  1263. if (list == null){
  1264. list = new ArrayList();
  1265. list.add(ex);
  1266. }
  1267. list.add(r);
  1268. }
  1269. if (list != null){
  1270. ex = compiler.or(list.toArray());
  1271. }
  1272. {if (true) return ex;}
  1273. throw new Error("Missing return statement in function");
  1274. }
  1275. /* [22] AndExpr ::= EqualityExpr | AndExpr 'and' EqualityExpr */
  1276. final public Object AndExpr() throws ParseException {
  1277. Object ex, r;
  1278. ArrayList list = null;
  1279. ex = EqualityExpr();
  1280. label_9:
  1281. while (true) {
  1282. switch (jj_nt.kind) {
  1283. case AND:
  1284. ;
  1285. break;
  1286. default:
  1287. jj_la1[25] = jj_gen;
  1288. break label_9;
  1289. }
  1290. jj_consume_token(AND);
  1291. r = EqualityExpr();
  1292. if (list == null){
  1293. list = new ArrayList();
  1294. list.add(ex);
  1295. }
  1296. list.add(r);
  1297. }
  1298. if (list != null){
  1299. ex = compiler.and(list.toArray());
  1300. }
  1301. {if (true) return ex;}
  1302. throw new Error("Missing return statement in function");
  1303. }
  1304. /* [23] EqualityExpr ::= RelationalExpr | EqualityExpr '=' RelationalExpr | EqualityExpr '!=' RelationalExpr */
  1305. final public Object EqualityExpr() throws ParseException {
  1306. Object ex, r;
  1307. ex = RelationalExpr();
  1308. label_10:
  1309. while (true) {
  1310. switch (jj_nt.kind) {
  1311. case EQ:
  1312. case NEQ:
  1313. ;
  1314. break;
  1315. default:
  1316. jj_la1[26] = jj_gen;
  1317. break label_10;
  1318. }
  1319. switch (jj_nt.kind) {
  1320. case EQ:
  1321. jj_consume_token(EQ);
  1322. r = RelationalExpr();
  1323. ex = compiler.equal(ex, r);
  1324. break;
  1325. case NEQ:
  1326. jj_consume_token(NEQ);
  1327. r = RelationalExpr();
  1328. ex = compiler.notEqual(ex, r);
  1329. break;
  1330. default:
  1331. jj_la1[27] = jj_gen;
  1332. jj_consume_token(-1);
  1333. throw new ParseException();
  1334. }
  1335. }
  1336. {if (true) return ex;}
  1337. throw new Error("Missing return statement in function");
  1338. }
  1339. /* [24] RelationalExpr ::= AdditiveExpr | RelationalExpr '<' AdditiveExpr | RelationalExpr '>' AdditiveExpr
  1340. | RelationalExpr '<=' AdditiveExpr | RelationalExpr '>=' AdditiveExpr */
  1341. final public Object RelationalExpr() throws ParseException {
  1342. Object ex, r;
  1343. ex = AdditiveExpr();
  1344. label_11:
  1345. while (true) {
  1346. switch (jj_nt.kind) {
  1347. case LT:
  1348. case LTE:
  1349. case GT:
  1350. case GTE:
  1351. ;
  1352. break;
  1353. default:
  1354. jj_la1[28] = jj_gen;
  1355. break label_11;
  1356. }
  1357. switch (jj_nt.kind) {
  1358. case LT:
  1359. jj_consume_token(LT);
  1360. r = AdditiveExpr();
  1361. ex = compiler.lessThan(ex, r);
  1362. break;
  1363. case GT:
  1364. jj_consume_token(GT);
  1365. r = AdditiveExpr();
  1366. ex = compiler.greaterThan(ex, r);
  1367. break;
  1368. case LTE:
  1369. jj_consume_token(LTE);
  1370. r = AdditiveExpr();
  1371. ex = compiler.lessThanOrEqual(ex, r);
  1372. break;
  1373. case GTE:
  1374. jj_consume_token(GTE);
  1375. r = AdditiveExpr();
  1376. ex = compiler.greaterThanOrEqual(ex, r);
  1377. break;
  1378. default:
  1379. jj_la1[29] = jj_gen;
  1380. jj_consume_token(-1);
  1381. throw new ParseException();
  1382. }
  1383. }
  1384. {if (true) return ex;}
  1385. throw new Error("Missing return statement in function");
  1386. }
  1387. /*-------------*/
  1388. /* 3.5 Numbers */
  1389. /*-------------*/
  1390. /* [25] AdditiveExpr ::= MultiplicativeExpr | AdditiveExpr '+' MultiplicativeExpr | AdditiveExpr '-' MultiplicativeExpr */
  1391. final public Object AdditiveExpr() throws ParseException {
  1392. Object ex, r;
  1393. ArrayList list = null;
  1394. ex = SubtractiveExpr();
  1395. label_12:
  1396. while (true) {
  1397. switch (jj_nt.kind) {
  1398. case PLUS:
  1399. ;
  1400. break;
  1401. default:
  1402. jj_la1[30] = jj_gen;
  1403. break label_12;
  1404. }
  1405. jj_consume_token(PLUS);
  1406. r = SubtractiveExpr();
  1407. if (list == null){
  1408. list = new ArrayList();
  1409. list.add(ex);
  1410. }
  1411. list.add(r);
  1412. }
  1413. if (list != null){
  1414. ex = compiler.sum(list.toArray());
  1415. }
  1416. {if (true) return ex;}
  1417. throw new Error("Missing return statement in function");
  1418. }
  1419. final public Object SubtractiveExpr() throws ParseException {
  1420. Object ex, r = null;
  1421. ex = MultiplicativeExpr();
  1422. label_13:
  1423. while (true) {
  1424. switch (jj_nt.kind) {
  1425. case MINUS:
  1426. ;
  1427. break;
  1428. default:
  1429. jj_la1[31] = jj_gen;
  1430. break label_13;
  1431. }
  1432. jj_consume_token(MINUS);
  1433. r = MultiplicativeExpr();
  1434. ex = compiler.minus(ex, r);
  1435. }
  1436. {if (true) return ex;}
  1437. throw new Error("Missing return statement in function");
  1438. }
  1439. /* [26] MultiplicativeExpr ::= UnaryExpr | MultiplicativeExpr MultiplyOperator UnaryExpr
  1440. | MultiplicativeExpr 'div' UnaryExpr | MultiplicativeExpr 'mod' UnaryExpr */
  1441. final public Object MultiplicativeExpr() throws ParseException {
  1442. Object ex, r;
  1443. ex = UnaryExpr();
  1444. label_14:
  1445. while (true) {
  1446. switch (jj_nt.kind) {
  1447. case MOD:
  1448. case DIV:
  1449. case 88:
  1450. ;
  1451. break;
  1452. default:
  1453. jj_la1[32] = jj_gen;
  1454. break label_14;
  1455. }
  1456. switch (jj_nt.kind) {
  1457. case 88:
  1458. jj_consume_token(88);
  1459. r = UnaryExpr();
  1460. ex = compiler.multiply(ex, r);
  1461. break;
  1462. case DIV:
  1463. jj_consume_token(DIV);
  1464. r = UnaryExpr();
  1465. ex = compiler.divide(ex, r);
  1466. break;
  1467. case MOD:
  1468. jj_consume_token(MOD);
  1469. r = UnaryExpr();
  1470. ex = compiler.mod(ex, r);
  1471. break;
  1472. default:
  1473. jj_la1[33] = jj_gen;
  1474. jj_consume_token(-1);
  1475. throw new ParseException();
  1476. }
  1477. }
  1478. {if (true) return ex;}
  1479. throw new Error("Missing return statement in function");
  1480. }
  1481. /* [27] UnaryExpr ::= UnionExpr | '-' UnaryExpr */
  1482. final public Object UnaryExpr() throws ParseException {
  1483. Object ex;
  1484. switch (jj_nt.kind) {
  1485. case SLASH:
  1486. case SLASHSLASH:
  1487. case VARIABLE:
  1488. case Literal:
  1489. case Number:
  1490. case OR:
  1491. case AND:
  1492. case MOD:
  1493. case DIV:
  1494. case NODE:
  1495. case TEXT:
  1496. case COMMENT:
  1497. case PI:
  1498. case AXIS_SELF:
  1499. case AXIS_CHILD:
  1500. case AXIS_PARENT:
  1501. case AXIS_ANCESTOR:
  1502. case AXIS_ATTRIBUTE:
  1503. case AXIS_NAMESPACE:
  1504. case AXIS_PRECEDING:
  1505. case AXIS_FOLLOWING:
  1506. case AXIS_DESCENDANT:
  1507. case AXIS_ANCESTOR_OR_SELF:
  1508. case AXIS_FOLLOWING_SIBLING:
  1509. case AXIS_PRECEDING_SIBLING:
  1510. case AXIS_DESCENDANT_OR_SELF:
  1511. case FUNCTION_LAST:
  1512. case FUNCTION_POSITION:
  1513. case FUNCTION_COUNT:
  1514. case FUNCTION_ID:
  1515. case FUNCTION_KEY:
  1516. case FUNCTION_LOCAL_NAME:
  1517. case FUNCTION_NAMESPACE_URI:
  1518. case FUNCTION_NAME:
  1519. case FUNCTION_STRING:
  1520. case FUNCTION_CONCAT:
  1521. case FUNCTION_STARTS_WITH:
  1522. case FUNCTION_CONTAINS:
  1523. case FUNCTION_SUBSTRING_BEFORE:
  1524. case FUNCTION_SUBSTRING_AFTER:
  1525. case FUNCTION_SUBSTRING:
  1526. case FUNCTION_STRING_LENGTH:
  1527. case FUNCTION_NORMALIZE_SPACE:
  1528. case FUNCTION_TRANSLATE:
  1529. case FUNCTION_BOOLEAN:
  1530. case FUNCTION_NOT:
  1531. case FUNCTION_TRUE:
  1532. case FUNCTION_FALSE:
  1533. case FUNCTION_NULL:
  1534. case FUNCTION_LANG:
  1535. case FUNCTION_NUMBER:
  1536. case FUNCTION_SUM:
  1537. case FUNCTION_FLOOR:
  1538. case FUNCTION_CEILING:
  1539. case FUNCTION_ROUND:
  1540. case FUNCTION_FORMAT_NUMBER:
  1541. case NCName:
  1542. case 80:
  1543. case 82:
  1544. case 83:
  1545. case 86:
  1546. case 88:
  1547. ex = UnionExpr();
  1548. break;
  1549. case MINUS:
  1550. jj_consume_token(MINUS);
  1551. ex = UnaryExpr();
  1552. ex = compiler.minus(ex);
  1553. break;
  1554. default:
  1555. jj_la1[34] = jj_gen;
  1556. jj_consume_token(-1);
  1557. throw new ParseException();
  1558. }
  1559. {if (true) return ex;}
  1560. throw new Error("Missing return statement in function");
  1561. }
  1562. /*-------------*/
  1563. /* 3.6 Strings */
  1564. /*-------------*/
  1565. /*----------------------------------*/
  1566. /* 3.7 Expression Lexical Structure */
  1567. /*----------------------------------*/
  1568. /*
  1569. The following special tokenization rules must be applied in the order
  1570. specified to disambiguate the grammar:
  1571. 1. If there is a preceding token and the preceding token is not one of
  1572. @, ::, (, [, , or an Operator,
  1573. then a * must be recognized as a MultiplyOperator and an NCName must
  1574. be recognized as an OperatorName.
  1575. 2. If the character following an NCName (possibly after intervening ExprWhitespace)
  1576. is (, then the token must be recognized as a NodeType or a FunctionName.
  1577. 3. If the two characters following an NCName (possibly after intervening ExprWhitespace)
  1578. are ::, then the token must be recognized as an AxisName.
  1579. 4. Otherwise, the token must not be recognized as a MultiplyOperator, an OperatorName,
  1580. a NodeType, a FunctionName, or an AxisName.
  1581. */
  1582. /*
  1583. [28] ExprToken ::= '(' | ')' | '[' | ']' | '.' | '..' | '@' | ',' | '::'
  1584. | WildcardName | NodeType | Operator | FunctionName | AxisName | Literal
  1585. | Number | VariableReference
  1586. */
  1587. /* [34] MultiplyOperator ::= '*' */
  1588. /* [35] FunctionName ::= QName - NodeType */
  1589. final public Object FunctionName() throws ParseException {
  1590. Object qname;
  1591. qname = QName_Without_CoreFunctions();
  1592. {if (true) return qname;}
  1593. throw new Error("Missing return statement in function");
  1594. }
  1595. /* [36] VariableReference ::= '$' QName */
  1596. final public Object VariableReference() throws ParseException {
  1597. Object ex;
  1598. jj_consume_token(VARIABLE);
  1599. ex = QName();
  1600. {if (true) return compiler.variableReference(ex);}
  1601. throw new Error("Missing return statement in function");
  1602. }
  1603. /* [37] WildcardName ::= '*' | NCName ':' '*' | QName */
  1604. final public Object WildcardName() throws ParseException {
  1605. Object qn;
  1606. String nc1, nc2 = null;
  1607. switch (jj_nt.kind) {
  1608. case 88:
  1609. jj_consume_token(88);
  1610. break;
  1611. case OR:
  1612. case AND:
  1613. case MOD:
  1614. case DIV:
  1615. case NODE:
  1616. case TEXT:
  1617. case COMMENT:
  1618. case PI:
  1619. case FUNCTION_LAST:
  1620. case FUNCTION_POSITION:
  1621. case FUNCTION_COUNT:
  1622. case FUNCTION_ID:
  1623. case FUNCTION_KEY:
  1624. case FUNCTION_LOCAL_NAME:
  1625. case FUNCTION_NAMESPACE_URI:
  1626. case FUNCTION_NAME:
  1627. case FUNCTION_STRING:
  1628. case FUNCTION_CONCAT:
  1629. case FUNCTION_STARTS_WITH:
  1630. case FUNCTION_CONTAINS:
  1631. case FUNCTION_SUBSTRING_BEFORE:
  1632. case FUNCTION_SUBSTRING_AFTER:
  1633. case FUNCTION_SUBSTRING:
  1634. case FUNCTION_STRING_LENGTH:
  1635. case FUNCTION_NORMALIZE_SPACE:
  1636. case FUNCTION_TRANSLATE:
  1637. case FUNCTION_BOOLEAN:
  1638. case FUNCTION_NOT:
  1639. case FUNCTION_TRUE:
  1640. case FUNCTION_FALSE:
  1641. case FUNCTION_NULL:
  1642. case FUNCTION_LANG:
  1643. c