PageRenderTime 55ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/bsh/bsh.jj

#
Unknown | 2439 lines | 2337 code | 102 blank | 0 comment | 0 complexity | b86ea8223399b8e62874ea09dd2fe1b9 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. /*@bgen(jjtree) Generated By:JJTree: Do not edit this line. src/bsh/bsh.jj */
  2. /*@egen*//*****************************************************************************
  3. * *
  4. * This file is part of the BeanShell Java Scripting distribution. *
  5. * Documentation and updates may be found at http://www.beanshell.org/ *
  6. * *
  7. * Sun Public License Notice: *
  8. * *
  9. * The contents of this file are subject to the Sun Public License Version *
  10. * 1.0 (the "License"); you may not use this file except in compliance with *
  11. * the License. A copy of the License is available at http://www.sun.com *
  12. * *
  13. * The Original Code is BeanShell. The Initial Developer of the Original *
  14. * Code is Pat Niemeyer. Portions created by Pat Niemeyer are Copyright *
  15. * (C) 2000. All Rights Reserved. *
  16. * *
  17. * GNU Public License Notice: *
  18. * *
  19. * Alternatively, the contents of this file may be used under the terms of *
  20. * the GNU Lesser General Public License (the "LGPL"), in which case the *
  21. * provisions of LGPL are applicable instead of those above. If you wish to *
  22. * allow use of your version of this file only under the terms of the LGPL *
  23. * and not to allow others to use your version of this file under the SPL, *
  24. * indicate your decision by deleting the provisions above and replace *
  25. * them with the notice and other provisions required by the LGPL. If you *
  26. * do not delete the provisions above, a recipient may use your version of *
  27. * this file under either the SPL or the LGPL. *
  28. * *
  29. * Patrick Niemeyer (pat@pat.net) *
  30. * Author of Learning Java, O'Reilly & Associates *
  31. * http://www.pat.net/~pat/ *
  32. * *
  33. *****************************************************************************/
  34. /*
  35. Notes:
  36. There is probably a lot of room for improvement in here.
  37. All of the syntactic lookaheads have been commented with:
  38. SYNTACTIC_LOOKAHEAD
  39. These are probably expensive and we may want to start weeding them out
  40. where possible.
  41. */
  42. options {
  43. JAVA_UNICODE_ESCAPE=true;
  44. STATIC=false;
  45. /* Print grammar debugging info as we parse
  46. DEBUG_PARSER=true;
  47. */
  48. /* Print detailed lookahead debugging info
  49. DEBUG_LOOKAHEAD=true;
  50. */
  51. // Not sure exactly what this does
  52. ERROR_REPORTING=false;
  53. // This breaks something for interactive use on the command line,
  54. // but may be useful in non-interactive use.
  55. //CACHE_TOKENS=true;
  56. }
  57. PARSER_BEGIN(Parser)
  58. package org.gjt.sp.jedit.bsh;
  59. import java.io.*;
  60. import java.util.Vector;
  61. /**
  62. This is the BeanShell parser. It is used internally by the Interpreter
  63. class (which is probably what you are looking for). The parser knows
  64. only how to parse the structure of the language, it does not understand
  65. names, commands, etc.
  66. <p>
  67. You can use the Parser from the command line to do basic structural
  68. validation of BeanShell files without actually executing them. e.g.
  69. <code><pre>
  70. java bsh.Parser [ -p ] file [ file ] [ ... ]
  71. </pre></code>
  72. <p>
  73. The -p option causes the abstract syntax to be printed.
  74. <p>
  75. From code you'd use the Parser like this:
  76. <p
  77. <code><pre>
  78. Parser parser = new Parser(in);
  79. while( !(eof=parser.Line()) ) {
  80. SimpleNode node = parser.popNode();
  81. // use the node, etc. (See bsh.BSH* classes)
  82. }
  83. </pre></code>
  84. */
  85. public class Parser/*@bgen(jjtree)*/implements ParserTreeConstants/*@egen*/
  86. {/*@bgen(jjtree)*/
  87. protected JJTParserState jjtree = new JJTParserState();
  88. /*@egen*/
  89. boolean retainComments = false;
  90. public void setRetainComments( boolean b ) {
  91. retainComments = b;
  92. }
  93. void jjtreeOpenNodeScope(Node n) {
  94. ((SimpleNode)n).firstToken = getToken(1);
  95. }
  96. void jjtreeCloseNodeScope(Node n) {
  97. ((SimpleNode)n).lastToken = getToken(0);
  98. }
  99. /**
  100. Re-initialize the input stream and token source.
  101. */
  102. void reInitInput( Reader in ) {
  103. ReInit(in);
  104. }
  105. public SimpleNode popNode()
  106. {
  107. if ( jjtree.nodeArity() > 0) // number of child nodes
  108. return (SimpleNode)jjtree.popNode();
  109. else
  110. return null;
  111. }
  112. /**
  113. Explicitly re-initialize just the token reader.
  114. This seems to be necessary to avoid certain looping errors when
  115. reading bogus input. See Interpreter.
  116. */
  117. void reInitTokenInput( Reader in ) {
  118. jj_input_stream.ReInit( in,
  119. jj_input_stream.getEndLine(),
  120. jj_input_stream.getEndColumn() );
  121. }
  122. public static void main( String [] args )
  123. throws IOException, ParseException
  124. {
  125. boolean print = false;
  126. int i=0;
  127. if ( args[0].equals("-p") ) {
  128. i++;
  129. print=true;
  130. }
  131. for(; i< args.length; i++) {
  132. Reader in = new FileReader(args[i]);
  133. Parser parser = new Parser(in);
  134. parser.setRetainComments(true);
  135. while( !parser.Line()/*eof*/ )
  136. if ( print )
  137. System.out.println( parser.popNode() );
  138. }
  139. }
  140. /**
  141. Lookahead for the enhanced for statement.
  142. Expect "for" "(" and then see whether we hit ":" or a ";" first.
  143. */
  144. boolean isRegularForStatement()
  145. {
  146. int curTok = 1;
  147. Token tok;
  148. tok = getToken(curTok++);
  149. if ( tok.kind != FOR ) return false;
  150. tok = getToken(curTok++);
  151. if ( tok.kind != LPAREN ) return false;
  152. while (true)
  153. {
  154. tok = getToken(curTok++);
  155. switch (tok.kind) {
  156. case COLON:
  157. return false;
  158. case SEMICOLON:
  159. return true;
  160. case EOF:
  161. return false;
  162. }
  163. }
  164. }
  165. /**
  166. Generate a ParseException with the specified message, pointing to the
  167. current token.
  168. The auto-generated Parser.generateParseException() method does not
  169. provide line number info, therefore we do this.
  170. */
  171. ParseException createParseException( String message )
  172. {
  173. Token errortok = token;
  174. int line = errortok.beginLine, column = errortok.beginColumn;
  175. String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image;
  176. return new ParseException( "Parse error at line " + line
  177. + ", column " + column + " : " + message );
  178. }
  179. }
  180. PARSER_END(Parser)
  181. SKIP : /* WHITE SPACE */
  182. {
  183. " " | "\t" | "\r" | "\f"
  184. | "\n"
  185. | < NONPRINTABLE: (["\u0000"-" ", "\u0080"-"\u00ff"])+ >
  186. }
  187. SPECIAL_TOKEN : /* COMMENTS */
  188. {
  189. /*
  190. SINGLE_LINE_COMMENT includes a hack to accept SLC at the end of a file
  191. with no terminanting linefeed. This is actually illegal according to
  192. spec, but comes up often enough to warrant it... (especially in eval()).
  193. */
  194. <SINGLE_LINE_COMMENT: "//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")? >
  195. | <HASH_BANG_COMMENT: "#!" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
  196. /* Moved FORMAL_COMMENT to a real token. Modified MULTI_LINE_COMMENT to not
  197. catch formal comments (require no star after star) */
  198. | <MULTI_LINE_COMMENT:
  199. "/*" (~["*"])+ "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
  200. }
  201. TOKEN : /* RESERVED WORDS AND LITERALS */
  202. {
  203. < ABSTRACT : "abstract" >
  204. | < BOOLEAN: "boolean" >
  205. | < BREAK: "break" >
  206. | < CLASS: "class" >
  207. | < BYTE: "byte" >
  208. | < CASE: "case" >
  209. | < CATCH: "catch" >
  210. | < CHAR: "char" >
  211. | < CONST: "const" >
  212. | < CONTINUE: "continue" >
  213. | < _DEFAULT: "default" >
  214. | < DO: "do" >
  215. | < DOUBLE: "double" >
  216. | < ELSE: "else" >
  217. | < ENUM: "enum" >
  218. | < EXTENDS: "extends" >
  219. | < FALSE: "false" >
  220. | < FINAL: "final" >
  221. | < FINALLY: "finally" >
  222. | < FLOAT: "float" >
  223. | < FOR: "for" >
  224. | < GOTO: "goto" >
  225. | < IF: "if" >
  226. | < IMPLEMENTS: "implements" >
  227. | < IMPORT: "import" >
  228. | < INSTANCEOF: "instanceof" >
  229. | < INT: "int" >
  230. | < INTERFACE: "interface" >
  231. | < LONG: "long" >
  232. | < NATIVE: "native" >
  233. | < NEW: "new" >
  234. | < NULL: "null" >
  235. | < PACKAGE: "package" >
  236. | < PRIVATE: "private" >
  237. | < PROTECTED: "protected" >
  238. | < PUBLIC: "public" >
  239. | < RETURN: "return" >
  240. | < SHORT: "short" >
  241. | < STATIC: "static" >
  242. | < STRICTFP : "strictfp" >
  243. | < SWITCH: "switch" >
  244. | < SYNCHRONIZED: "synchronized" >
  245. | < TRANSIENT: "transient" >
  246. | < THROW: "throw" >
  247. | < THROWS: "throws" >
  248. | < TRUE: "true" >
  249. | < TRY: "try" >
  250. | < VOID: "void" >
  251. | < VOLATILE: "volatile" >
  252. | < WHILE: "while" >
  253. }
  254. TOKEN : /* LITERALS */
  255. {
  256. < INTEGER_LITERAL:
  257. <DECIMAL_LITERAL> (["l","L"])?
  258. | <HEX_LITERAL> (["l","L"])?
  259. | <OCTAL_LITERAL> (["l","L"])?
  260. >
  261. |
  262. < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
  263. |
  264. < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
  265. |
  266. < #OCTAL_LITERAL: "0" (["0"-"7"])* >
  267. |
  268. < FLOATING_POINT_LITERAL:
  269. (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])?
  270. | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])?
  271. | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?
  272. | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]
  273. >
  274. |
  275. < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
  276. |
  277. < CHARACTER_LITERAL:
  278. "'"
  279. ( (~["'","\\","\n","\r"])
  280. | ("\\"
  281. ( ["n","t","b","r","f","\\","'","\""]
  282. | ["0"-"7"] ( ["0"-"7"] )?
  283. | ["0"-"3"] ["0"-"7"] ["0"-"7"]
  284. )
  285. )
  286. )
  287. "'"
  288. >
  289. |
  290. < STRING_LITERAL:
  291. "\""
  292. ( (~["\"","\\","\n","\r"])
  293. | ("\\"
  294. ( ["n","t","b","r","f","\\","'","\""]
  295. | ["0"-"7"] ( ["0"-"7"] )?
  296. | ["0"-"3"] ["0"-"7"] ["0"-"7"]
  297. )
  298. )
  299. )*
  300. "\""
  301. >
  302. |
  303. < FORMAL_COMMENT:
  304. "/**" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/"
  305. >
  306. }
  307. TOKEN : /* IDENTIFIERS */
  308. {
  309. < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >
  310. |
  311. < #LETTER:
  312. [
  313. "$",
  314. "A"-"Z",
  315. "_",
  316. "a"-"z",
  317. "\u00c0"-"\u00d6",
  318. "\u00d8"-"\u00f6",
  319. "\u00f8"-"\u00ff",
  320. "\u0100"-"\u1fff",
  321. "\u3040"-"\u318f",
  322. "\u3300"-"\u337f",
  323. "\u3400"-"\u3d2d",
  324. "\u4e00"-"\u9fff",
  325. "\uf900"-"\ufaff"
  326. ]
  327. >
  328. |
  329. < #DIGIT:
  330. [
  331. "0"-"9",
  332. "\u0660"-"\u0669",
  333. "\u06f0"-"\u06f9",
  334. "\u0966"-"\u096f",
  335. "\u09e6"-"\u09ef",
  336. "\u0a66"-"\u0a6f",
  337. "\u0ae6"-"\u0aef",
  338. "\u0b66"-"\u0b6f",
  339. "\u0be7"-"\u0bef",
  340. "\u0c66"-"\u0c6f",
  341. "\u0ce6"-"\u0cef",
  342. "\u0d66"-"\u0d6f",
  343. "\u0e50"-"\u0e59",
  344. "\u0ed0"-"\u0ed9",
  345. "\u1040"-"\u1049"
  346. ]
  347. >
  348. }
  349. TOKEN : /* SEPARATORS */
  350. {
  351. < LPAREN: "(" >
  352. | < RPAREN: ")" >
  353. | < LBRACE: "{" >
  354. | < RBRACE: "}" >
  355. | < LBRACKET: "[" >
  356. | < RBRACKET: "]" >
  357. | < SEMICOLON: ";" >
  358. | < COMMA: "," >
  359. | < DOT: "." >
  360. }
  361. TOKEN : /* OPERATORS */
  362. {
  363. < ASSIGN: "=" >
  364. | < GT: ">" >
  365. | < GTX: "@gt" >
  366. | < LT: "<" >
  367. | < LTX: "@lt" >
  368. | < BANG: "!" >
  369. | < TILDE: "~" >
  370. | < HOOK: "?" >
  371. | < COLON: ":" >
  372. | < EQ: "==" >
  373. | < LE: "<=" >
  374. | < LEX: "@lteq" >
  375. | < GE: ">=" >
  376. | < GEX: "@gteq" >
  377. | < NE: "!=" >
  378. | < BOOL_OR: "||" >
  379. | < BOOL_ORX: "@or" >
  380. | < BOOL_AND: "&&" >
  381. | < BOOL_ANDX: "@and" >
  382. | < INCR: "++" >
  383. | < DECR: "--" >
  384. | < PLUS: "+" >
  385. | < MINUS: "-" >
  386. | < STAR: "*" >
  387. | < SLASH: "/" >
  388. | < BIT_AND: "&" >
  389. | < BIT_ANDX: "@bitwise_and" >
  390. | < BIT_OR: "|" >
  391. | < BIT_ORX: "@bitwise_or" >
  392. | < XOR: "^" >
  393. | < MOD: "%" >
  394. | < LSHIFT: "<<" >
  395. | < LSHIFTX: "@left_shift" >
  396. | < RSIGNEDSHIFT: ">>" >
  397. | < RSIGNEDSHIFTX: "@right_shift" >
  398. | < RUNSIGNEDSHIFT: ">>>" >
  399. | < RUNSIGNEDSHIFTX: "@right_unsigned_shift" >
  400. | < PLUSASSIGN: "+=" >
  401. | < MINUSASSIGN: "-=" >
  402. | < STARASSIGN: "*=" >
  403. | < SLASHASSIGN: "/=" >
  404. | < ANDASSIGN: "&=" >
  405. | < ANDASSIGNX: "@and_assign" >
  406. | < ORASSIGN: "|=" >
  407. | < ORASSIGNX: "@or_assign" >
  408. | < XORASSIGN: "^=" >
  409. | < MODASSIGN: "%=" >
  410. | < LSHIFTASSIGN: "<<=" >
  411. | < LSHIFTASSIGNX: "@left_shift_assign" >
  412. | < RSIGNEDSHIFTASSIGN: ">>=" >
  413. | < RSIGNEDSHIFTASSIGNX: "@right_shift_assign" >
  414. | < RUNSIGNEDSHIFTASSIGN: ">>>=" >
  415. | < RUNSIGNEDSHIFTASSIGNX: "@right_unsigned_shift_assign" >
  416. }
  417. /*
  418. Thanks to Sreenivasa Viswanadha for suggesting how to get rid of expensive
  419. lookahead here.
  420. */
  421. boolean Line() :
  422. {}
  423. {
  424. <EOF> {
  425. Interpreter.debug("End of File!");
  426. return true;
  427. }
  428. |
  429. BlockStatement() {
  430. return false;
  431. }
  432. }
  433. /*****************************************
  434. * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
  435. *****************************************/
  436. /*
  437. Gather modifiers for a class, method, or field.
  438. I lookahead is true then we are being called as part of a lookahead and we
  439. should not enforce any rules. Otherwise we validate based on context
  440. (field, method, class)
  441. */
  442. Modifiers Modifiers( int context, boolean lookahead ) :
  443. {
  444. Modifiers mods = null;
  445. }
  446. {
  447. (
  448. (
  449. "private" | "protected" | "public" | "synchronized" | "final"
  450. | "native" | "transient" | "volatile" | "abstract" | "static"
  451. | "strictfp"
  452. ) {
  453. if ( !lookahead )
  454. try {
  455. if ( mods == null ) mods = new Modifiers();
  456. mods.addModifier( context, getToken(0).image );
  457. } catch ( IllegalStateException e ) {
  458. throw createParseException( e.getMessage() );
  459. }
  460. }
  461. )* {
  462. return mods;
  463. }
  464. }
  465. /**
  466. */
  467. void ClassDeclaration() :
  468. {/*@bgen(jjtree) ClassDeclaration */
  469. BSHClassDeclaration jjtn000 = new BSHClassDeclaration(JJTCLASSDECLARATION);
  470. boolean jjtc000 = true;
  471. jjtree.openNodeScope(jjtn000);
  472. jjtreeOpenNodeScope(jjtn000);
  473. /*@egen*/
  474. Modifiers mods;
  475. Token name;
  476. int numInterfaces;
  477. }
  478. {/*@bgen(jjtree) ClassDeclaration */
  479. try {
  480. /*@egen*/
  481. mods = Modifiers( Modifiers.CLASS, false )
  482. ( "class" | "interface" { jjtn000.isInterface=true; } )
  483. name=<IDENTIFIER>
  484. [ "extends" AmbiguousName() { jjtn000.extend = true; } ]
  485. [ "implements" numInterfaces=NameList()
  486. { jjtn000.numInterfaces=numInterfaces; } ]
  487. Block()/*@bgen(jjtree)*/
  488. {
  489. jjtree.closeNodeScope(jjtn000, true);
  490. jjtc000 = false;
  491. jjtreeCloseNodeScope(jjtn000);
  492. }
  493. /*@egen*/
  494. {
  495. jjtn000.modifiers = mods;
  496. jjtn000.name = name.image;
  497. }/*@bgen(jjtree)*/
  498. } catch (Throwable jjte000) {
  499. if (jjtc000) {
  500. jjtree.clearNodeScope(jjtn000);
  501. jjtc000 = false;
  502. } else {
  503. jjtree.popNode();
  504. }
  505. if (jjte000 instanceof RuntimeException) {
  506. throw (RuntimeException)jjte000;
  507. }
  508. if (jjte000 instanceof ParseException) {
  509. throw (ParseException)jjte000;
  510. }
  511. throw (Error)jjte000;
  512. } finally {
  513. if (jjtc000) {
  514. jjtree.closeNodeScope(jjtn000, true);
  515. jjtreeCloseNodeScope(jjtn000);
  516. }
  517. }
  518. /*@egen*/
  519. }
  520. void MethodDeclaration() :
  521. {/*@bgen(jjtree) MethodDeclaration */
  522. BSHMethodDeclaration jjtn000 = new BSHMethodDeclaration(JJTMETHODDECLARATION);
  523. boolean jjtc000 = true;
  524. jjtree.openNodeScope(jjtn000);
  525. jjtreeOpenNodeScope(jjtn000);
  526. /*@egen*/
  527. Token t = null;
  528. Modifiers mods;
  529. int count;
  530. }
  531. {/*@bgen(jjtree) MethodDeclaration */
  532. try {
  533. /*@egen*/
  534. mods = Modifiers( Modifiers.METHOD, false ) { jjtn000.modifiers = mods; }
  535. (
  536. LOOKAHEAD( <IDENTIFIER> "(" )
  537. t = <IDENTIFIER> { jjtn000.name = t.image; }
  538. |
  539. ReturnType()
  540. t = <IDENTIFIER> { jjtn000.name = t.image; }
  541. )
  542. FormalParameters()
  543. [ "throws" count=NameList() { jjtn000.numThrows=count; } ]
  544. ( Block() | ";" )/*@bgen(jjtree)*/
  545. } catch (Throwable jjte000) {
  546. if (jjtc000) {
  547. jjtree.clearNodeScope(jjtn000);
  548. jjtc000 = false;
  549. } else {
  550. jjtree.popNode();
  551. }
  552. if (jjte000 instanceof RuntimeException) {
  553. throw (RuntimeException)jjte000;
  554. }
  555. if (jjte000 instanceof ParseException) {
  556. throw (ParseException)jjte000;
  557. }
  558. throw (Error)jjte000;
  559. } finally {
  560. if (jjtc000) {
  561. jjtree.closeNodeScope(jjtn000, true);
  562. jjtreeCloseNodeScope(jjtn000);
  563. }
  564. }
  565. /*@egen*/
  566. }
  567. void PackageDeclaration () :
  568. {/*@bgen(jjtree) PackageDeclaration */
  569. BSHPackageDeclaration jjtn000 = new BSHPackageDeclaration(JJTPACKAGEDECLARATION);
  570. boolean jjtc000 = true;
  571. jjtree.openNodeScope(jjtn000);
  572. jjtreeOpenNodeScope(jjtn000);
  573. /*@egen*/ }
  574. {/*@bgen(jjtree) PackageDeclaration */
  575. try {
  576. /*@egen*/
  577. "package" AmbiguousName()/*@bgen(jjtree)*/
  578. } catch (Throwable jjte000) {
  579. if (jjtc000) {
  580. jjtree.clearNodeScope(jjtn000);
  581. jjtc000 = false;
  582. } else {
  583. jjtree.popNode();
  584. }
  585. if (jjte000 instanceof RuntimeException) {
  586. throw (RuntimeException)jjte000;
  587. }
  588. if (jjte000 instanceof ParseException) {
  589. throw (ParseException)jjte000;
  590. }
  591. throw (Error)jjte000;
  592. } finally {
  593. if (jjtc000) {
  594. jjtree.closeNodeScope(jjtn000, true);
  595. jjtreeCloseNodeScope(jjtn000);
  596. }
  597. }
  598. /*@egen*/
  599. }
  600. void ImportDeclaration() :
  601. {/*@bgen(jjtree) ImportDeclaration */
  602. BSHImportDeclaration jjtn000 = new BSHImportDeclaration(JJTIMPORTDECLARATION);
  603. boolean jjtc000 = true;
  604. jjtree.openNodeScope(jjtn000);
  605. jjtreeOpenNodeScope(jjtn000);
  606. /*@egen*/
  607. Token s = null;
  608. Token t = null;
  609. }
  610. {/*@bgen(jjtree) ImportDeclaration */
  611. try {
  612. /*@egen*/
  613. LOOKAHEAD( 3 )
  614. [ s = "static" ] "import" AmbiguousName() [ t = "." "*" ] ";"/*@bgen(jjtree)*/
  615. {
  616. jjtree.closeNodeScope(jjtn000, true);
  617. jjtc000 = false;
  618. jjtreeCloseNodeScope(jjtn000);
  619. }
  620. /*@egen*/
  621. {
  622. if ( s != null ) jjtn000.staticImport = true;
  623. if ( t != null ) jjtn000.importPackage = true;
  624. }
  625. |
  626. // bsh super import statement
  627. "import" "*" ";"/*@bgen(jjtree)*/
  628. {
  629. jjtree.closeNodeScope(jjtn000, true);
  630. jjtc000 = false;
  631. jjtreeCloseNodeScope(jjtn000);
  632. }
  633. /*@egen*/ {
  634. jjtn000.superImport = true;
  635. }/*@bgen(jjtree)*/
  636. } catch (Throwable jjte000) {
  637. if (jjtc000) {
  638. jjtree.clearNodeScope(jjtn000);
  639. jjtc000 = false;
  640. } else {
  641. jjtree.popNode();
  642. }
  643. if (jjte000 instanceof RuntimeException) {
  644. throw (RuntimeException)jjte000;
  645. }
  646. if (jjte000 instanceof ParseException) {
  647. throw (ParseException)jjte000;
  648. }
  649. throw (Error)jjte000;
  650. } finally {
  651. if (jjtc000) {
  652. jjtree.closeNodeScope(jjtn000, true);
  653. jjtreeCloseNodeScope(jjtn000);
  654. }
  655. }
  656. /*@egen*/
  657. }
  658. void VariableDeclarator() :
  659. {/*@bgen(jjtree) VariableDeclarator */
  660. BSHVariableDeclarator jjtn000 = new BSHVariableDeclarator(JJTVARIABLEDECLARATOR);
  661. boolean jjtc000 = true;
  662. jjtree.openNodeScope(jjtn000);
  663. jjtreeOpenNodeScope(jjtn000);
  664. /*@egen*/
  665. Token t;
  666. }
  667. {/*@bgen(jjtree) VariableDeclarator */
  668. try {
  669. /*@egen*/
  670. t=<IDENTIFIER> [ "=" VariableInitializer() ]/*@bgen(jjtree)*/
  671. {
  672. jjtree.closeNodeScope(jjtn000, true);
  673. jjtc000 = false;
  674. jjtreeCloseNodeScope(jjtn000);
  675. }
  676. /*@egen*/
  677. {
  678. jjtn000.name = t.image;
  679. }/*@bgen(jjtree)*/
  680. } catch (Throwable jjte000) {
  681. if (jjtc000) {
  682. jjtree.clearNodeScope(jjtn000);
  683. jjtc000 = false;
  684. } else {
  685. jjtree.popNode();
  686. }
  687. if (jjte000 instanceof RuntimeException) {
  688. throw (RuntimeException)jjte000;
  689. }
  690. if (jjte000 instanceof ParseException) {
  691. throw (ParseException)jjte000;
  692. }
  693. throw (Error)jjte000;
  694. } finally {
  695. if (jjtc000) {
  696. jjtree.closeNodeScope(jjtn000, true);
  697. jjtreeCloseNodeScope(jjtn000);
  698. }
  699. }
  700. /*@egen*/
  701. }
  702. /*
  703. this originally handled postfix array dimensions...
  704. void VariableDeclaratorId() #VariableDeclaratorId :
  705. { Token t; }
  706. {
  707. t=<IDENTIFIER> { jjtThis.name = t.image; }
  708. ( "[" "]" { jjtThis.addUndefinedDimension(); } )*
  709. }
  710. */
  711. void VariableInitializer() :
  712. {}
  713. {
  714. ArrayInitializer()
  715. |
  716. Expression()
  717. }
  718. void ArrayInitializer() :
  719. {/*@bgen(jjtree) ArrayInitializer */
  720. BSHArrayInitializer jjtn000 = new BSHArrayInitializer(JJTARRAYINITIALIZER);
  721. boolean jjtc000 = true;
  722. jjtree.openNodeScope(jjtn000);
  723. jjtreeOpenNodeScope(jjtn000);
  724. /*@egen*/}
  725. {/*@bgen(jjtree) ArrayInitializer */
  726. try {
  727. /*@egen*/
  728. "{" [ VariableInitializer()
  729. ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"/*@bgen(jjtree)*/
  730. } catch (Throwable jjte000) {
  731. if (jjtc000) {
  732. jjtree.clearNodeScope(jjtn000);
  733. jjtc000 = false;
  734. } else {
  735. jjtree.popNode();
  736. }
  737. if (jjte000 instanceof RuntimeException) {
  738. throw (RuntimeException)jjte000;
  739. }
  740. if (jjte000 instanceof ParseException) {
  741. throw (ParseException)jjte000;
  742. }
  743. throw (Error)jjte000;
  744. } finally {
  745. if (jjtc000) {
  746. jjtree.closeNodeScope(jjtn000, true);
  747. jjtreeCloseNodeScope(jjtn000);
  748. }
  749. }
  750. /*@egen*/
  751. }
  752. void FormalParameters() :
  753. {/*@bgen(jjtree) FormalParameters */
  754. BSHFormalParameters jjtn000 = new BSHFormalParameters(JJTFORMALPARAMETERS);
  755. boolean jjtc000 = true;
  756. jjtree.openNodeScope(jjtn000);
  757. jjtreeOpenNodeScope(jjtn000);
  758. /*@egen*/}
  759. {/*@bgen(jjtree) FormalParameters */
  760. try {
  761. /*@egen*/
  762. "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"/*@bgen(jjtree)*/
  763. } catch (Throwable jjte000) {
  764. if (jjtc000) {
  765. jjtree.clearNodeScope(jjtn000);
  766. jjtc000 = false;
  767. } else {
  768. jjtree.popNode();
  769. }
  770. if (jjte000 instanceof RuntimeException) {
  771. throw (RuntimeException)jjte000;
  772. }
  773. if (jjte000 instanceof ParseException) {
  774. throw (ParseException)jjte000;
  775. }
  776. throw (Error)jjte000;
  777. } finally {
  778. if (jjtc000) {
  779. jjtree.closeNodeScope(jjtn000, true);
  780. jjtreeCloseNodeScope(jjtn000);
  781. }
  782. }
  783. /*@egen*/
  784. }
  785. void FormalParameter() :
  786. {/*@bgen(jjtree) FormalParameter */
  787. BSHFormalParameter jjtn000 = new BSHFormalParameter(JJTFORMALPARAMETER);
  788. boolean jjtc000 = true;
  789. jjtree.openNodeScope(jjtn000);
  790. jjtreeOpenNodeScope(jjtn000);
  791. /*@egen*/ Token t; }
  792. {/*@bgen(jjtree) FormalParameter */
  793. try {
  794. /*@egen*/
  795. // added [] to Type for bsh. Removed [ final ] - is that legal?
  796. LOOKAHEAD(2) Type() t=<IDENTIFIER>/*@bgen(jjtree)*/
  797. {
  798. jjtree.closeNodeScope(jjtn000, true);
  799. jjtc000 = false;
  800. jjtreeCloseNodeScope(jjtn000);
  801. }
  802. /*@egen*/ { jjtn000.name = t.image; }
  803. |
  804. t=<IDENTIFIER>/*@bgen(jjtree)*/
  805. {
  806. jjtree.closeNodeScope(jjtn000, true);
  807. jjtc000 = false;
  808. jjtreeCloseNodeScope(jjtn000);
  809. }
  810. /*@egen*/ { jjtn000.name = t.image; }/*@bgen(jjtree)*/
  811. } catch (Throwable jjte000) {
  812. if (jjtc000) {
  813. jjtree.clearNodeScope(jjtn000);
  814. jjtc000 = false;
  815. } else {
  816. jjtree.popNode();
  817. }
  818. if (jjte000 instanceof RuntimeException) {
  819. throw (RuntimeException)jjte000;
  820. }
  821. if (jjte000 instanceof ParseException) {
  822. throw (ParseException)jjte000;
  823. }
  824. throw (Error)jjte000;
  825. } finally {
  826. if (jjtc000) {
  827. jjtree.closeNodeScope(jjtn000, true);
  828. jjtreeCloseNodeScope(jjtn000);
  829. }
  830. }
  831. /*@egen*/
  832. }
  833. /*
  834. Type, name and expression syntax follows.
  835. */
  836. void Type() :
  837. {/*@bgen(jjtree) Type */
  838. BSHType jjtn000 = new BSHType(JJTTYPE);
  839. boolean jjtc000 = true;
  840. jjtree.openNodeScope(jjtn000);
  841. jjtreeOpenNodeScope(jjtn000);
  842. /*@egen*/ }
  843. {/*@bgen(jjtree) Type */
  844. try {
  845. /*@egen*/
  846. /*
  847. The embedded lookahead is (was?) necessary to disambiguate for
  848. PrimaryPrefix. ( )* is a choice point. It took me a while to
  849. figure out where to put that. This stuff is annoying.
  850. */
  851. ( PrimitiveType() | AmbiguousName() )
  852. ( LOOKAHEAD(2) "[" "]" { jjtn000.addArrayDimension(); } )*/*@bgen(jjtree)*/
  853. } catch (Throwable jjte000) {
  854. if (jjtc000) {
  855. jjtree.clearNodeScope(jjtn000);
  856. jjtc000 = false;
  857. } else {
  858. jjtree.popNode();
  859. }
  860. if (jjte000 instanceof RuntimeException) {
  861. throw (RuntimeException)jjte000;
  862. }
  863. if (jjte000 instanceof ParseException) {
  864. throw (ParseException)jjte000;
  865. }
  866. throw (Error)jjte000;
  867. } finally {
  868. if (jjtc000) {
  869. jjtree.closeNodeScope(jjtn000, true);
  870. jjtreeCloseNodeScope(jjtn000);
  871. }
  872. }
  873. /*@egen*/
  874. }
  875. /*
  876. Originally called ResultType in the grammar
  877. */
  878. void ReturnType() :
  879. {/*@bgen(jjtree) ReturnType */
  880. BSHReturnType jjtn000 = new BSHReturnType(JJTRETURNTYPE);
  881. boolean jjtc000 = true;
  882. jjtree.openNodeScope(jjtn000);
  883. jjtreeOpenNodeScope(jjtn000);
  884. /*@egen*/ }
  885. {/*@bgen(jjtree) ReturnType */
  886. try {
  887. /*@egen*/
  888. "void"/*@bgen(jjtree)*/
  889. {
  890. jjtree.closeNodeScope(jjtn000, true);
  891. jjtc000 = false;
  892. jjtreeCloseNodeScope(jjtn000);
  893. }
  894. /*@egen*/ { jjtn000.isVoid = true; }
  895. |
  896. Type()/*@bgen(jjtree)*/
  897. } catch (Throwable jjte000) {
  898. if (jjtc000) {
  899. jjtree.clearNodeScope(jjtn000);
  900. jjtc000 = false;
  901. } else {
  902. jjtree.popNode();
  903. }
  904. if (jjte000 instanceof RuntimeException) {
  905. throw (RuntimeException)jjte000;
  906. }
  907. if (jjte000 instanceof ParseException) {
  908. throw (ParseException)jjte000;
  909. }
  910. throw (Error)jjte000;
  911. } finally {
  912. if (jjtc000) {
  913. jjtree.closeNodeScope(jjtn000, true);
  914. jjtreeCloseNodeScope(jjtn000);
  915. }
  916. }
  917. /*@egen*/
  918. }
  919. void PrimitiveType() :
  920. {/*@bgen(jjtree) PrimitiveType */
  921. BSHPrimitiveType jjtn000 = new BSHPrimitiveType(JJTPRIMITIVETYPE);
  922. boolean jjtc000 = true;
  923. jjtree.openNodeScope(jjtn000);
  924. jjtreeOpenNodeScope(jjtn000);
  925. /*@egen*/ } {/*@bgen(jjtree) PrimitiveType */
  926. try {
  927. /*@egen*/
  928. "boolean"/*@bgen(jjtree)*/
  929. {
  930. jjtree.closeNodeScope(jjtn000, true);
  931. jjtc000 = false;
  932. jjtreeCloseNodeScope(jjtn000);
  933. }
  934. /*@egen*/ { jjtn000.type = Boolean.TYPE; }
  935. | "char"/*@bgen(jjtree)*/
  936. {
  937. jjtree.closeNodeScope(jjtn000, true);
  938. jjtc000 = false;
  939. jjtreeCloseNodeScope(jjtn000);
  940. }
  941. /*@egen*/ { jjtn000.type = Character.TYPE; }
  942. | "byte"/*@bgen(jjtree)*/
  943. {
  944. jjtree.closeNodeScope(jjtn000, true);
  945. jjtc000 = false;
  946. jjtreeCloseNodeScope(jjtn000);
  947. }
  948. /*@egen*/ { jjtn000.type = Byte.TYPE; }
  949. | "short"/*@bgen(jjtree)*/
  950. {
  951. jjtree.closeNodeScope(jjtn000, true);
  952. jjtc000 = false;
  953. jjtreeCloseNodeScope(jjtn000);
  954. }
  955. /*@egen*/ { jjtn000.type = Short.TYPE; }
  956. | "int"/*@bgen(jjtree)*/
  957. {
  958. jjtree.closeNodeScope(jjtn000, true);
  959. jjtc000 = false;
  960. jjtreeCloseNodeScope(jjtn000);
  961. }
  962. /*@egen*/ { jjtn000.type = Integer.TYPE; }
  963. | "long"/*@bgen(jjtree)*/
  964. {
  965. jjtree.closeNodeScope(jjtn000, true);
  966. jjtc000 = false;
  967. jjtreeCloseNodeScope(jjtn000);
  968. }
  969. /*@egen*/ { jjtn000.type = Long.TYPE; }
  970. | "float"/*@bgen(jjtree)*/
  971. {
  972. jjtree.closeNodeScope(jjtn000, true);
  973. jjtc000 = false;
  974. jjtreeCloseNodeScope(jjtn000);
  975. }
  976. /*@egen*/ { jjtn000.type = Float.TYPE; }
  977. | "double"/*@bgen(jjtree)*/
  978. {
  979. jjtree.closeNodeScope(jjtn000, true);
  980. jjtc000 = false;
  981. jjtreeCloseNodeScope(jjtn000);
  982. }
  983. /*@egen*/ { jjtn000.type = Double.TYPE; }/*@bgen(jjtree)*/
  984. } finally {
  985. if (jjtc000) {
  986. jjtree.closeNodeScope(jjtn000, true);
  987. jjtreeCloseNodeScope(jjtn000);
  988. }
  989. }
  990. /*@egen*/
  991. }
  992. void AmbiguousName() :
  993. /*
  994. A lookahead of 2 is required below since "Name" can be followed by a ".*"
  995. when used in the context of an "ImportDeclaration".
  996. */
  997. {/*@bgen(jjtree) AmbiguousName */
  998. BSHAmbiguousName jjtn000 = new BSHAmbiguousName(JJTAMBIGUOUSNAME);
  999. boolean jjtc000 = true;
  1000. jjtree.openNodeScope(jjtn000);
  1001. jjtreeOpenNodeScope(jjtn000);
  1002. /*@egen*/
  1003. Token t;
  1004. StringBuffer s;
  1005. }
  1006. {/*@bgen(jjtree) AmbiguousName */
  1007. try {
  1008. /*@egen*/
  1009. t = <IDENTIFIER> {
  1010. s = new StringBuffer(t.image);
  1011. }
  1012. ( LOOKAHEAD(2) "." t = <IDENTIFIER> { s.append("."+t.image); } )*/*@bgen(jjtree)*/
  1013. {
  1014. jjtree.closeNodeScope(jjtn000, true);
  1015. jjtc000 = false;
  1016. jjtreeCloseNodeScope(jjtn000);
  1017. }
  1018. /*@egen*/ {
  1019. jjtn000.text = s.toString();
  1020. }/*@bgen(jjtree)*/
  1021. } finally {
  1022. if (jjtc000) {
  1023. jjtree.closeNodeScope(jjtn000, true);
  1024. jjtreeCloseNodeScope(jjtn000);
  1025. }
  1026. }
  1027. /*@egen*/
  1028. }
  1029. int NameList() :
  1030. { int count = 0; }
  1031. {
  1032. AmbiguousName() { ++count; } ( "," AmbiguousName() { ++count; } )*
  1033. { return count; }
  1034. }
  1035. /*
  1036. * Expression syntax follows.
  1037. */
  1038. void Expression() :
  1039. { }
  1040. {
  1041. /**
  1042. SYNTACTIC_LOOKAHEAD
  1043. Note: the original grammar was cheating here and we've fixed that,
  1044. but at the expense of another syntactic lookahead.
  1045. */
  1046. LOOKAHEAD( PrimaryExpression() AssignmentOperator() )
  1047. Assignment()
  1048. |
  1049. ConditionalExpression()
  1050. }
  1051. void Assignment() :
  1052. {/*@bgen(jjtree) Assignment */
  1053. BSHAssignment jjtn000 = new BSHAssignment(JJTASSIGNMENT);
  1054. boolean jjtc000 = true;
  1055. jjtree.openNodeScope(jjtn000);
  1056. jjtreeOpenNodeScope(jjtn000);
  1057. /*@egen*/ int op ; }
  1058. {/*@bgen(jjtree) Assignment */
  1059. try {
  1060. /*@egen*/
  1061. PrimaryExpression()
  1062. op = AssignmentOperator() { jjtn000.operator = op; }
  1063. // Add this for blocks, e.g. foo = { };
  1064. //( Expression() | Block() )
  1065. Expression()/*@bgen(jjtree)*/
  1066. } catch (Throwable jjte000) {
  1067. if (jjtc000) {
  1068. jjtree.clearNodeScope(jjtn000);
  1069. jjtc000 = false;
  1070. } else {
  1071. jjtree.popNode();
  1072. }
  1073. if (jjte000 instanceof RuntimeException) {
  1074. throw (RuntimeException)jjte000;
  1075. }
  1076. if (jjte000 instanceof ParseException) {
  1077. throw (ParseException)jjte000;
  1078. }
  1079. throw (Error)jjte000;
  1080. } finally {
  1081. if (jjtc000) {
  1082. jjtree.closeNodeScope(jjtn000, true);
  1083. jjtreeCloseNodeScope(jjtn000);
  1084. }
  1085. }
  1086. /*@egen*/
  1087. }
  1088. int AssignmentOperator() :
  1089. { Token t; }
  1090. {
  1091. ( "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "&=" | "^=" | "|=" |
  1092. "<<=" | "@left_shift_assign" | ">>=" | "@right_shift_assign" |
  1093. ">>>=" | "@right_unsigned_shift_assign" )
  1094. {
  1095. t = getToken(0);
  1096. return t.kind;
  1097. }
  1098. }
  1099. void ConditionalExpression() :
  1100. { }
  1101. {
  1102. ConditionalOrExpression() [ "?" Expression() ":"/*@bgen(jjtree) #TernaryExpression( 3) */
  1103. {
  1104. BSHTernaryExpression jjtn001 = new BSHTernaryExpression(JJTTERNARYEXPRESSION);
  1105. boolean jjtc001 = true;
  1106. jjtree.openNodeScope(jjtn001);
  1107. jjtreeOpenNodeScope(jjtn001);
  1108. }
  1109. try {
  1110. /*@egen*/ ConditionalExpression()/*@bgen(jjtree)*/
  1111. } catch (Throwable jjte001) {
  1112. if (jjtc001) {
  1113. jjtree.clearNodeScope(jjtn001);
  1114. jjtc001 = false;
  1115. } else {
  1116. jjtree.popNode();
  1117. }
  1118. if (jjte001 instanceof RuntimeException) {
  1119. throw (RuntimeException)jjte001;
  1120. }
  1121. if (jjte001 instanceof ParseException) {
  1122. throw (ParseException)jjte001;
  1123. }
  1124. throw (Error)jjte001;
  1125. } finally {
  1126. if (jjtc001) {
  1127. jjtree.closeNodeScope(jjtn001, 3);
  1128. jjtreeCloseNodeScope(jjtn001);
  1129. }
  1130. }
  1131. /*@egen*/ ]
  1132. }
  1133. void ConditionalOrExpression() :
  1134. { Token t=null; }
  1135. {
  1136. ConditionalAndExpression()
  1137. ( ( t = "||" | t = "@or" )
  1138. ConditionalAndExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
  1139. {
  1140. BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
  1141. boolean jjtc001 = true;
  1142. jjtree.openNodeScope(jjtn001);
  1143. jjtreeOpenNodeScope(jjtn001);
  1144. }
  1145. try {
  1146. /*@egen*//*@bgen(jjtree)*/
  1147. {
  1148. jjtree.closeNodeScope(jjtn001, 2);
  1149. jjtc001 = false;
  1150. jjtreeCloseNodeScope(jjtn001);
  1151. }
  1152. /*@egen*/
  1153. { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1154. } finally {
  1155. if (jjtc001) {
  1156. jjtree.closeNodeScope(jjtn001, 2);
  1157. jjtreeCloseNodeScope(jjtn001);
  1158. }
  1159. }
  1160. /*@egen*/ )*
  1161. }
  1162. void ConditionalAndExpression() :
  1163. { Token t=null; }
  1164. {
  1165. InclusiveOrExpression()
  1166. ( ( t = "&&" | t = "@and" )
  1167. InclusiveOrExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
  1168. {
  1169. BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
  1170. boolean jjtc001 = true;
  1171. jjtree.openNodeScope(jjtn001);
  1172. jjtreeOpenNodeScope(jjtn001);
  1173. }
  1174. try {
  1175. /*@egen*//*@bgen(jjtree)*/
  1176. {
  1177. jjtree.closeNodeScope(jjtn001, 2);
  1178. jjtc001 = false;
  1179. jjtreeCloseNodeScope(jjtn001);
  1180. }
  1181. /*@egen*/
  1182. { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1183. } finally {
  1184. if (jjtc001) {
  1185. jjtree.closeNodeScope(jjtn001, 2);
  1186. jjtreeCloseNodeScope(jjtn001);
  1187. }
  1188. }
  1189. /*@egen*/ )*
  1190. }
  1191. void InclusiveOrExpression() :
  1192. { Token t=null; }
  1193. {
  1194. ExclusiveOrExpression()
  1195. ( ( t = "|" | t = "@bitwise_or" )
  1196. ExclusiveOrExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
  1197. {
  1198. BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
  1199. boolean jjtc001 = true;
  1200. jjtree.openNodeScope(jjtn001);
  1201. jjtreeOpenNodeScope(jjtn001);
  1202. }
  1203. try {
  1204. /*@egen*//*@bgen(jjtree)*/
  1205. {
  1206. jjtree.closeNodeScope(jjtn001, 2);
  1207. jjtc001 = false;
  1208. jjtreeCloseNodeScope(jjtn001);
  1209. }
  1210. /*@egen*/
  1211. { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1212. } finally {
  1213. if (jjtc001) {
  1214. jjtree.closeNodeScope(jjtn001, 2);
  1215. jjtreeCloseNodeScope(jjtn001);
  1216. }
  1217. }
  1218. /*@egen*/ )*
  1219. }
  1220. void ExclusiveOrExpression() :
  1221. { Token t=null; }
  1222. {
  1223. AndExpression() ( t="^" AndExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
  1224. {
  1225. BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
  1226. boolean jjtc001 = true;
  1227. jjtree.openNodeScope(jjtn001);
  1228. jjtreeOpenNodeScope(jjtn001);
  1229. }
  1230. try {
  1231. /*@egen*//*@bgen(jjtree)*/
  1232. {
  1233. jjtree.closeNodeScope(jjtn001, 2);
  1234. jjtc001 = false;
  1235. jjtreeCloseNodeScope(jjtn001);
  1236. }
  1237. /*@egen*/
  1238. { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1239. } finally {
  1240. if (jjtc001) {
  1241. jjtree.closeNodeScope(jjtn001, 2);
  1242. jjtreeCloseNodeScope(jjtn001);
  1243. }
  1244. }
  1245. /*@egen*/ )*
  1246. }
  1247. void AndExpression() :
  1248. { Token t=null; }
  1249. {
  1250. EqualityExpression()
  1251. ( ( t = "&" | t = "@bitwise_and" )
  1252. EqualityExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
  1253. {
  1254. BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
  1255. boolean jjtc001 = true;
  1256. jjtree.openNodeScope(jjtn001);
  1257. jjtreeOpenNodeScope(jjtn001);
  1258. }
  1259. try {
  1260. /*@egen*//*@bgen(jjtree)*/
  1261. {
  1262. jjtree.closeNodeScope(jjtn001, 2);
  1263. jjtc001 = false;
  1264. jjtreeCloseNodeScope(jjtn001);
  1265. }
  1266. /*@egen*/
  1267. { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1268. } finally {
  1269. if (jjtc001) {
  1270. jjtree.closeNodeScope(jjtn001, 2);
  1271. jjtreeCloseNodeScope(jjtn001);
  1272. }
  1273. }
  1274. /*@egen*/ )*
  1275. }
  1276. void EqualityExpression() :
  1277. { Token t = null; }
  1278. {
  1279. InstanceOfExpression() ( ( t= "==" | t= "!=" ) InstanceOfExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
  1280. {
  1281. BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
  1282. boolean jjtc001 = true;
  1283. jjtree.openNodeScope(jjtn001);
  1284. jjtreeOpenNodeScope(jjtn001);
  1285. }
  1286. try {
  1287. /*@egen*//*@bgen(jjtree)*/
  1288. {
  1289. jjtree.closeNodeScope(jjtn001, 2);
  1290. jjtc001 = false;
  1291. jjtreeCloseNodeScope(jjtn001);
  1292. }
  1293. /*@egen*/
  1294. { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1295. } finally {
  1296. if (jjtc001) {
  1297. jjtree.closeNodeScope(jjtn001, 2);
  1298. jjtreeCloseNodeScope(jjtn001);
  1299. }
  1300. }
  1301. /*@egen*/
  1302. )*
  1303. }
  1304. void InstanceOfExpression() :
  1305. { Token t = null; }
  1306. {
  1307. RelationalExpression()
  1308. [ t = "instanceof" Type()/*@bgen(jjtree) #BinaryExpression( 2) */
  1309. {
  1310. BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
  1311. boolean jjtc001 = true;
  1312. jjtree.openNodeScope(jjtn001);
  1313. jjtreeOpenNodeScope(jjtn001);
  1314. }
  1315. try {
  1316. /*@egen*//*@bgen(jjtree)*/
  1317. {
  1318. jjtree.closeNodeScope(jjtn001, 2);
  1319. jjtc001 = false;
  1320. jjtreeCloseNodeScope(jjtn001);
  1321. }
  1322. /*@egen*/ { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1323. } finally {
  1324. if (jjtc001) {
  1325. jjtree.closeNodeScope(jjtn001, 2);
  1326. jjtreeCloseNodeScope(jjtn001);
  1327. }
  1328. }
  1329. /*@egen*/ ]
  1330. }
  1331. void RelationalExpression() :
  1332. { Token t = null; }
  1333. {
  1334. ShiftExpression()
  1335. ( ( t = "<" | t = "@lt" | t = ">" | t = "@gt" |
  1336. t = "<=" | t = "@lteq" | t = ">=" | t = "@gteq" )
  1337. ShiftExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
  1338. {
  1339. BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
  1340. boolean jjtc001 = true;
  1341. jjtree.openNodeScope(jjtn001);
  1342. jjtreeOpenNodeScope(jjtn001);
  1343. }
  1344. try {
  1345. /*@egen*//*@bgen(jjtree)*/
  1346. {
  1347. jjtree.closeNodeScope(jjtn001, 2);
  1348. jjtc001 = false;
  1349. jjtreeCloseNodeScope(jjtn001);
  1350. }
  1351. /*@egen*/
  1352. { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1353. } finally {
  1354. if (jjtc001) {
  1355. jjtree.closeNodeScope(jjtn001, 2);
  1356. jjtreeCloseNodeScope(jjtn001);
  1357. }
  1358. }
  1359. /*@egen*/ )*
  1360. }
  1361. void ShiftExpression() :
  1362. { Token t = null; }
  1363. {
  1364. AdditiveExpression()
  1365. ( ( t = "<<" | t = "@left_shift" | t = ">>" | t = "@right_shift" |
  1366. t = ">>>" | t = "@right_unsigned_shift" )
  1367. AdditiveExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
  1368. {
  1369. BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
  1370. boolean jjtc001 = true;
  1371. jjtree.openNodeScope(jjtn001);
  1372. jjtreeOpenNodeScope(jjtn001);
  1373. }
  1374. try {
  1375. /*@egen*//*@bgen(jjtree)*/
  1376. {
  1377. jjtree.closeNodeScope(jjtn001, 2);
  1378. jjtc001 = false;
  1379. jjtreeCloseNodeScope(jjtn001);
  1380. }
  1381. /*@egen*/
  1382. { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1383. } finally {
  1384. if (jjtc001) {
  1385. jjtree.closeNodeScope(jjtn001, 2);
  1386. jjtreeCloseNodeScope(jjtn001);
  1387. }
  1388. }
  1389. /*@egen*/ )*
  1390. }
  1391. void AdditiveExpression() :
  1392. { Token t = null; }
  1393. {
  1394. MultiplicativeExpression()
  1395. ( ( t= "+" | t= "-" ) MultiplicativeExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
  1396. {
  1397. BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
  1398. boolean jjtc001 = true;
  1399. jjtree.openNodeScope(jjtn001);
  1400. jjtreeOpenNodeScope(jjtn001);
  1401. }
  1402. try {
  1403. /*@egen*//*@bgen(jjtree)*/
  1404. {
  1405. jjtree.closeNodeScope(jjtn001, 2);
  1406. jjtc001 = false;
  1407. jjtreeCloseNodeScope(jjtn001);
  1408. }
  1409. /*@egen*/ { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1410. } finally {
  1411. if (jjtc001) {
  1412. jjtree.closeNodeScope(jjtn001, 2);
  1413. jjtreeCloseNodeScope(jjtn001);
  1414. }
  1415. }
  1416. /*@egen*/
  1417. )*
  1418. }
  1419. void MultiplicativeExpression() :
  1420. { Token t = null; }
  1421. {
  1422. UnaryExpression() ( ( t= "*" | t= "/" | t= "%" )
  1423. UnaryExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
  1424. {
  1425. BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
  1426. boolean jjtc001 = true;
  1427. jjtree.openNodeScope(jjtn001);
  1428. jjtreeOpenNodeScope(jjtn001);
  1429. }
  1430. try {
  1431. /*@egen*//*@bgen(jjtree)*/
  1432. {
  1433. jjtree.closeNodeScope(jjtn001, 2);
  1434. jjtc001 = false;
  1435. jjtreeCloseNodeScope(jjtn001);
  1436. }
  1437. /*@egen*/ { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1438. } finally {
  1439. if (jjtc001) {
  1440. jjtree.closeNodeScope(jjtn001, 2);
  1441. jjtreeCloseNodeScope(jjtn001);
  1442. }
  1443. }
  1444. /*@egen*/ )*
  1445. }
  1446. void UnaryExpression() :
  1447. { Token t = null; }
  1448. {
  1449. ( t="+" | t="-" ) UnaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
  1450. {
  1451. BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
  1452. boolean jjtc001 = true;
  1453. jjtree.openNodeScope(jjtn001);
  1454. jjtreeOpenNodeScope(jjtn001);
  1455. }
  1456. try {
  1457. /*@egen*//*@bgen(jjtree)*/
  1458. {
  1459. jjtree.closeNodeScope(jjtn001, 1);
  1460. jjtc001 = false;
  1461. jjtreeCloseNodeScope(jjtn001);
  1462. }
  1463. /*@egen*/
  1464. { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1465. } finally {
  1466. if (jjtc001) {
  1467. jjtree.closeNodeScope(jjtn001, 1);
  1468. jjtreeCloseNodeScope(jjtn001);
  1469. }
  1470. }
  1471. /*@egen*/
  1472. |
  1473. PreIncrementExpression()
  1474. |
  1475. PreDecrementExpression()
  1476. |
  1477. UnaryExpressionNotPlusMinus()
  1478. }
  1479. void PreIncrementExpression() :
  1480. { Token t = null; }
  1481. {
  1482. t="++" PrimaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
  1483. {
  1484. BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
  1485. boolean jjtc001 = true;
  1486. jjtree.openNodeScope(jjtn001);
  1487. jjtreeOpenNodeScope(jjtn001);
  1488. }
  1489. try {
  1490. /*@egen*//*@bgen(jjtree)*/
  1491. {
  1492. jjtree.closeNodeScope(jjtn001, 1);
  1493. jjtc001 = false;
  1494. jjtreeCloseNodeScope(jjtn001);
  1495. }
  1496. /*@egen*/
  1497. { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1498. } finally {
  1499. if (jjtc001) {
  1500. jjtree.closeNodeScope(jjtn001, 1);
  1501. jjtreeCloseNodeScope(jjtn001);
  1502. }
  1503. }
  1504. /*@egen*/
  1505. }
  1506. void PreDecrementExpression() :
  1507. { Token t = null; }
  1508. {
  1509. t="--" PrimaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
  1510. {
  1511. BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
  1512. boolean jjtc001 = true;
  1513. jjtree.openNodeScope(jjtn001);
  1514. jjtreeOpenNodeScope(jjtn001);
  1515. }
  1516. try {
  1517. /*@egen*//*@bgen(jjtree)*/
  1518. {
  1519. jjtree.closeNodeScope(jjtn001, 1);
  1520. jjtc001 = false;
  1521. jjtreeCloseNodeScope(jjtn001);
  1522. }
  1523. /*@egen*/
  1524. { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1525. } finally {
  1526. if (jjtc001) {
  1527. jjtree.closeNodeScope(jjtn001, 1);
  1528. jjtreeCloseNodeScope(jjtn001);
  1529. }
  1530. }
  1531. /*@egen*/
  1532. }
  1533. void UnaryExpressionNotPlusMinus() :
  1534. { Token t = null; }
  1535. {
  1536. ( t="~" | t="!" ) UnaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
  1537. {
  1538. BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
  1539. boolean jjtc001 = true;
  1540. jjtree.openNodeScope(jjtn001);
  1541. jjtreeOpenNodeScope(jjtn001);
  1542. }
  1543. try {
  1544. /*@egen*//*@bgen(jjtree)*/
  1545. {
  1546. jjtree.closeNodeScope(jjtn001, 1);
  1547. jjtc001 = false;
  1548. jjtreeCloseNodeScope(jjtn001);
  1549. }
  1550. /*@egen*/
  1551. { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
  1552. } finally {
  1553. if (jjtc001) {
  1554. jjtree.closeNodeScope(jjtn001, 1);
  1555. jjtreeCloseNodeScope(jjtn001);
  1556. }
  1557. }
  1558. /*@egen*/
  1559. |
  1560. // SYNTACTIC_LOOKAHEAD
  1561. LOOKAHEAD( CastLookahead() ) CastExpression()
  1562. |
  1563. PostfixExpression()
  1564. }
  1565. // This production is to determine lookahead only.
  1566. void CastLookahead() : { }
  1567. {
  1568. LOOKAHEAD(2) "(" PrimitiveType()
  1569. |
  1570. // SYNTACTIC_LOOKAHEAD
  1571. LOOKAHEAD( "(" AmbiguousName() "[" ) "(" AmbiguousName() "[" "]"
  1572. |
  1573. "(" AmbiguousName() ")" ( "~" | "!" | "(" | <IDENTIFIER> | /* "this" | "super" | */ "new" | Literal() )
  1574. }
  1575. void PostfixExpression() :
  1576. { Token t = null; }
  1577. {
  1578. // SYNTACTIC_LOOKAHEAD
  1579. LOOKAHEAD( PrimaryExpression() ("++"|"--") )
  1580. PrimaryExpression()
  1581. ( t="++" | t="--" )/*@bgen(jjtree) #UnaryExpression( 1) */
  1582. {
  1583. BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
  1584. boolean jjtc001 = true;
  1585. jjtree.openNodeScope(jjtn001);
  1586. jjtreeOpenNodeScope(jjtn001);
  1587. }
  1588. try {
  1589. /*@egen*//*@bgen(jjtree)*/
  1590. {
  1591. jjtree.closeNodeScope(jjtn001, 1);
  1592. jjtc001 = false;
  1593. jjtreeCloseNodeScope(jjtn001);
  1594. }
  1595. /*@egen*/ {
  1596. jjtn001.kind = t.kind; jjtn001.postfix = true; }/*@bgen(jjtree)*/
  1597. } finally {
  1598. if (jjtc001) {
  1599. jjtree.closeNodeScope(jjtn001, 1);
  1600. jjtreeCloseNodeScope(jjtn001);
  1601. }
  1602. }
  1603. /*@egen*/
  1604. |
  1605. PrimaryExpression()
  1606. }
  1607. void CastExpression() :
  1608. {/*@bgen(jjtree) CastExpression */
  1609. BSHCastExpression jjtn000 = new BSHCastExpression(JJTCASTEXPRESSION);
  1610. boolean jjtc000 = true;
  1611. jjtree.openNodeScope(jjtn000);
  1612. jjtreeOpenNodeScope(jjtn000);
  1613. /*@egen*/ }
  1614. {/*@bgen(jjtree) CastExpression */
  1615. try {
  1616. /*@egen*/
  1617. // SYNTACTIC_LOOKAHEAD
  1618. LOOKAHEAD( "(" PrimitiveType() ) "(" Type() ")" UnaryExpression()
  1619. |
  1620. "(" Type() ")" UnaryExpressionNotPlusMinus()/*@bgen(jjtree)*/
  1621. } catch (Throwable jjte000) {
  1622. if (jjtc000) {
  1623. jjtree.clearNodeScope(jjtn000);
  1624. jjtc000 = false;
  1625. } else {
  1626. jjtree.popNode();
  1627. }
  1628. if (jjte000 instanceof RuntimeException) {
  1629. throw (RuntimeException)jjte000;
  1630. }
  1631. if (jjte000 instanceof ParseException) {
  1632. throw (ParseException)jjte000;
  1633. }
  1634. throw (Error)jjte000;
  1635. } finally {
  1636. if (jjtc000) {
  1637. jjtree.closeNodeScope(jjtn000, true);
  1638. jjtreeCloseNodeScope(jjtn000);
  1639. }
  1640. }
  1641. /*@egen*/
  1642. }
  1643. void PrimaryExpression() : {/*@bgen(jjtree) PrimaryExpression */
  1644. BSHPrimaryExpression jjtn000 = new BSHPrimaryExpression(JJTPRIMARYEXPRESSION);
  1645. boolean jjtc000 = true;
  1646. jjtree.openNodeScope(jjtn000);
  1647. jjtreeOpenNodeScope(jjtn000);
  1648. /*@egen*/ }
  1649. {/*@bgen(jjtree) PrimaryExpression */
  1650. try {
  1651. /*@egen*/
  1652. PrimaryPrefix() ( PrimarySuffix() )*/*@bgen(jjtree)*/
  1653. } catch (Throwable jjte000) {
  1654. if (jjtc000) {
  1655. jjtree.clearNodeScope(jjtn000);
  1656. jjtc000 = false;
  1657. } else {
  1658. jjtree.popNode();
  1659. }
  1660. if (jjte000 instanceof RuntimeException) {
  1661. throw (RuntimeException)jjte000;
  1662. }
  1663. if (jjte000 instanceof ParseException) {
  1664. throw (ParseException)jjte000;
  1665. }
  1666. throw (Error)jjte000;
  1667. } finally {
  1668. if (jjtc000) {
  1669. jjtree.closeNodeScope(jjtn000, true);
  1670. jjtreeCloseNodeScope(jjtn000);
  1671. }
  1672. }
  1673. /*@egen*/
  1674. }
  1675. void MethodInvocation() : {/*@bgen(jjtree) MethodInvocation */
  1676. BSHMethodInvocation jjtn000 = new BSHMethodInvocation(JJTMETHODINVOCATION);
  1677. boolean jjtc000 = true;
  1678. jjtree.openNodeScope(jjtn000);
  1679. jjtreeOpenNodeScope(jjtn000);
  1680. /*@egen*/ }
  1681. {/*@bgen(jjtree) MethodInvocation */
  1682. try {
  1683. /*@egen*/
  1684. AmbiguousName() Arguments()/*@bgen(jjtree)*/
  1685. } catch (Throwable jjte000) {
  1686. if (jjtc000) {
  1687. jjtree.clearNodeScope(jjtn000);
  1688. jjtc000 = false;
  1689. } else {
  1690. jjtree.popNode();
  1691. }
  1692. if (jjte000 instanceof RuntimeException) {
  1693. throw (RuntimeException)jjte000;
  1694. }
  1695. if (jjte000 instanceof ParseException) {
  1696. throw (ParseException)jjte000;
  1697. }
  1698. throw (Error)jjte000;
  1699. } finally {
  1700. if (jjtc000) {
  1701. jjtree.closeNodeScope(jjtn000, true);
  1702. jjtreeCloseNodeScope(jjtn000);
  1703. }
  1704. }
  1705. /*@egen*/
  1706. }
  1707. void PrimaryPrefix() : { }
  1708. {
  1709. Literal()
  1710. |
  1711. "(" Expression() ")"
  1712. |
  1713. AllocationExpression()
  1714. |
  1715. // SYNTACTIC_LOOKAHEAD
  1716. LOOKAHEAD( MethodInvocation() )

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