home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 20 / AACD20.BIN / AACD / Programming / Jikes / Source / src / java.g < prev    next >
Encoding:
Text File  |  2001-02-24  |  120.4 KB  |  5,012 lines

  1. %options scopes,act,an=javaact.cpp,hn=javaact.h,em,tab,gp=c++,
  2. %options fp=java,escape=$,prefix=TK_,em,defer,output-size=125
  3. %options hblockb=\:,hblocke=:\
  4. %options nogoto-default
  5. %options single-productions
  6. %options la=2,names=max
  7. -- $Id: java.g,v 1.18 2000/07/22 21:02:51 mdejong Exp $
  8. -- This software is subject to the terms of the IBM Jikes Compiler
  9. -- License Agreement available at the following URL:
  10. -- http://www.ibm.com/research/jikes.
  11. -- Copyright (C) 1996, 1999, International Business Machines Corporation
  12. -- and others.  All Rights Reserved.
  13. -- You must accept the terms of that agreement to use this software.
  14.  
  15. ------------------------------------------------------------------------
  16. --
  17. --                               J A V A
  18. --
  19. -- This Java grammar is almost identical to the grammar defined in
  20. -- chapter 19 of the Java Language Specification manual together with
  21. -- the additional rules found in the 1.1 document. It is written here
  22. -- in JIKES PG format with semantic actions following each rule. In
  23. -- specifying the rules we enclosed all terminal symbols in single
  24. -- quotes so that they can be quickly distinguished from
  25. -- non-terminals. Optional symbols are suffixed with a question mark (?)
  26. -- and the rules expanding such definitions can be found at the end.
  27. --
  28. -- This grammar is totally faithful to the original rules except that
  29. -- some syntactic markers: PackageHeaderMarker, MethodHeaderMarker and
  30. -- BodyMarker, were added to allow the parser to skip certain irrelevant
  31. -- syntactic components when they are not needed.
  32. --
  33. -- The file javaact.h produced by JIKESPG from this file (java.g) contains a
  34. -- very readable definition of the grammar rules together with their
  35. -- associated semantic actions. That file is marked with appropriate
  36. -- location directives (automatically generated) which instructs the C++
  37. -- compiler to issue error messages in terms of this file (java.g).
  38. -- Therefore, though the user is encouraged to read javaact.h, no
  39. -- change should ever be made to that file. Instead, changes should
  40. -- always be made in this file and javaact.h should be regenerated
  41. -- using JIKESPG.
  42. --
  43. ------------------------------------------------------------------------
  44.  
  45. $Define
  46.  
  47. --
  48. -- This macro generates a header for an action function consisting
  49. -- of the rule in question (commented) and a location directive.
  50. --
  51. $location
  52. /.
  53.  
  54. //
  55. // Rule $rule_number:  $rule_text
  56. //
  57. #line $next_line "$input_file"./
  58.  
  59. --
  60. -- This macro is used to initialize the rule_action array
  61. -- to an unnamed function. A name is generated using the
  62. -- number of the rule in question.
  63. --
  64. $action
  65. /.
  66. #ifndef HEADERS
  67.     rule_action[$rule_number] = &Parser::Act$rule_number;
  68. #else
  69.     void Act$rule_number(void);
  70. #endif
  71. ./
  72.  
  73. --
  74. -- These macros are used to initialize the rule_action array
  75. -- to a specific named function.
  76. --
  77. $MakeArrayType
  78. /.
  79. #ifndef HEADERS
  80.     rule_action[$rule_number] = &Parser::MakeArrayType;
  81. #endif
  82. ./
  83.  
  84. $MakeSimpleName
  85. /.
  86. #ifndef HEADERS
  87.     rule_action[$rule_number] = &Parser::MakeSimpleName;
  88. #endif
  89. ./
  90.  
  91. $MakeFieldAccess
  92. /.
  93. #ifndef HEADERS
  94.     rule_action[$rule_number] = &Parser::MakeFieldAccess;
  95. #endif
  96. ./
  97.  
  98. $MakeQualifiedSuper
  99. /.
  100. #ifndef HEADERS
  101.     rule_action[$rule_number] = &Parser::MakeQualifiedSuper;
  102. #endif
  103. ./
  104.  
  105. $MakeQualifiedNew
  106. /.
  107. #ifndef HEADERS
  108.     rule_action[$rule_number] = &Parser::MakeQualifiedNew;
  109. #endif
  110. ./
  111.  
  112. $SetSym1ToSym2
  113. /.
  114. #ifndef HEADERS
  115.     rule_action[$rule_number] = &Parser::SetSym1ToSym2;
  116. #endif
  117. ./
  118.  
  119. $MakeEmptyStatement
  120. /.
  121. #ifndef HEADERS
  122.     rule_action[$rule_number] = &Parser::MakeEmptyStatement;
  123. #endif
  124. ./
  125.  
  126. $MakeLabeledStatement
  127. /.
  128. #ifndef HEADERS
  129.     rule_action[$rule_number] = &Parser::MakeLabeledStatement;
  130. #endif
  131. ./
  132.  
  133. $MakeExpressionStatement
  134. /.
  135. #ifndef HEADERS
  136.     rule_action[$rule_number] = &Parser::MakeExpressionStatement;
  137. #endif
  138. ./
  139.  
  140. $MakeIfThenElseStatement
  141. /.
  142. #ifndef HEADERS
  143.     rule_action[$rule_number] = &Parser::MakeIfThenElseStatement;
  144. #endif
  145. ./
  146.  
  147. $MakeWhileStatement
  148. /.
  149. #ifndef HEADERS
  150.     rule_action[$rule_number] = &Parser::MakeWhileStatement;
  151. #endif
  152. ./
  153.  
  154. $MakeForStatement
  155. /.
  156. #ifndef HEADERS
  157.     rule_action[$rule_number] = &Parser::MakeForStatement;
  158. #endif
  159. ./
  160.  
  161. $MakeArrayCreationExpression
  162. /.
  163. #ifndef HEADERS
  164.     rule_action[$rule_number] = &Parser::MakeArrayCreationExpression;
  165. #endif
  166. ./
  167.  
  168. $MakeSuperFieldAccess
  169. /.
  170. #ifndef HEADERS
  171.     rule_action[$rule_number] = &Parser::MakeSuperFieldAccess;
  172. #endif
  173. ./
  174.  
  175. $MakeSuperDoubleFieldAccess
  176. /.
  177. #ifndef HEADERS
  178.     rule_action[$rule_number] = &Parser::MakeSuperDoubleFieldAccess;
  179. #endif
  180. ./
  181.  
  182. $MakeArrayAccess
  183. /.
  184. #ifndef HEADERS
  185.     rule_action[$rule_number] = &Parser::MakeArrayAccess;
  186. #endif
  187. ./
  188.  
  189. $MakeCastExpression
  190. /.
  191. #ifndef HEADERS
  192.     rule_action[$rule_number] = &Parser::MakeCastExpression;
  193. #endif
  194. ./
  195.  
  196. --
  197. -- This macro is used to initialize the rule_action array
  198. -- to the NullAction function.
  199. --
  200. $NullAction
  201. /.
  202. #ifndef HEADERS
  203.     rule_action[$rule_number] = &Parser::NullAction;
  204. #endif
  205. ./
  206.  
  207. --
  208. -- This macro is used to initialize the rule_action array
  209. -- to the NoAction function.
  210. --
  211. $NoAction
  212. /.
  213. #ifndef HEADERS
  214.     rule_action[$rule_number] = &Parser::NoAction;
  215. #endif
  216. ./
  217.  
  218. --
  219. -- This macro generates a header for a named action function that is
  220. -- already defined and will be shared.
  221. --
  222. $shared_function
  223. /.
  224.  
  225. //
  226. // Rule $rule_number:  $rule_text./
  227.  
  228. --
  229. -- This macro generates a header for a rule that invokes the
  230. -- no_function routine.
  231. --
  232. $shared_NoAction
  233. /.
  234.  
  235. //
  236. // Rule $rule_number:  $rule_text
  237. //
  238. // void NoAction(void);
  239. //./
  240.  
  241. --
  242. -- This macro generates a header for a rule that invokes the
  243. -- null_function routine.
  244. --
  245. $shared_NullAction
  246. /.
  247.  
  248. //
  249. // Rule $rule_number:  $rule_text
  250. //
  251. // void NullAction(void);
  252. //./
  253.  
  254. $Terminals
  255.  
  256.     BodyMarker
  257.  
  258.     Identifier
  259.  
  260.     abstract boolean break byte case catch char class const
  261.     continue default do double else extends false final finally float
  262.     for goto if implements import instanceof int
  263.     interface long native new null package private
  264.     protected public return short static strictfp super switch
  265.     synchronized this throw throws transient true try void
  266.     volatile while
  267.  
  268.     IntegerLiteral
  269.     LongLiteral
  270.     FloatingPointLiteral
  271.     DoubleLiteral
  272.     CharacterLiteral
  273.     StringLiteral
  274.  
  275.     PLUS_PLUS
  276.     MINUS_MINUS
  277.     EQUAL_EQUAL
  278.     LESS_EQUAL
  279.     GREATER_EQUAL
  280.     NOT_EQUAL
  281.     LEFT_SHIFT
  282.     RIGHT_SHIFT
  283.     UNSIGNED_RIGHT_SHIFT
  284.     PLUS_EQUAL
  285.     MINUS_EQUAL
  286.     MULTIPLY_EQUAL
  287.     DIVIDE_EQUAL
  288.     AND_EQUAL
  289.     OR_EQUAL
  290.     XOR_EQUAL
  291.     REMAINDER_EQUAL
  292.     LEFT_SHIFT_EQUAL
  293.     RIGHT_SHIFT_EQUAL
  294.     UNSIGNED_RIGHT_SHIFT_EQUAL
  295.     OR_OR
  296.     AND_AND
  297.     PLUS
  298.     MINUS
  299.     NOT
  300.     REMAINDER
  301.     XOR
  302.     AND
  303.     MULTIPLY
  304.     OR
  305.     TWIDDLE
  306.     DIVIDE
  307.     GREATER
  308.     LESS
  309.     LPAREN
  310.     RPAREN
  311.     LBRACE
  312.     RBRACE
  313.     LBRACKET
  314.     RBRACKET
  315.     SEMICOLON
  316.     QUESTION
  317.     COLON
  318.     COMMA
  319.     DOT
  320.     EQUAL
  321.  
  322.     ERROR
  323.     EOF
  324.     EOL
  325.  
  326. $Alias
  327.  
  328.     '++'   ::= PLUS_PLUS
  329.     '--'   ::= MINUS_MINUS
  330.     '=='   ::= EQUAL_EQUAL
  331.     '<='   ::= LESS_EQUAL
  332.     '>='   ::= GREATER_EQUAL
  333.     '!='   ::= NOT_EQUAL
  334.     '<<'   ::= LEFT_SHIFT
  335.     '>>'   ::= RIGHT_SHIFT
  336.     '>>>'  ::= UNSIGNED_RIGHT_SHIFT
  337.     '+='   ::= PLUS_EQUAL
  338.     '-='   ::= MINUS_EQUAL
  339.     '*='   ::= MULTIPLY_EQUAL
  340.     '/='   ::= DIVIDE_EQUAL
  341.     '&='   ::= AND_EQUAL
  342.     '|='   ::= OR_EQUAL
  343.     '^='   ::= XOR_EQUAL
  344.     '%='   ::= REMAINDER_EQUAL
  345.     '<<='  ::= LEFT_SHIFT_EQUAL
  346.     '>>='  ::= RIGHT_SHIFT_EQUAL
  347.     '>>>=' ::= UNSIGNED_RIGHT_SHIFT_EQUAL
  348.     '||'   ::= OR_OR
  349.     '&&'   ::= AND_AND
  350.  
  351.     '+'    ::= PLUS
  352.     '-'    ::= MINUS
  353.     '!'    ::= NOT
  354.     '%'    ::= REMAINDER
  355.     '^'    ::= XOR
  356.     '&'    ::= AND
  357.     '*'    ::= MULTIPLY
  358.     '|'    ::= OR
  359.     '~'    ::= TWIDDLE
  360.     '/'    ::= DIVIDE
  361.     '>'    ::= GREATER
  362.     '<'    ::= LESS
  363.     '('    ::= LPAREN
  364.     ')'    ::= RPAREN
  365.     '{'    ::= LBRACE
  366.     '}'    ::= RBRACE
  367.     '['    ::= LBRACKET
  368.     ']'    ::= RBRACKET
  369.     ';'    ::= SEMICOLON
  370.     '?'    ::= QUESTION
  371.     ':'    ::= COLON
  372.     ','    ::= COMMA
  373.     '.'    ::= DOT
  374.     '='    ::= EQUAL
  375.  
  376.     $EOF   ::= EOF
  377.     $ERROR ::= ERROR
  378.  
  379.     $EOL   ::= ;
  380.  
  381. $Start
  382.  
  383.     Goal
  384.  
  385. $Rules
  386.  
  387. \:
  388. //
  389. // This software is subject to the terms of the IBM Jikes Compiler Open
  390. // Source License Agreement available at the following URL:
  391. // http://www.ibm.com/research/jikes.
  392. // Copyright (C) 1996, 1998, International Business Machines Corporation
  393. // and others.  All Rights Reserved.
  394. // You must accept the terms of that agreement to use this software.
  395. //
  396.  
  397. #ifndef HEADERS
  398.  
  399. #ifdef    HAVE_NAMESPACE
  400. namespace Jikes {    // Open namespace Jikes block
  401. #endif
  402.  
  403. void Parser::InitRuleAction()
  404. {
  405.     rule_action[0] = &Parser::BadAction;
  406. #else
  407.     void BadAction(void);
  408.     void NoAction(void);
  409.     void NullAction(void);
  410.     void MakeArrayType(void);
  411.     void MakeSimpleName(void);
  412.     void MakeFieldAccess(void);
  413.     void MakeQualifiedSuper(void);
  414.     void MakeQualifiedNew(void);
  415.     void SetSym1ToSym2(void);
  416.     void MakeEmptyStatement(void);
  417.     void MakeLabeledStatement(void);
  418.     void MakeExpressionStatement(void);
  419.     void MakeIfThenElseStatement(void);
  420.     void MakeWhileStatement(void);
  421.     void MakeForStatement(void);
  422.     void MakeArrayCreationExpression(void);
  423.     void MakeSuperFieldAccess(void);
  424.     void MakeSuperDoubleFieldAccess(void);
  425.     void MakeArrayAccess(void);
  426.     void MakeCastExpression(void);
  427. #endif
  428.  
  429. :\
  430.  
  431. /.#line $next_line "$input_file"
  432. //
  433. // This software is subject to the terms of the IBM Jikes Compiler Open
  434. // Source License Agreement available at the following URL:
  435. // http://www.ibm.com/research/jikes.
  436. // Copyright (C) 1996, 1998, International Business Machines Corporation
  437. // and others.  All Rights Reserved.
  438. // You must accept the terms of that agreement to use this software.
  439. //
  440.  
  441. #include "platform.h"
  442. #include "parser.h"
  443. #include "ast.h"
  444.  
  445. #undef HEADERS
  446. #include "javaact.h"
  447.  
  448. #ifdef    HAVE_NAMESPACE
  449. using namespace Jikes;
  450. #endif
  451.  
  452. #ifdef    HAVE_NAMESPACE
  453. using namespace Jikes;
  454. #endif
  455.  
  456. //****************************************************************************//
  457. //****************************************************************************//
  458. //*                                                                          *//
  459. //* Below, we show each rule of the Java grammar together with the semantic  *//
  460. //* action that is invoked when the parser performs a reduction by that rule.*//
  461. //*                                                                          *//
  462. //****************************************************************************//
  463. //****************************************************************************//
  464.  
  465. ./
  466.  
  467. --18.2 Productions from 2.3: The syntactic Grammar
  468.  
  469. Goal -> CompilationUnit
  470. \:$NoAction:\
  471. /.$location
  472. //
  473. // Given a rule of the form A ::= x1 x2 ... xn        n >= 1
  474. //
  475. // Do nothing - Whatever Ast was produced for x1 is inherited by A.
  476. //
  477. void Parser::BadAction(void) { assert(false); }
  478. void Parser::NoAction(void) {}
  479. ./
  480.  
  481. Goal ::= BodyMarker ConstructorBody
  482. \:$action:\
  483. /.$location
  484. //
  485. // This rule was added to allow the parser to recognize the body of a
  486. // funtion (constructor or method, as the definition of the body of a
  487. // method is subsumed by the definition of the body of a constructor)
  488. // out of context. Note that the artificial terminal BodyMarker is
  489. // added here to prevent an ordinary parse from accepting a body as
  490. // a valid input - i.e., to recognize a body out-of-context, the
  491. // BodyMarker terminal must be inserted in front of the input stream
  492. // containing the body in question.
  493. //
  494. void Parser::Act$rule_number(void)
  495. {
  496.     Sym(1) = Sym(2);
  497. }
  498. ./
  499.  
  500.  
  501. --18.3 Productions from 3: Lexical Structure
  502. --
  503. -- Expand the definition IntegerLiteral and BooleanLiteral
  504. --
  505.  
  506. Literal ::= IntegerLiteral
  507. \:$action:\
  508. /.$location
  509. void Parser::Act$rule_number(void)
  510. {
  511.     Sym(1) = ast_pool -> NewIntegerLiteral(Token(1));
  512. }
  513. ./
  514.  
  515. Literal ::= LongLiteral
  516. \:$action:\
  517. /.$location
  518. void Parser::Act$rule_number(void)
  519. {
  520.     Sym(1) = ast_pool -> NewLongLiteral(Token(1));
  521. }
  522. ./
  523.  
  524. Literal ::= FloatingPointLiteral
  525. \:$action:\
  526. /.$location
  527. void Parser::Act$rule_number(void)
  528. {
  529.     Sym(1) = ast_pool -> NewFloatingPointLiteral(Token(1));
  530. }
  531. ./
  532.  
  533. Literal ::= DoubleLiteral
  534. \:$action:\
  535. /.$location
  536. void Parser::Act$rule_number(void)
  537. {
  538.     Sym(1) = ast_pool -> NewDoubleLiteral(Token(1));
  539. }
  540. ./
  541.  
  542. Literal -> BooleanLiteral
  543. \:$NoAction:\
  544. /.$shared_NoAction./
  545.  
  546. Literal ::= CharacterLiteral
  547. \:$action:\
  548. /.$location
  549. void Parser::Act$rule_number(void)
  550. {
  551.     Sym(1) = ast_pool -> NewCharacterLiteral(Token(1));
  552. }
  553. ./
  554.  
  555. Literal ::= StringLiteral
  556. \:$action:\
  557. /.$location
  558. void Parser::Act$rule_number(void)
  559. {
  560.     Sym(1) = ast_pool -> NewStringLiteral(Token(1));
  561. }
  562. ./
  563.  
  564. Literal ::= null
  565. \:$action:\
  566. /.$location
  567. void Parser::Act$rule_number(void)
  568. {
  569.     Sym(1) = ast_pool -> NewNullLiteral(Token(1));
  570. }
  571. ./
  572.  
  573. BooleanLiteral ::= true
  574. \:$action:\
  575. /.$location
  576. void Parser::Act$rule_number(void)
  577. {
  578.     Sym(1) = ast_pool -> NewTrueLiteral(Token(1));
  579. }
  580. ./
  581.  
  582. BooleanLiteral ::= false
  583. \:$action:\
  584. /.$location
  585. void Parser::Act$rule_number(void)
  586. {
  587.     Sym(1) = ast_pool -> NewFalseLiteral(Token(1));
  588. }
  589. ./
  590.  
  591. --18.4 Productions from 4: Types, Values and Variables
  592.  
  593. Type -> PrimitiveType
  594. \:$NoAction:\
  595. /.$shared_NoAction./
  596.  
  597. Type -> ReferenceType
  598. \:$NoAction:\
  599. /.$shared_NoAction./
  600.  
  601. PrimitiveType -> NumericType
  602. \:$NoAction:\
  603. /.$shared_NoAction./
  604.  
  605. PrimitiveType ::= 'boolean'
  606. \:$action:\
  607. /.$location
  608. void Parser::Act$rule_number(void)
  609. {
  610.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::BOOLEAN, Token(1));
  611. }
  612. ./
  613.  
  614. NumericType -> IntegralType
  615. \:$NoAction:\
  616. /.$shared_NoAction./
  617.  
  618. NumericType -> FloatingPointType
  619. \:$NoAction:\
  620. /.$shared_NoAction./
  621.  
  622. IntegralType ::= 'byte'
  623. \:$action:\
  624. /.$location
  625. void Parser::Act$rule_number(void)
  626. {
  627.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::BYTE, Token(1));
  628. }
  629. ./
  630.  
  631. IntegralType ::= 'short'
  632. \:$action:\
  633. /.$location
  634. void Parser::Act$rule_number(void)
  635. {
  636.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::SHORT, Token(1));
  637. }
  638. ./
  639.  
  640. IntegralType ::= 'int'
  641. \:$action:\
  642. /.$location
  643. void Parser::Act$rule_number(void)
  644. {
  645.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::INT, Token(1));
  646. }
  647. ./
  648.  
  649. IntegralType ::= 'long'
  650. \:$action:\
  651. /.$location
  652. void Parser::Act$rule_number(void)
  653. {
  654.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::LONG, Token(1));
  655. }
  656. ./
  657.  
  658. IntegralType ::= 'char'
  659. \:$action:\
  660. /.$location
  661. void Parser::Act$rule_number(void)
  662. {
  663.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::CHAR, Token(1));
  664. }
  665. ./
  666.  
  667. FloatingPointType ::= 'float'
  668. \:$action:\
  669. /.$location
  670. void Parser::Act$rule_number(void)
  671. {
  672.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::FLOAT, Token(1));
  673. }
  674. ./
  675.  
  676. FloatingPointType ::= 'double'
  677. \:$action:\
  678. /.$location
  679. void Parser::Act$rule_number(void)
  680. {
  681.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::DOUBLE, Token(1));
  682. }
  683. ./
  684.  
  685. ReferenceType -> ClassOrInterfaceType
  686. \:$NoAction:\
  687. /.$shared_NoAction./
  688.  
  689. ReferenceType -> ArrayType
  690. \:$NoAction:\
  691. /.$shared_NoAction./
  692.  
  693. ClassOrInterfaceType -> Name
  694. \:$NoAction:\
  695. /.$shared_NoAction./
  696.  
  697. --
  698. -- These rules have been rewritten to avoid some conflicts introduced
  699. -- by adding the 1.1 features
  700. --
  701. -- ArrayType ::= PrimitiveType '[' ']'
  702. -- ArrayType ::= Name '[' ']'
  703. -- ArrayType ::= ArrayType '[' ']'
  704. --
  705. ArrayType ::= PrimitiveType Dims
  706. \:$MakeArrayType:\
  707. /.$location
  708. void Parser::MakeArrayType(void)
  709. {
  710.     AstArrayType *p = ast_pool -> NewArrayType();
  711.     p -> type     = Sym(1);
  712.     //
  713.     // The list of modifiers is guaranteed not empty
  714.     //
  715.     {
  716.         AstListNode *tail = (AstListNode *) Sym(2);
  717.         p -> AllocateBrackets(tail -> index + 1);
  718.         AstListNode *root = tail;
  719.         do
  720.         {
  721.             root = root -> next;
  722.             p -> AddBrackets((AstBrackets *) root -> element);
  723.         } while(root != tail);
  724.         FreeCircularList(tail);
  725.     }
  726.     Sym(1) = p;
  727. }
  728. ./
  729.  
  730. ArrayType ::= Name Dims
  731. \:$MakeArrayType:\
  732. /.$shared_function
  733. //
  734. // void MakeArrayType(void);
  735. //./
  736.  
  737. ClassType -> ClassOrInterfaceType
  738. \:$NoAction:\
  739. /.$shared_NoAction./
  740.  
  741. InterfaceType -> ClassOrInterfaceType
  742. \:$NoAction:\
  743. /.$shared_NoAction./
  744.  
  745. --18.5 Productions from 6: Names
  746.  
  747. Name -> SimpleName
  748. \:$NoAction:\
  749. /.$shared_NoAction./
  750.  
  751. Name -> QualifiedName
  752. \:$NoAction:\
  753. /.$shared_NoAction./
  754.  
  755. SimpleName ::= 'Identifier'
  756. \:$MakeSimpleName:\
  757. /.$location
  758. void Parser::MakeSimpleName(void)
  759. {
  760.     Sym(1) = ast_pool -> NewSimpleName(Token(1));
  761. }
  762. ./
  763.  
  764. QualifiedName ::= Name '.' 'Identifier'
  765. \:$MakeFieldAccess:\
  766. /.$location
  767. void Parser::MakeFieldAccess(void)
  768. {
  769.     AstFieldAccess *p = ast_pool -> NewFieldAccess();
  770.     p -> base = (AstExpression *) Sym(1);
  771.     p -> dot_token = Token(2);
  772.     p -> identifier_token = Token(3);
  773.     Sym(1) = p;
  774. }
  775. ./
  776.  
  777. --18.6 Productions from 7: Packages
  778.  
  779. CompilationUnit ::= PackageDeclarationopt ImportDeclarationsopt TypeDeclarationsopt
  780. \:$action:\
  781. /.$location
  782. void Parser::Act$rule_number(void)
  783. {
  784.     AstCompilationUnit *p = ast_pool -> NewCompilationUnit();
  785.     p -> package_declaration_opt = (AstPackageDeclaration *) Sym(1);
  786.     if (Sym(2) != NULL)
  787.     {
  788.         AstListNode *tail = (AstListNode *) Sym(2);
  789.         p -> AllocateImportDeclarations(tail -> index + 1);
  790.         AstListNode *root = tail;
  791.         do
  792.         {
  793.             root = root -> next;
  794.             p -> AddImportDeclaration((AstImportDeclaration *) root -> element);
  795.         } while(root != tail);
  796.         FreeCircularList(tail);
  797.     }
  798.     if (Sym(3) != NULL)
  799.     {
  800.         AstListNode *tail = (AstListNode *) Sym(3);
  801.         p -> AllocateTypeDeclarations(tail -> index + 1);
  802.         AstListNode *root = tail;
  803.         do
  804.         {
  805.             root = root -> next;
  806.             p -> AddTypeDeclaration(root -> element);
  807.         } while(root != tail);
  808.         FreeCircularList(tail);
  809.     }
  810.     Sym(1) = p;
  811. }
  812. ./
  813.  
  814. ImportDeclarations ::= ImportDeclaration
  815. \:$action:\
  816. /.$location
  817. //
  818. // Note that the list is circular so as to preserve the order of the elements
  819. //
  820. void Parser::Act$rule_number(void)
  821. {
  822.     AstListNode *p = AllocateListNode();
  823.     p -> next = p;
  824.     p -> element = Sym(1);
  825.     p -> index = 0;
  826.  
  827.     Sym(1) = p;
  828. }
  829. ./
  830.  
  831. ImportDeclarations ::= ImportDeclarations ImportDeclaration
  832. \:$action:\
  833. /.$location
  834. //
  835. // Note that the list is circular so as to preserve the order of the elements
  836. //
  837. void Parser::Act$rule_number(void)
  838. {
  839.     AstListNode *tail = (AstListNode *) Sym(1);
  840.  
  841.     AstListNode *p = AllocateListNode();
  842.     p -> element = Sym(2);
  843.     p -> index = tail -> index + 1;
  844.  
  845.     p -> next = tail -> next;
  846.     tail -> next = p;
  847.  
  848.     Sym(1) = p;
  849. }
  850. ./
  851.  
  852. TypeDeclarations ::= TypeDeclaration
  853. \:$action:\
  854. /.$location
  855. //
  856. // Note that the list is circular so as to preserve the order of the elements
  857. //
  858. void Parser::Act$rule_number(void)
  859. {
  860.     AstListNode *p = AllocateListNode();
  861.     p -> next = p;
  862.     p -> element = Sym(1);
  863.     p -> index = 0;
  864.  
  865.     Sym(1) = p;
  866. }
  867. ./
  868.  
  869. TypeDeclarations ::= TypeDeclarations TypeDeclaration
  870. \:$action:\
  871. /.$location
  872. //
  873. // Note that the list is circular so as to preserve the order of the elements
  874. //
  875. void Parser::Act$rule_number(void)
  876. {
  877.     AstListNode *tail = (AstListNode *) Sym(1);
  878.  
  879.     AstListNode *p = AllocateListNode();
  880.     p -> element = Sym(2);
  881.     p -> index = tail -> index + 1;
  882.  
  883.     p -> next = tail -> next;
  884.     tail -> next = p;
  885.  
  886.     Sym(1) = p;
  887. }
  888. ./
  889.  
  890. PackageDeclaration ::= 'package' Name PackageHeaderMarker ';'
  891. \:$action:\
  892. /.$location
  893. void Parser::Act$rule_number(void)
  894. {
  895.     AstPackageDeclaration *p = ast_pool -> NewPackageDeclaration();
  896.     p -> package_token   = Token(1);
  897.     p -> name            = (AstExpression *) Sym(2);
  898.     p -> semicolon_token = Token(3);
  899.     Sym(1) = p;
  900. }
  901. ./
  902.  
  903. ImportDeclaration -> SingleTypeImportDeclaration
  904. \:$NoAction:\
  905. /.$shared_NoAction./
  906.  
  907. ImportDeclaration -> TypeImportOnDemandDeclaration
  908. \:$NoAction:\
  909. /.$shared_NoAction./
  910.  
  911. SingleTypeImportDeclaration ::= 'import' Name ';'
  912. \:$action:\
  913. /.$location
  914. void Parser::Act$rule_number(void)
  915. {
  916.     AstImportDeclaration *p = ast_pool -> NewImportDeclaration();
  917.     p -> import_token    = Token(1);
  918.     p -> name            = (AstExpression *) Sym(2);
  919.     p -> star_token_opt  = 0;
  920.     p -> semicolon_token = Token(3);
  921.     Sym(1) = p;
  922. }
  923. ./
  924.  
  925. TypeImportOnDemandDeclaration ::= 'import' Name '.' '*' ';'
  926. \:$action:\
  927. /.$location
  928. void Parser::Act$rule_number(void)
  929. {
  930.     AstImportDeclaration *p = ast_pool -> NewImportDeclaration();
  931.     p -> import_token         = Token(1);
  932.     p -> name                 = (AstExpression *) Sym(2);
  933.     p -> star_token_opt       = Token(4);
  934.     p -> semicolon_token      = Token(5);
  935.     Sym(1) = p;
  936. }
  937. ./
  938.  
  939. TypeDeclaration -> ClassDeclaration
  940. \:$NoAction:\
  941. /.$shared_NoAction./
  942.  
  943. TypeDeclaration -> InterfaceDeclaration
  944. \:$NoAction:\
  945. /.$shared_NoAction./
  946.  
  947. TypeDeclaration ::= ';'
  948. \:$action:\
  949. /.$location
  950. void Parser::Act$rule_number(void)
  951. {
  952.     Sym(1) = ast_pool -> NewEmptyDeclaration(Token(1));
  953. }
  954. ./
  955.  
  956. --18.7 Only in the LALR(1) Grammar
  957.  
  958. Modifiers ::= Modifier
  959. \:$action:\
  960. /.$location
  961. //
  962. // Note that the list is circular so as to preserve the order of the elements
  963. //
  964. void Parser::Act$rule_number(void)
  965. {
  966.     AstListNode *p = AllocateListNode();
  967.     p -> next = p;
  968.     p -> element = Sym(1);
  969.     p -> index = 0;
  970.  
  971.     Sym(1) = p;
  972. }
  973. ./
  974.  
  975. Modifiers ::= Modifiers Modifier
  976. \:$action:\
  977. /.$location
  978. //
  979. // Note that the list is circular so as to preserve the order of the elements
  980. //
  981. void Parser::Act$rule_number(void)
  982. {
  983.     AstListNode *tail = (AstListNode *) Sym(1);
  984.  
  985.     AstListNode *p = AllocateListNode();
  986.     p -> element = Sym(2);
  987.     p -> index = tail -> index + 1;
  988.  
  989.     p -> next = tail -> next;
  990.     tail -> next = p;
  991.  
  992.     Sym(1) = p;
  993. }
  994. ./
  995.  
  996. Modifier ::= 'public'
  997. \:$action:\
  998. /.$location
  999. void Parser::Act$rule_number(void)
  1000. {
  1001.     Sym(1) = ast_pool -> NewModifier(Ast::PUBLIC, Token(1));
  1002. }
  1003. ./
  1004.  
  1005. Modifier ::= 'protected'
  1006. \:$action:\
  1007. /.$location
  1008. void Parser::Act$rule_number(void)
  1009. {
  1010.     Sym(1) = ast_pool -> NewModifier(Ast::PROTECTED, Token(1));
  1011. }
  1012. ./
  1013.  
  1014. Modifier ::= 'private'
  1015. \:$action:\
  1016. /.$location
  1017. void Parser::Act$rule_number(void)
  1018. {
  1019.     Sym(1) = ast_pool -> NewModifier(Ast::PRIVATE, Token(1));
  1020. }
  1021. ./
  1022.  
  1023. Modifier ::= 'static'
  1024. \:$action:\
  1025. /.$location
  1026. void Parser::Act$rule_number(void)
  1027. {
  1028.     Sym(1) = ast_pool -> NewModifier(Ast::STATIC, Token(1));
  1029. }
  1030. ./
  1031.  
  1032. Modifier ::= 'abstract'
  1033. \:$action:\
  1034. /.$location
  1035. void Parser::Act$rule_number(void)
  1036. {
  1037.     Sym(1) = ast_pool -> NewModifier(Ast::ABSTRACT, Token(1));
  1038. }
  1039. ./
  1040.  
  1041. Modifier ::= 'final'
  1042. \:$action:\
  1043. /.$location
  1044. void Parser::Act$rule_number(void)
  1045. {
  1046.     Sym(1) = ast_pool -> NewModifier(Ast::FINAL, Token(1));
  1047. }
  1048. ./
  1049.  
  1050. Modifier ::= 'native'
  1051. \:$action:\
  1052. /.$location
  1053. void Parser::Act$rule_number(void)
  1054. {
  1055.     Sym(1) = ast_pool -> NewModifier(Ast::NATIVE, Token(1));
  1056. }
  1057. ./
  1058.  
  1059. Modifier ::= 'strictfp'
  1060. \:$action:\
  1061. /.$location
  1062. void Parser::Act$rule_number(void)
  1063. {
  1064.     Sym(1) = ast_pool -> NewModifier(Ast::STRICTFP, Token(1));
  1065. }
  1066. ./
  1067.  
  1068. Modifier ::= 'synchronized'
  1069. \:$action:\
  1070. /.$location
  1071. void Parser::Act$rule_number(void)
  1072. {
  1073.     Sym(1) = ast_pool -> NewModifier(Ast::SYNCHRONIZED, Token(1));
  1074. }
  1075. ./
  1076.  
  1077. Modifier ::= 'transient'
  1078. \:$action:\
  1079. /.$location
  1080. void Parser::Act$rule_number(void)
  1081. {
  1082.     Sym(1) = ast_pool -> NewModifier(Ast::TRANSIENT, Token(1));
  1083. }
  1084. ./
  1085.  
  1086. Modifier ::= 'volatile'
  1087. \:$action:\
  1088. /.$location
  1089. void Parser::Act$rule_number(void)
  1090. {
  1091.     Sym(1) = ast_pool -> NewModifier(Ast::VOLATILE, Token(1));
  1092. }
  1093. ./
  1094.  
  1095. --18.8 Productions from 8: Class Declarations
  1096. --ClassModifier ::=
  1097. --      'abstract'
  1098. --    | 'final'
  1099. --    | 'public'
  1100. --18.8.1 Productions from 8.1: Class Declarations
  1101.  
  1102. ClassDeclaration ::= Modifiersopt 'class' 'Identifier' Superopt Interfacesopt ClassBody
  1103. \:$action:\
  1104. /.$location
  1105. void Parser::Act$rule_number(void)
  1106. {
  1107.     AstClassDeclaration *p = ast_pool -> NewClassDeclaration();
  1108.     if (Sym(1) != NULL)
  1109.     {
  1110.         AstListNode *tail = (AstListNode *) Sym(1);
  1111.         p -> AllocateClassModifiers(tail -> index + 1);
  1112.         AstListNode *root = tail;
  1113.         do
  1114.         {
  1115.             root = root -> next;
  1116.             p -> AddClassModifier((AstModifier *) root -> element);
  1117.         } while(root != tail);
  1118.         FreeCircularList(tail);
  1119.     }
  1120.     p -> class_token          = Token(2);
  1121.     p -> identifier_token     = Token(3);
  1122.     p -> super_opt            = (AstExpression *) Sym(4);
  1123.     if (Sym(5) != NULL)
  1124.     {
  1125.         AstListNode *tail = (AstListNode *) Sym(5);
  1126.         p -> AllocateInterfaces(tail -> index + 1);
  1127.         AstListNode *root = tail;
  1128.         do
  1129.         {
  1130.             root = root -> next;
  1131.             p -> AddInterface((AstExpression *) root -> element);
  1132.         } while(root != tail);
  1133.         FreeCircularList(tail);
  1134.     }
  1135.     p -> class_body = (AstClassBody *) Sym(6);
  1136.     Sym(1) = p;
  1137. }
  1138. ./
  1139.  
  1140. Super ::= 'extends' ClassType
  1141. \:$SetSym1ToSym2:\
  1142. /.$location
  1143. void Parser::SetSym1ToSym2(void) { Sym(1) = Sym(2); }
  1144. ./
  1145.  
  1146. Interfaces ::= 'implements' InterfaceTypeList
  1147. \:$SetSym1ToSym2:\
  1148. /.$shared_function
  1149. //
  1150. // void SetSym1ToSym2(void);
  1151. //./
  1152.  
  1153. InterfaceTypeList ::= InterfaceType
  1154. \:$action:\
  1155. /.$location
  1156. //
  1157. // Note that the list is circular so as to preserve the order of the elements
  1158. //
  1159. void Parser::Act$rule_number(void)
  1160. {
  1161.     AstListNode *p = AllocateListNode();
  1162.     p -> next = p;
  1163.     p -> element = Sym(1);
  1164.     p -> index = 0;
  1165.  
  1166.     Sym(1) = p;
  1167. }
  1168. ./
  1169.  
  1170. InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType
  1171. \:$action:\
  1172. /.$location
  1173. //
  1174. // Note that the list is circular so as to preserve the order of the elements
  1175. //
  1176. void Parser::Act$rule_number(void)
  1177. {
  1178.     AstListNode *tail = (AstListNode *) Sym(1);
  1179.  
  1180.     AstListNode *p = AllocateListNode();
  1181.     p -> element = Sym(3);
  1182.     p -> index = tail -> index + 1;
  1183.  
  1184.     p -> next = tail -> next;
  1185.     tail -> next = p;
  1186.  
  1187.     Sym(1) = p;
  1188. }
  1189. ./
  1190.  
  1191. ClassBody ::= '{' ClassBodyDeclarationsopt '}'
  1192. \:$action:\
  1193. /.$location
  1194. void Parser::Act$rule_number(void)
  1195. {
  1196.     AstClassBody *p = ast_pool -> NewClassBody();
  1197.     if (parse_header_only)
  1198.         p -> mark_unparsed();
  1199.  
  1200.     p -> left_brace_token = Token(1);
  1201.     if (Sym(2) != NULL)
  1202.     {
  1203.         int num_instance_variables = 0,
  1204.             num_class_variables = 0,
  1205.             num_methods = 0,
  1206.             num_constructors = 0,
  1207.             num_static_initializers = 0,
  1208.             num_inner_classes = 0,
  1209.             num_inner_interfaces = 0,
  1210.             num_blocks = 0,
  1211.             num_empty_declarations = 0;
  1212.  
  1213.         AstListNode *tail = (AstListNode *) Sym(2);
  1214.         p -> AllocateClassBodyDeclarations(tail -> index + 1);
  1215.         AstListNode *root = tail;
  1216.         do
  1217.         {
  1218.             root = root -> next;
  1219.             p -> AddClassBodyDeclaration(root -> element);
  1220.  
  1221.             AstFieldDeclaration *field_declaration = root -> element -> FieldDeclarationCast();
  1222.             if (field_declaration)
  1223.             {
  1224.                 for (int i = 0; i < field_declaration -> NumVariableModifiers(); i++)
  1225.                 {
  1226.                     if (field_declaration -> VariableModifier(i) -> kind == Ast::STATIC)
  1227.                     {
  1228.                         field_declaration -> MarkStatic();
  1229.                         break;
  1230.                     }
  1231.                 }
  1232.                 if (field_declaration -> StaticFieldCast())
  1233.                      num_class_variables++;
  1234.                 else num_instance_variables++;
  1235.             }
  1236.             else if (root -> element -> MethodDeclarationCast())
  1237.             {
  1238.                 num_methods++;
  1239.             }
  1240.             else if (root -> element -> ConstructorDeclarationCast())
  1241.             {
  1242.                 num_constructors++;
  1243.             }
  1244.             else if (root -> element -> StaticInitializerCast())
  1245.             {
  1246.                 num_static_initializers++;
  1247.             }
  1248.             else if (root -> element -> ClassDeclarationCast())
  1249.             {
  1250.                 num_inner_classes++;
  1251.             }
  1252.             else if (root -> element -> InterfaceDeclarationCast())
  1253.             {
  1254.                 num_inner_interfaces++;
  1255.             }
  1256.             else if (root -> element -> BlockCast())
  1257.             {
  1258.                 num_blocks++;
  1259.             }
  1260.             else num_empty_declarations++;
  1261.         } while(root != tail);
  1262.  
  1263.         p -> AllocateInstanceVariables(num_instance_variables);
  1264.         p -> AllocateClassVariables(num_class_variables);
  1265.         p -> AllocateMethods(num_methods);
  1266.         p -> AllocateConstructors(num_constructors);
  1267.         p -> AllocateStaticInitializers(num_static_initializers);
  1268.         p -> AllocateNestedClasses(num_inner_classes);
  1269.         p -> AllocateNestedInterfaces(num_inner_interfaces);
  1270.         p -> AllocateBlocks(num_blocks);
  1271.         p -> AllocateEmptyDeclarations(num_empty_declarations);
  1272.  
  1273.         root = tail;
  1274.         do
  1275.         {
  1276.             root = root -> next;
  1277.  
  1278.             AstFieldDeclaration *field_declaration;
  1279.             AstMethodDeclaration *method_declaration;
  1280.             AstConstructorDeclaration *constructor_declaration;
  1281.             AstStaticInitializer *static_initializer;
  1282.             AstClassDeclaration *class_declaration;
  1283.             AstInterfaceDeclaration *interface_declaration;
  1284.             AstBlock *block;
  1285.  
  1286.             if ((field_declaration = root -> element -> FieldDeclarationCast()))
  1287.             {
  1288.                 if (field_declaration -> StaticFieldCast())
  1289.                      p -> AddClassVariable(field_declaration);
  1290.                 else p -> AddInstanceVariable(field_declaration);
  1291.             }
  1292.             else if ((method_declaration = root -> element -> MethodDeclarationCast()))
  1293.             {
  1294.                 p -> AddMethod(method_declaration);
  1295.             }
  1296.             else if ((constructor_declaration = root -> element -> ConstructorDeclarationCast()))
  1297.             {
  1298.                 p -> AddConstructor(constructor_declaration);
  1299.             }
  1300.             else if ((static_initializer = root -> element -> StaticInitializerCast()))
  1301.             {
  1302.                 p -> AddStaticInitializer(static_initializer);
  1303.             }
  1304.             else if ((class_declaration = root -> element -> ClassDeclarationCast()))
  1305.             {
  1306.                 p -> AddNestedClass(class_declaration);
  1307.             }
  1308.             else if ((interface_declaration = root -> element -> InterfaceDeclarationCast()))
  1309.             {
  1310.                 p -> AddNestedInterface(interface_declaration);
  1311.             }
  1312.             else if ((block = root -> element -> BlockCast()))
  1313.             {
  1314.                 p -> AddBlock(block);
  1315.             }
  1316.             else // assert(block = root -> element -> EmptyDeclarationCast())
  1317.             {
  1318.                 p -> AddEmptyDeclaration((AstEmptyDeclaration *) root -> element);
  1319.             }
  1320.         } while(root != tail);
  1321.         FreeCircularList(tail);
  1322.     }
  1323.     p -> right_brace_token = Token(3);
  1324.     p -> pool = body_pool; // from now on, this is the storage pool to use for this type
  1325.     Sym(1) = p;
  1326. }
  1327. ./
  1328.  
  1329. ClassBodyDeclarations ::= ClassBodyDeclaration
  1330. \:$action:\
  1331. /.$location
  1332. //
  1333. // Note that the list is circular so as to preserve the order of the elements
  1334. //
  1335. void Parser::Act$rule_number(void)
  1336. {
  1337.     AstListNode *p = AllocateListNode();
  1338.     p -> next = p;
  1339.     p -> element = Sym(1);
  1340.     p -> index = 0;
  1341.  
  1342.     Sym(1) = p;
  1343. }
  1344. ./
  1345.  
  1346. ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration
  1347. \:$action:\
  1348. /.$location
  1349. //
  1350. // Note that the list is circular so as to preserve the order of the elements
  1351. //
  1352. void Parser::Act$rule_number(void)
  1353. {
  1354.     AstListNode *tail = (AstListNode *) Sym(1);
  1355.  
  1356.     AstListNode *p = AllocateListNode();
  1357.     p -> element = Sym(2);
  1358.     p -> index = tail -> index + 1;
  1359.  
  1360.     p -> next = tail -> next;
  1361.     tail -> next = p;
  1362.  
  1363.     Sym(1) = p;
  1364. }
  1365. ./
  1366.  
  1367. ClassBodyDeclaration -> ClassMemberDeclaration
  1368. \:$NoAction:\
  1369. /.$shared_NoAction./
  1370.  
  1371. ClassBodyDeclaration -> StaticInitializer
  1372. \:$NoAction:\
  1373. /.$shared_NoAction./
  1374.  
  1375. ClassBodyDeclaration -> ConstructorDeclaration
  1376. \:$NoAction:\
  1377. /.$shared_NoAction./
  1378.  
  1379. --1.1 feature
  1380. ClassBodyDeclaration ::= MethodHeaderMarker Block
  1381. \:$action:\
  1382. /.$location
  1383. void Parser::Act$rule_number(void)
  1384. {
  1385.     Sym(1) = Sym(2);
  1386. }
  1387. ./
  1388.  
  1389. ClassMemberDeclaration -> FieldDeclaration
  1390. \:$NoAction:\
  1391. /.$shared_NoAction./
  1392.  
  1393. ClassMemberDeclaration -> MethodDeclaration
  1394. \:$NoAction:\
  1395. /.$shared_NoAction./
  1396.  
  1397. --1.1 feature
  1398. ClassMemberDeclaration -> ClassDeclaration
  1399. \:$NoAction:\
  1400. /.$shared_NoAction./
  1401.  
  1402. --1.1 feature
  1403. ClassMemberDeclaration -> InterfaceDeclaration
  1404. \:$NoAction:\
  1405. /.$shared_NoAction./
  1406.  
  1407. --
  1408. -- Empty declarations are not valid Java ClassMemberDeclarations.
  1409. -- However, since the current (2/14/97) Java compiler accepts them
  1410. -- (in fact, some of the official tests contain this erroneous
  1411. -- syntax), we decided to accept them as valid syntax and flag them
  1412. -- as a warning during semantic processing.
  1413. --
  1414. ClassMemberDeclaration ::= ';'
  1415. \:$action:\
  1416. /.$location
  1417. void Parser::Act$rule_number(void)
  1418. {
  1419.     Sym(1) = ast_pool -> NewEmptyDeclaration(Token(1));
  1420. }
  1421. ./
  1422.  
  1423. --18.8.2 Productions from 8.3: Field Declarations
  1424. --VariableModifier ::=
  1425. --      'public'
  1426. --    | 'protected'
  1427. --    | 'private'
  1428. --    | 'static'
  1429. --    | 'final'
  1430. --    | 'transient'
  1431. --    | 'volatile'
  1432.  
  1433. FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';'
  1434. \:$action:\
  1435. /.$location
  1436. void Parser::Act$rule_number(void)
  1437. {
  1438.     AstFieldDeclaration *p = ast_pool -> NewFieldDeclaration();
  1439.     if (Sym(1) != NULL)
  1440.     {
  1441.         AstListNode *tail = (AstListNode *) Sym(1);
  1442.         p -> AllocateVariableModifiers(tail -> index + 1);
  1443.         AstListNode *root = tail;
  1444.         do
  1445.         {
  1446.             root = root -> next;
  1447.             p -> AddVariableModifier((AstModifier *) root -> element);
  1448.         } while(root != tail);
  1449.         FreeCircularList(tail);
  1450.     }
  1451.     p -> type = Sym(2);
  1452.     //
  1453.     // The list of declarators is guaranteed not empty
  1454.     //
  1455.     {
  1456.         AstListNode *tail = (AstListNode *) Sym(3);
  1457.         p -> AllocateVariableDeclarators(tail -> index + 1);
  1458.         AstListNode *root = tail;
  1459.         do
  1460.         {
  1461.             root = root -> next;
  1462.             p -> AddVariableDeclarator((AstVariableDeclarator *) root -> element);
  1463.         } while(root != tail);
  1464.         FreeCircularList(tail);
  1465.     }
  1466.     p -> semicolon_token      = Token(4);
  1467.     Sym(1) = p;
  1468. }
  1469. ./
  1470.  
  1471. VariableDeclarators ::= VariableDeclarator
  1472. \:$action:\
  1473. /.$location
  1474. //
  1475. // Note that the list is circular so as to preserve the order of the elements
  1476. //
  1477. void Parser::Act$rule_number(void)
  1478. {
  1479.     AstListNode *p = AllocateListNode();
  1480.     p -> next = p;
  1481.     p -> element = Sym(1);
  1482.     p -> index = 0;
  1483.  
  1484.     Sym(1) = p;
  1485. }
  1486. ./
  1487.  
  1488. VariableDeclarators ::= VariableDeclarators ',' VariableDeclarator
  1489. \:$action:\
  1490. /.$location
  1491. //
  1492. // Note that the list is circular so as to preserve the order of the elements
  1493. //
  1494. void Parser::Act$rule_number(void)
  1495. {
  1496.     AstListNode *tail = (AstListNode *) Sym(1);
  1497.  
  1498.     AstListNode *p = AllocateListNode();
  1499.     p -> element = Sym(3);
  1500.     p -> index = tail -> index + 1;
  1501.  
  1502.     p -> next = tail -> next;
  1503.     tail -> next = p;
  1504.  
  1505.     Sym(1) = p;
  1506. }
  1507. ./
  1508.  
  1509. VariableDeclarator ::= VariableDeclaratorId
  1510. \:$action:\
  1511. /.$location
  1512. void Parser::Act$rule_number(void)
  1513. {
  1514.     AstVariableDeclarator *p = ast_pool -> NewVariableDeclarator();
  1515.     p -> variable_declarator_name = (AstVariableDeclaratorId *) Sym(1);
  1516.     p -> variable_initializer_opt = NULL;
  1517.     Sym(1) = p;
  1518. }
  1519. ./
  1520.  
  1521. VariableDeclarator ::= VariableDeclaratorId '=' VariableInitializer
  1522. \:$action:\
  1523. /.$location
  1524. void Parser::Act$rule_number(void)
  1525. {
  1526.     AstVariableDeclarator *p = ast_pool -> NewVariableDeclarator();
  1527.     p -> variable_declarator_name = (AstVariableDeclaratorId *) Sym(1);
  1528.     p -> variable_initializer_opt = Sym(3);
  1529.     Sym(1) = p;
  1530. }
  1531. ./
  1532.  
  1533. VariableDeclaratorId ::= 'Identifier' Dimsopt
  1534. \:$action:\
  1535. /.$location
  1536. void Parser::Act$rule_number(void)
  1537. {
  1538.     AstVariableDeclaratorId *p = ast_pool -> NewVariableDeclaratorId();
  1539.     p -> identifier_token = Token(1);
  1540.     if (Sym(2) != NULL)
  1541.     {
  1542.         AstListNode *tail = (AstListNode *) Sym(2);
  1543.         p -> AllocateBrackets(tail -> index + 1);
  1544.         AstListNode *root = tail;
  1545.         do
  1546.         {
  1547.             root = root -> next;
  1548.             p -> AddBrackets((AstBrackets *) root -> element);
  1549.         } while(root != tail);
  1550.         FreeCircularList(tail);
  1551.     }
  1552.     Sym(1) = p;
  1553. }
  1554. ./
  1555.  
  1556. VariableInitializer -> Expression
  1557. \:$NoAction:\
  1558. /.$shared_NoAction./
  1559.  
  1560. VariableInitializer -> ArrayInitializer
  1561. \:$NoAction:\
  1562. /.$shared_NoAction./
  1563.  
  1564. --18.8.3 Productions from 8.4: Method Declarations
  1565. --MethodModifier ::=
  1566. --      'public'
  1567. --    | 'protected'
  1568. --    | 'private'
  1569. --    | 'static'
  1570. --    | 'abstract'
  1571. --    | 'final'
  1572. --    | 'native'
  1573. --    | 'synchronized'
  1574. --
  1575. -- The original rule does not contain the "MethodHeaderMarker.
  1576. -- See explanation above.
  1577. --
  1578. -- MethodDeclaration ::= MethodHeader MethodBody
  1579. --
  1580.  
  1581. MethodDeclaration ::= MethodHeader MethodHeaderMarker MethodBody
  1582. \:$action:\
  1583. /.$location
  1584. void Parser::Act$rule_number(void)
  1585. {
  1586.     ((AstMethodDeclaration *) Sym(1)) -> method_body = (AstStatement *) Sym(3);
  1587. }
  1588. ./
  1589.  
  1590. MethodHeader ::= Modifiersopt Type MethodDeclarator Throwsopt
  1591. \:$action:\
  1592. /.$location
  1593. void Parser::Act$rule_number(void)
  1594. {
  1595.     AstMethodDeclaration *p = ast_pool -> NewMethodDeclaration();
  1596.     if (Sym(1) != NULL)
  1597.     {
  1598.         AstListNode *tail = (AstListNode *) Sym(1);
  1599.         p -> AllocateMethodModifiers(tail -> index + 1);
  1600.         AstListNode *root = tail;
  1601.         do
  1602.         {
  1603.             root = root -> next;
  1604.             p -> AddMethodModifier((AstModifier *) root -> element);
  1605.         } while(root != tail);
  1606.         FreeCircularList(tail);
  1607.     }
  1608.     p -> type              = Sym(2);
  1609.     p -> method_declarator = (AstMethodDeclarator *) Sym(3);
  1610.     if (Sym(4) != NULL)
  1611.     {
  1612.         AstListNode *tail = (AstListNode *) Sym(4);
  1613.         p -> AllocateThrows(tail -> index + 1);
  1614.         AstListNode *root = tail;
  1615.         do
  1616.         {
  1617.             root = root -> next;
  1618.             p -> AddThrow((AstExpression *) root -> element);
  1619.         } while(root != tail);
  1620.         FreeCircularList(tail);
  1621.     }
  1622.     Sym(1) = p;
  1623. }
  1624. ./
  1625.  
  1626. MethodHeader ::= Modifiersopt 'void' MethodDeclarator Throwsopt
  1627. \:$action:\
  1628. /.$location
  1629. void Parser::Act$rule_number(void)
  1630. {
  1631.     AstMethodDeclaration *p = ast_pool -> NewMethodDeclaration();
  1632.     if (Sym(1) != NULL)
  1633.     {
  1634.         AstListNode *tail = (AstListNode *) Sym(1);
  1635.         p -> AllocateMethodModifiers(tail -> index + 1);
  1636.         AstListNode *root = tail;
  1637.         do
  1638.         {
  1639.             root = root -> next;
  1640.             p -> AddMethodModifier((AstModifier *) root -> element);
  1641.         } while(root != tail);
  1642.         FreeCircularList(tail);
  1643.     }
  1644.     p -> type              = ast_pool -> NewPrimitiveType(Ast::VOID_TYPE, Token(2));
  1645.     p -> method_declarator = (AstMethodDeclarator *) Sym(3);
  1646.     if (Sym(4) != NULL)
  1647.     {
  1648.         AstListNode *tail = (AstListNode *) Sym(4);
  1649.         p -> AllocateThrows(tail -> index + 1);
  1650.         AstListNode *root = tail;
  1651.         do
  1652.         {
  1653.             root = root -> next;
  1654.             p -> AddThrow((AstExpression *) root -> element);
  1655.         } while(root != tail);
  1656.         FreeCircularList(tail);
  1657.     }
  1658.     Sym(1) = p;
  1659. }
  1660. ./
  1661.  
  1662. MethodDeclarator ::= 'Identifier' '(' FormalParameterListopt ')' Dimsopt
  1663. \:$action:\
  1664. /.$location
  1665. void Parser::Act$rule_number(void)
  1666. {
  1667.     AstMethodDeclarator *p = ast_pool -> NewMethodDeclarator();
  1668.     p -> identifier_token        = Token(1);
  1669.     p -> left_parenthesis_token  = Token(2);
  1670.     if (Sym(3) != NULL)
  1671.     {
  1672.         AstListNode *tail = (AstListNode *) Sym(3);
  1673.         p -> AllocateFormalParameters(tail -> index + 1);
  1674.         AstListNode *root = tail;
  1675.         do
  1676.         {
  1677.             root = root -> next;
  1678.             p -> AddFormalParameter((AstFormalParameter *) root -> element);
  1679.         } while(root != tail);
  1680.         FreeCircularList(tail);
  1681.     }
  1682.     p -> right_parenthesis_token = Token(4);
  1683.     if (Sym(5) != NULL)
  1684.     {
  1685.         AstListNode *tail = (AstListNode *) Sym(5);
  1686.         p -> AllocateBrackets(tail -> index + 1);
  1687.         AstListNode *root = tail;
  1688.         do
  1689.         {
  1690.             root = root -> next;
  1691.             p -> AddBrackets((AstBrackets *) root -> element);
  1692.         } while(root != tail);
  1693.         FreeCircularList(tail);
  1694.     }
  1695.     Sym(1) = p;
  1696. }
  1697. ./
  1698.  
  1699. FormalParameterList ::= FormalParameter
  1700. \:$action:\
  1701. /.$location
  1702. //
  1703. // Note that the list is circular so as to preserve the order of the elements
  1704. //
  1705. void Parser::Act$rule_number(void)
  1706. {
  1707.     AstListNode *p = AllocateListNode();
  1708.     p -> next = p;
  1709.     p -> element = Sym(1);
  1710.     p -> index = 0;
  1711.  
  1712.     Sym(1) = p;
  1713. }
  1714. ./
  1715.  
  1716. FormalParameterList ::= FormalParameterList ',' FormalParameter
  1717. \:$action:\
  1718. /.$location
  1719. //
  1720. // Note that the list is circular so as to preserve the order of the elements
  1721. //
  1722. void Parser::Act$rule_number(void)
  1723. {
  1724.     AstListNode *tail = (AstListNode *) Sym(1);
  1725.  
  1726.     AstListNode *p = AllocateListNode();
  1727.     p -> element = Sym(3);
  1728.     p -> index = tail -> index + 1;
  1729.  
  1730.     p -> next = tail -> next;
  1731.     tail -> next = p;
  1732.  
  1733.     Sym(1) = p;
  1734. }
  1735. ./
  1736.  
  1737. FormalParameter ::= Type VariableDeclaratorId
  1738. \:$action:\
  1739. /.$location
  1740. void Parser::Act$rule_number(void)
  1741. {
  1742.     AstFormalParameter *p = ast_pool -> NewFormalParameter();
  1743.     p -> type = Sym(1);
  1744.  
  1745.     AstVariableDeclarator *formal_declarator = ast_pool -> NewVariableDeclarator();
  1746.     formal_declarator -> variable_declarator_name = (AstVariableDeclaratorId *) Sym(2);
  1747.     formal_declarator -> variable_initializer_opt = NULL;
  1748.  
  1749.     p -> formal_declarator = formal_declarator;
  1750.  
  1751.     Sym(1) = p;
  1752. }
  1753. ./
  1754.  
  1755. --1.1 feature
  1756. FormalParameter ::= Modifiers Type VariableDeclaratorId
  1757. \:$action:\
  1758. /.$location
  1759. void Parser::Act$rule_number(void)
  1760. {
  1761.     AstFormalParameter *p = ast_pool -> NewFormalParameter();
  1762.     //
  1763.     // The list of modifiers is guaranteed not empty
  1764.     //
  1765.     {
  1766.         AstListNode *tail = (AstListNode *) Sym(1);
  1767.         p -> AllocateParameterModifiers(tail -> index + 1);
  1768.         AstListNode *root = tail;
  1769.         do
  1770.         {
  1771.             root = root -> next;
  1772.             p -> AddParameterModifier((AstModifier *) root -> element);
  1773.         } while(root != tail);
  1774.         FreeCircularList(tail);
  1775.     }
  1776.  
  1777.     p -> type = Sym(2);
  1778.  
  1779.     AstVariableDeclarator *formal_declarator = ast_pool -> NewVariableDeclarator();
  1780.     formal_declarator -> variable_declarator_name = (AstVariableDeclaratorId *) Sym(3);
  1781.     formal_declarator -> variable_initializer_opt = NULL;
  1782.  
  1783.     p -> formal_declarator = formal_declarator;
  1784.  
  1785.     Sym(1) = p;
  1786. }
  1787. ./
  1788.  
  1789. Throws ::= 'throws' ClassTypeList
  1790. \:$SetSym1ToSym2:\
  1791. /.$shared_function
  1792. //
  1793. // void SetSym1ToSym2(void);
  1794. //./
  1795.  
  1796. ClassTypeList ::= ClassType
  1797. \:$action:\
  1798. /.$location
  1799. //
  1800. // Note that the list is circular so as to preserve the order of the elements
  1801. //
  1802. void Parser::Act$rule_number(void)
  1803. {
  1804.     AstListNode *p = AllocateListNode();
  1805.     p -> next = p;
  1806.     p -> element = Sym(1);
  1807.     p -> index = 0;
  1808.  
  1809.     Sym(1) = p;
  1810. }
  1811. ./
  1812.  
  1813. ClassTypeList ::= ClassTypeList ',' ClassType
  1814. \:$action:\
  1815. /.$location
  1816. //
  1817. // Note that the list is circular so as to preserve the order of the elements
  1818. //
  1819. void Parser::Act$rule_number(void)
  1820. {
  1821.     AstListNode *tail = (AstListNode *) Sym(1);
  1822.  
  1823.     AstListNode *p = AllocateListNode();
  1824.     p -> element = Sym(3);
  1825.     p -> index = tail -> index + 1;
  1826.  
  1827.     p -> next = tail -> next;
  1828.     tail -> next = p;
  1829.  
  1830.     Sym(1) = p;
  1831. }
  1832. ./
  1833.  
  1834. MethodBody -> Block
  1835. \:$NoAction:\
  1836. /.$shared_NoAction./
  1837.  
  1838. MethodBody ::= ';'
  1839. \:$MakeEmptyStatement:\
  1840. /.$location
  1841. void Parser::MakeEmptyStatement(void)
  1842. {
  1843.     Sym(1) = ast_pool -> NewEmptyStatement(Token(1));
  1844. }
  1845. ./
  1846.  
  1847. --18.8.4 Productions from 8.5: Static Initializers
  1848.  
  1849. StaticInitializer ::= 'static' MethodHeaderMarker Block
  1850. \:$action:\
  1851. /.$location
  1852. void Parser::Act$rule_number(void)
  1853. {
  1854.     AstStaticInitializer *p = ast_pool -> NewStaticInitializer();
  1855.     p -> static_token = Token(1);
  1856.     p -> block        = (AstBlock *) Sym(3);
  1857.     Sym(1) = p;
  1858. }
  1859. ./
  1860.  
  1861. --18.8.5 Productions from 8.6: Constructor Declarations
  1862. --ConstructorModifier ::=
  1863. --      'public'
  1864. --    | 'protected'
  1865. --    | 'private'
  1866. --
  1867. --
  1868. -- The original rule does not contain a "MethodHeaderMarker". See
  1869. -- explanation above.
  1870. --
  1871. -- ConstructorDeclaration ::= Modifiersopt ConstructorDeclarator Throwsopt ConstructorBody
  1872. --
  1873.  
  1874. ConstructorDeclaration ::= Modifiersopt ConstructorDeclarator Throwsopt MethodHeaderMarker ConstructorBody
  1875. \:$action:\
  1876. /.$location
  1877. void Parser::Act$rule_number(void)
  1878. {
  1879.     AstConstructorBlock *block = Sym(5) -> ConstructorBlockCast();
  1880.     if (! block)
  1881.     {
  1882.         block = ast_pool -> NewConstructorBlock();
  1883.         block -> left_brace_token                    = Sym(5) -> LeftToken();
  1884.         block -> explicit_constructor_invocation_opt = NULL;
  1885.         block -> block                               = (AstBlock *) Sym(5);
  1886.         block -> right_brace_token                   = Sym(5) -> RightToken();
  1887.     }
  1888.  
  1889.     AstConstructorDeclaration *p = ast_pool -> NewConstructorDeclaration();
  1890.  
  1891.     if (Sym(1) != NULL)
  1892.     {
  1893.         AstListNode *tail = (AstListNode *) Sym(1);
  1894.         p -> AllocateConstructorModifiers(tail -> index + 1);
  1895.         AstListNode *root = tail;
  1896.         do
  1897.         {
  1898.             root = root -> next;
  1899.             p -> AddConstructorModifier((AstModifier *) root -> element);
  1900.         } while(root != tail);
  1901.         FreeCircularList(tail);
  1902.     }
  1903.     p -> constructor_declarator = (AstMethodDeclarator *) Sym(2);
  1904.     if (Sym(3) != NULL)
  1905.     {
  1906.         AstListNode *tail = (AstListNode *) Sym(3);
  1907.         p -> AllocateThrows(tail -> index + 1);
  1908.         AstListNode *root = tail;
  1909.         do
  1910.         {
  1911.             root = root -> next;
  1912.             p -> AddThrow((AstExpression *) root -> element);
  1913.         } while(root != tail);
  1914.         FreeCircularList(tail);
  1915.     }
  1916.     p -> constructor_body       = block;
  1917.  
  1918.     Sym(1) = p;
  1919. }
  1920. ./
  1921.  
  1922. --
  1923. -- The original rule specifies SimpleName but it appears to be an
  1924. -- error as the rule for a method declarator uses an Identifier.
  1925. --...Until further notice, ...
  1926. --
  1927. -- ConstructorDeclarator ::= SimpleName '(' FormalParameterListopt ')'
  1928. --
  1929.  
  1930. ConstructorDeclarator ::= 'Identifier' '(' FormalParameterListopt ')'
  1931. \:$action:\
  1932. /.$location
  1933. void Parser::Act$rule_number(void)
  1934. {
  1935.     AstMethodDeclarator *p = ast_pool -> NewMethodDeclarator();
  1936.     p -> identifier_token        = Token(1);
  1937.     p -> left_parenthesis_token  = Token(2);
  1938.     if (Sym(3) != NULL)
  1939.     {
  1940.         AstListNode *tail = (AstListNode *) Sym(3);
  1941.         p -> AllocateFormalParameters(tail -> index + 1);
  1942.         AstListNode *root = tail;
  1943.         do
  1944.         {
  1945.             root = root -> next;
  1946.             p -> AddFormalParameter((AstFormalParameter *) root -> element);
  1947.         } while(root != tail);
  1948.         FreeCircularList(tail);
  1949.     }
  1950.     p -> right_parenthesis_token = Token(4);
  1951.     Sym(1) = p;
  1952. }
  1953. ./
  1954.  
  1955. --
  1956. -- NOTE that the rules ExplicitConstructorInvocationopt has been expanded
  1957. -- in the rule below in order to make the grammar lalr(1).
  1958. --
  1959. -- ConstructorBody ::= '{' ExplicitConstructorInvocationopt BlockStatementsopt '}'
  1960. --
  1961. ConstructorBody -> Block
  1962. \:$NoAction:\
  1963. /.$shared_NoAction./
  1964.  
  1965. ConstructorBody ::= '{' ExplicitConstructorInvocation BlockStatementsopt '}'
  1966. \:$action:\
  1967. /.$location
  1968. void Parser::Act$rule_number(void)
  1969. {
  1970.     AstBlock *block = ast_pool -> NewBlock();
  1971.     if (Sym(3) != NULL)
  1972.     {
  1973.         AstListNode *tail = (AstListNode *) Sym(3);
  1974.         block -> AllocateBlockStatements(tail -> index + 1);
  1975.         AstListNode *root = tail;
  1976.         block -> left_brace_token  = root -> element -> LeftToken();
  1977.         block -> right_brace_token = tail -> element -> RightToken();
  1978.         do
  1979.         {
  1980.             root = root -> next;
  1981.             block -> AddStatement((AstStatement *) root -> element);
  1982.         } while(root != tail);
  1983.         FreeCircularList(tail);
  1984.     }
  1985.     else
  1986.     {
  1987.         block -> left_brace_token  = Token(4);
  1988.         block -> right_brace_token = Token(4);
  1989.     }
  1990.  
  1991.     AstConstructorBlock *p = ast_pool -> NewConstructorBlock();
  1992.     p -> left_brace_token                    = Token(1);
  1993.     p -> explicit_constructor_invocation_opt = Sym(2);
  1994.     p -> block                               = block;
  1995.     p -> right_brace_token                   = Token(4);
  1996.     Sym(1) = p;
  1997. }
  1998. ./
  1999.  
  2000. ExplicitConstructorInvocation ::= 'this' '(' ArgumentListopt ')' ';'
  2001. \:$action:\
  2002. /.$location
  2003. void Parser::Act$rule_number(void)
  2004. {
  2005.     AstThisCall *p = ast_pool -> NewThisCall();
  2006.     p -> base_opt                = NULL;
  2007.     p -> dot_token_opt           = 0;
  2008.     p -> this_token              = Token(1);
  2009.     p -> left_parenthesis_token  = Token(2);
  2010.     if (Sym(3) != NULL)
  2011.     {
  2012.         AstListNode *tail = (AstListNode *) Sym(3);
  2013.         p -> AllocateArguments(tail -> index + 1);
  2014.         AstListNode *root = tail;
  2015.         do
  2016.         {
  2017.             root = root -> next;
  2018.             p -> AddArgument((AstExpression *) root -> element);
  2019.         } while(root != tail);
  2020.         FreeCircularList(tail);
  2021.     }
  2022.     p -> right_parenthesis_token = Token(4);
  2023.     p -> semicolon_token         = Token(5);
  2024.     Sym(1) = p;
  2025. }
  2026. ./
  2027.  
  2028. ExplicitConstructorInvocation ::= 'super' '(' ArgumentListopt ')' ';'
  2029. \:$action:\
  2030. /.$location
  2031. void Parser::Act$rule_number(void)
  2032. {
  2033.     AstSuperCall *p = ast_pool -> NewSuperCall();
  2034.     p -> base_opt                = NULL;
  2035.     p -> dot_token_opt           = 0;
  2036.     p -> super_token             = Token(1);
  2037.     p -> left_parenthesis_token  = Token(2);
  2038.     if (Sym(3) != NULL)
  2039.     {
  2040.         AstListNode *tail = (AstListNode *) Sym(3);
  2041.         p -> AllocateArguments(tail -> index + 1);
  2042.         AstListNode *root = tail;
  2043.         do
  2044.         {
  2045.             root = root -> next;
  2046.             p -> AddArgument((AstExpression *) root -> element);
  2047.         } while(root != tail);
  2048.         FreeCircularList(tail);
  2049.     }
  2050.     p -> right_parenthesis_token = Token(4);
  2051.     p -> semicolon_token         = Token(5);
  2052.     Sym(1) = p;
  2053. }
  2054. ./
  2055.  
  2056. --1.2 feature
  2057. ExplicitConstructorInvocation ::= Primary '.' 'this' '(' ArgumentListopt ')' ';'
  2058. \:$action:\
  2059. /.$location
  2060. void Parser::Act$rule_number(void)
  2061. {
  2062.     AstThisCall *p = ast_pool -> NewThisCall();
  2063.     p -> base_opt               = (AstExpression *) Sym(1);
  2064.     p -> dot_token_opt          = Token(2);
  2065.     p -> this_token             = Token(3);
  2066.     p -> left_parenthesis_token = Token(4);
  2067.     if (Sym(5) != NULL)
  2068.     {
  2069.         AstListNode *tail = (AstListNode *) Sym(5);
  2070.         p -> AllocateArguments(tail -> index + 1);
  2071.         AstListNode *root = tail;
  2072.         do
  2073.         {
  2074.             root = root -> next;
  2075.             p -> AddArgument((AstExpression *) root -> element);
  2076.         } while(root != tail);
  2077.         FreeCircularList(tail);
  2078.     }
  2079.     p -> right_parenthesis_token = Token(6);
  2080.     p -> semicolon_token         = Token(7);
  2081.     Sym(1) = p;
  2082. }
  2083. ./
  2084.  
  2085. --1.1 feature
  2086. ExplicitConstructorInvocation ::= Primary '.' 'super' '(' ArgumentListopt ')' ';'
  2087. \:$MakeQualifiedSuper:\
  2088. /.$location
  2089. void Parser::MakeQualifiedSuper(void)
  2090. {
  2091.     AstSuperCall *p = ast_pool -> NewSuperCall();
  2092.     p -> base_opt                = (AstExpression *) Sym(1);
  2093.     p -> dot_token_opt           = Token(2);
  2094.     p -> super_token             = Token(3);
  2095.     p -> left_parenthesis_token  = Token(4);
  2096.     if (Sym(5) != NULL)
  2097.     {
  2098.         AstListNode *tail = (AstListNode *) Sym(5);
  2099.         p -> AllocateArguments(tail -> index + 1);
  2100.         AstListNode *root = tail;
  2101.         do
  2102.         {
  2103.             root = root -> next;
  2104.             p -> AddArgument((AstExpression *) root -> element);
  2105.         } while(root != tail);
  2106.         FreeCircularList(tail);
  2107.     }
  2108.     p -> right_parenthesis_token = Token(6);
  2109.     p -> semicolon_token         = Token(7);
  2110.     Sym(1) = p;
  2111. }
  2112. ./
  2113.  
  2114. --1.1 feature
  2115. ExplicitConstructorInvocation ::= Name '.' 'super' '(' ArgumentListopt ')' ';'
  2116. \:$MakeQualifiedSuper:\
  2117. /.$shared_function
  2118. //
  2119. // void MakeQualifiedSuper(void);
  2120. //./
  2121.  
  2122. --18.9 Productions from 9: Interface Declarations
  2123.  
  2124. --18.9.1 Productions from 9.1: Interface Declarations
  2125. --InterfaceModifier ::=
  2126. --      'public'
  2127. --    | 'abstract'
  2128. --
  2129. InterfaceDeclaration ::= Modifiersopt 'interface' 'Identifier' ExtendsInterfacesopt InterfaceBody
  2130. \:$action:\
  2131. /.$location
  2132. void Parser::Act$rule_number(void)
  2133. {
  2134.     AstInterfaceDeclaration *p = (AstInterfaceDeclaration *) Sym(5);
  2135.     if (Sym(1) != NULL)
  2136.     {
  2137.         AstListNode *tail = (AstListNode *) Sym(1);
  2138.         p -> AllocateInterfaceModifiers(tail -> index + 1);
  2139.         AstListNode *root = tail;
  2140.         do
  2141.         {
  2142.             root = root -> next;
  2143.             p -> AddInterfaceModifier((AstModifier *) root -> element);
  2144.         } while(root != tail);
  2145.         FreeCircularList(tail);
  2146.     }
  2147.     p -> interface_token  = Token(2);
  2148.     p -> identifier_token = Token(3);
  2149.     if (Sym(4) != NULL)
  2150.     {
  2151.         AstListNode *tail = (AstListNode *) Sym(4);
  2152.         p -> AllocateExtendsInterfaces(tail -> index + 1);
  2153.         AstListNode *root = tail;
  2154.         do
  2155.         {
  2156.             root = root -> next;
  2157.             p -> AddExtendsInterface((AstExpression *) root -> element);
  2158.         } while(root != tail);
  2159.         FreeCircularList(tail);
  2160.     }
  2161.     Sym(1) = p;
  2162. }
  2163. ./
  2164.  
  2165. ExtendsInterfaces ::= 'extends' InterfaceTypeList
  2166. \:$SetSym1ToSym2:\
  2167. /.$shared_function
  2168. //
  2169. // void SetSym1ToSym2(void);
  2170. //./
  2171.  
  2172. InterfaceBody ::= '{' InterfaceMemberDeclarationsopt '}'
  2173. \:$action:\
  2174. /.$location
  2175. void Parser::Act$rule_number(void)
  2176. {
  2177.     AstInterfaceDeclaration *p = ast_pool -> NewInterfaceDeclaration();
  2178.     if (parse_header_only)
  2179.         p -> mark_unparsed();
  2180.  
  2181.     p -> left_brace_token = Token(1);
  2182.     if (Sym(2) != NULL)
  2183.     {
  2184.         int num_class_variables = 0,
  2185.             num_methods = 0,
  2186.             num_inner_classes = 0,
  2187.             num_inner_interfaces = 0,
  2188.             num_empty_declarations = 0;
  2189.  
  2190.         AstListNode *tail = (AstListNode *) Sym(2);
  2191.         p -> AllocateInterfaceMemberDeclarations(tail -> index + 1);
  2192.         AstListNode *root = tail;
  2193.         do
  2194.         {
  2195.             root = root -> next;
  2196.             p -> AddInterfaceMemberDeclaration(root -> element);
  2197.  
  2198.             AstFieldDeclaration *field_declaration = root -> element -> FieldDeclarationCast();
  2199.             if (field_declaration)
  2200.             {
  2201.                 field_declaration -> MarkStatic();
  2202.                 num_class_variables++;
  2203.             }
  2204.             else if (root -> element -> MethodDeclarationCast())
  2205.             {
  2206.                 num_methods++;
  2207.             }
  2208.             else if (root -> element -> ClassDeclarationCast())
  2209.             {
  2210.                 num_inner_classes++;
  2211.             }
  2212.             else if (root -> element -> InterfaceDeclarationCast())
  2213.             {
  2214.                 num_inner_interfaces++;
  2215.             }
  2216.             else num_empty_declarations++;
  2217.         } while(root != tail);
  2218.  
  2219.         p -> AllocateClassVariables(num_class_variables);
  2220.         p -> AllocateMethods(num_methods);
  2221.         p -> AllocateNestedClasses(num_inner_classes);
  2222.         p -> AllocateNestedInterfaces(num_inner_interfaces);
  2223.         p -> AllocateEmptyDeclarations(num_empty_declarations);
  2224.  
  2225.         root = tail;
  2226.         do
  2227.         {
  2228.             root = root -> next;
  2229.  
  2230.             AstFieldDeclaration *field_declaration;
  2231.             AstMethodDeclaration *method_declaration;
  2232.             AstClassDeclaration *class_declaration;
  2233.             AstInterfaceDeclaration *interface_declaration;
  2234.  
  2235.             if ((field_declaration = root -> element -> FieldDeclarationCast()))
  2236.             {
  2237.                 p -> AddClassVariable(field_declaration);
  2238.             }
  2239.             else if ((method_declaration = root -> element -> MethodDeclarationCast()))
  2240.             {
  2241.                 p -> AddMethod(method_declaration);
  2242.             }
  2243.             else if ((class_declaration = root -> element -> ClassDeclarationCast()))
  2244.             {
  2245.                 p -> AddNestedClass(class_declaration);
  2246.             }
  2247.             else if ((interface_declaration = root -> element -> InterfaceDeclarationCast()))
  2248.             {
  2249.                 p -> AddNestedInterface(interface_declaration);
  2250.             }
  2251.             else // assert(interface_declaration = root -> element -> EmptyDeclarationCast())
  2252.             {
  2253.                 p -> AddEmptyDeclaration((AstEmptyDeclaration *) root -> element);
  2254.             }
  2255.         } while(root != tail);
  2256.         FreeCircularList(tail);
  2257.     }
  2258.     p -> right_brace_token = Token(3);
  2259.     p -> pool = body_pool; // from now on, this is the storage pool to use for this type
  2260.     Sym(1) = p;
  2261. }
  2262. ./
  2263.  
  2264. InterfaceMemberDeclarations ::= InterfaceMemberDeclaration
  2265. \:$action:\
  2266. /.$location
  2267. //
  2268. // Note that the list is circular so as to preserve the order of the elements
  2269. //
  2270. void Parser::Act$rule_number(void)
  2271. {
  2272.     AstListNode *p = AllocateListNode();
  2273.     p -> next = p;
  2274.     p -> element = Sym(1);
  2275.     p -> index = 0;
  2276.  
  2277.     Sym(1) = p;
  2278. }
  2279. ./
  2280.  
  2281. InterfaceMemberDeclarations ::= InterfaceMemberDeclarations InterfaceMemberDeclaration
  2282. \:$action:\
  2283. /.$location
  2284. //
  2285. // Note that the list is circular so as to preserve the order of the elements
  2286. //
  2287. void Parser::Act$rule_number(void)
  2288. {
  2289.     AstListNode *tail = (AstListNode *) Sym(1);
  2290.  
  2291.     AstListNode *p = AllocateListNode();
  2292.     p -> element = Sym(2);
  2293.     p -> index = tail -> index + 1;
  2294.  
  2295.     p -> next = tail -> next;
  2296.     tail -> next = p;
  2297.  
  2298.     Sym(1) = p;
  2299. }
  2300. ./
  2301.  
  2302. InterfaceMemberDeclaration -> ConstantDeclaration
  2303. \:$NoAction:\
  2304. /.$shared_NoAction./
  2305.  
  2306. InterfaceMemberDeclaration -> AbstractMethodDeclaration
  2307. \:$NoAction:\
  2308. /.$shared_NoAction./
  2309.  
  2310. --1.1 feature
  2311. InterfaceMemberDeclaration -> ClassDeclaration
  2312. \:$NoAction:\
  2313. /.$shared_NoAction./
  2314.  
  2315. --1.1 feature
  2316. InterfaceMemberDeclaration -> InterfaceDeclaration
  2317. \:$NoAction:\
  2318. /.$shared_NoAction./
  2319.  
  2320. --
  2321. -- Empty declarations are not valid Java InterfaceMemberDeclarations.
  2322. -- However, since the current (2/14/97) Java compiler accepts them
  2323. -- (in fact, some of the official tests contain this erroneous
  2324. -- syntax), we decided to accept them as valid syntax and flag them
  2325. -- as a warning during semantic processing.
  2326. --
  2327. InterfaceMemberDeclaration ::= ';'
  2328. \:$action:\
  2329. /.$location
  2330. void Parser::Act$rule_number(void)
  2331. {
  2332.     Sym(1) = ast_pool -> NewEmptyDeclaration(Token(1));
  2333. }
  2334. ./
  2335.  
  2336. ConstantDeclaration -> FieldDeclaration
  2337. \:$NoAction:\
  2338. /.$shared_NoAction./
  2339.  
  2340. AbstractMethodDeclaration ::= MethodHeader ';'
  2341. \:$action:\
  2342. /.$location
  2343. void Parser::Act$rule_number(void)
  2344. {
  2345.     ((AstMethodDeclaration *) Sym(1)) -> method_body = ast_pool -> NewEmptyStatement(Token(2));
  2346. }
  2347. ./
  2348.  
  2349. --18.10 Productions from 10: Arrays
  2350.  
  2351. --
  2352. -- NOTE that the rules VariableInitializersopt and ,opt have been expanded,
  2353. -- where appropriate, in the rule below in order to make the grammar lalr(1).
  2354. --
  2355. -- ArrayInitializer ::= '{' VariableInitializersopt ,opt '}'
  2356. --
  2357. ArrayInitializer ::= '{' ,opt '}'
  2358. \:$action:\
  2359. /.$location
  2360. void Parser::Act$rule_number(void)
  2361. {
  2362.     AstArrayInitializer *p = ast_pool -> NewArrayInitializer();
  2363.     p -> left_brace_token      = Token(1);
  2364.     p -> right_brace_token     = Token(3);
  2365.     Sym(1) = p;
  2366. }
  2367. ./
  2368.  
  2369. ArrayInitializer ::= '{' VariableInitializers '}'
  2370. \:$action:\
  2371. /.$location
  2372. void Parser::Act$rule_number(void)
  2373. {
  2374.     AstArrayInitializer *p = ast_pool -> NewArrayInitializer();
  2375.     p -> left_brace_token      = Token(1);
  2376.     if (Sym(2) != NULL)
  2377.     {
  2378.         AstListNode *tail = (AstListNode *) Sym(2);
  2379.         p -> AllocateVariableInitializers(tail -> index + 1);
  2380.         AstListNode *root = tail;
  2381.         do
  2382.         {
  2383.             root = root -> next;
  2384.             p -> AddVariableInitializer(root -> element);
  2385.         } while(root != tail);
  2386.         FreeCircularList(tail);
  2387.     }
  2388.     p -> right_brace_token     = Token(3);
  2389.     Sym(1) = p;
  2390. }
  2391. ./
  2392.  
  2393. ArrayInitializer ::= '{' VariableInitializers , '}'
  2394. \:$action:\
  2395. /.$location
  2396. void Parser::Act$rule_number(void)
  2397. {
  2398.     AstArrayInitializer *p = ast_pool -> NewArrayInitializer();
  2399.     p -> left_brace_token      = Token(1);
  2400.     if (Sym(2) != NULL)
  2401.     {
  2402.         AstListNode *tail = (AstListNode *) Sym(2);
  2403.         p -> AllocateVariableInitializers(tail -> index + 1);
  2404.         AstListNode *root = tail;
  2405.         do
  2406.         {
  2407.             root = root -> next;
  2408.             p -> AddVariableInitializer(root -> element);
  2409.         } while(root != tail);
  2410.         FreeCircularList(tail);
  2411.     }
  2412.     p -> right_brace_token     = Token(4);
  2413.     Sym(1) = p;
  2414. }
  2415. ./
  2416.  
  2417. VariableInitializers ::= VariableInitializer
  2418. \:$action:\
  2419. /.$location
  2420. //
  2421. // Note that the list is circular so as to preserve the order of the elements
  2422. //
  2423. void Parser::Act$rule_number(void)
  2424. {
  2425.     AstListNode *p = AllocateListNode();
  2426.     p -> next = p;
  2427.     p -> element = Sym(1);
  2428.     p -> index = 0;
  2429.  
  2430.     Sym(1) = p;
  2431. }
  2432. ./
  2433.  
  2434. VariableInitializers ::= VariableInitializers ',' VariableInitializer
  2435. \:$action:\
  2436. /.$location
  2437. //
  2438. // Note that the list is circular so as to preserve the order of the elements
  2439. //
  2440. void Parser::Act$rule_number(void)
  2441. {
  2442.     AstListNode *tail = (AstListNode *) Sym(1);
  2443.  
  2444.     AstListNode *p = AllocateListNode();
  2445.     p -> element = Sym(3);
  2446.     p -> index = tail -> index + 1;
  2447.  
  2448.     p -> next = tail -> next;
  2449.     tail -> next = p;
  2450.  
  2451.     Sym(1) = p;
  2452. }
  2453. ./
  2454.  
  2455. --18.11 Productions from 13: Blocks and Statements
  2456.  
  2457. Block ::= '{' BlockStatementsopt '}'
  2458. \:$action:\
  2459. /.$location
  2460. void Parser::Act$rule_number(void)
  2461. {
  2462.     AstBlock *p = ast_pool -> NewBlock();
  2463.     p -> left_brace_token  = Token(1);
  2464.     if (Sym(2) != NULL)
  2465.     {
  2466.         AstListNode *tail = (AstListNode *) Sym(2);
  2467.         p -> AllocateBlockStatements(tail -> index + 1);
  2468.         AstListNode *root = tail;
  2469.         do
  2470.         {
  2471.             root = root -> next;
  2472.             p -> AddStatement((AstStatement *) root -> element);
  2473.         } while(root != tail);
  2474.         FreeCircularList(tail);
  2475.     }
  2476.     p -> right_brace_token = Token(3);
  2477.     Sym(1) = p;
  2478. }
  2479. ./
  2480.  
  2481. BlockStatements ::= BlockStatement
  2482. \:$action:\
  2483. /.$location
  2484. //
  2485. // Note that the list is circular so as to preserve the order of the elements
  2486. //
  2487. void Parser::Act$rule_number(void)
  2488. {
  2489.     AstListNode *p = AllocateListNode();
  2490.     p -> next = p;
  2491.     p -> element = Sym(1);
  2492.     p -> index = 0;
  2493.  
  2494.     Sym(1) = p;
  2495. }
  2496. ./
  2497.  
  2498. BlockStatements ::= BlockStatements BlockStatement
  2499. \:$action:\
  2500. /.$location
  2501. //
  2502. // Note that the list is circular so as to preserve the order of the elements
  2503. //
  2504. void Parser::Act$rule_number(void)
  2505. {
  2506.     AstListNode *tail = (AstListNode *) Sym(1);
  2507.  
  2508.     AstListNode *p = AllocateListNode();
  2509.     p -> element = Sym(2);
  2510.     p -> index = tail -> index + 1;
  2511.  
  2512.     p -> next = tail -> next;
  2513.     tail -> next = p;
  2514.  
  2515.     Sym(1) = p;
  2516. }
  2517. ./
  2518.  
  2519. BlockStatement -> LocalVariableDeclarationStatement
  2520. \:$NoAction:\
  2521. /.$shared_NoAction./
  2522.  
  2523. BlockStatement -> Statement
  2524. \:$NoAction:\
  2525. /.$shared_NoAction./
  2526.  
  2527. --1.1 feature
  2528. BlockStatement -> ClassDeclaration
  2529. \:$NoAction:\
  2530. /.$shared_NoAction./
  2531.  
  2532. LocalVariableDeclarationStatement ::= LocalVariableDeclaration ';'
  2533. \:$action:\
  2534. /.$location
  2535. void Parser::Act$rule_number(void)
  2536. {
  2537.     ((AstLocalVariableDeclarationStatement *) Sym(1)) -> semicolon_token_opt = Token(2);
  2538. }
  2539. ./
  2540.  
  2541. LocalVariableDeclaration ::= Type VariableDeclarators
  2542. \:$action:\
  2543. /.$location
  2544. void Parser::Act$rule_number(void)
  2545. {
  2546.     AstLocalVariableDeclarationStatement *p = ast_pool -> NewLocalVariableDeclarationStatement();
  2547.     p -> type                 = Sym(1);
  2548.     //
  2549.     // The list of declarators is guaranteed not empty
  2550.     //
  2551.     {
  2552.         AstListNode *tail = (AstListNode *) Sym(2);
  2553.         p -> AllocateVariableDeclarators(tail -> index + 1);
  2554.         AstListNode *root = tail;
  2555.         do
  2556.         {
  2557.             root = root -> next;
  2558.             p -> AddVariableDeclarator((AstVariableDeclarator *) root -> element);
  2559.         } while(root != tail);
  2560.         FreeCircularList(tail);
  2561.     }
  2562.     p -> semicolon_token_opt  = 0;
  2563.     Sym(1) = p;
  2564. }
  2565. ./
  2566.  
  2567. --1.1 feature
  2568. LocalVariableDeclaration ::= Modifiers Type VariableDeclarators
  2569. \:$action:\
  2570. /.$location
  2571. void Parser::Act$rule_number(void)
  2572. {
  2573.     AstLocalVariableDeclarationStatement *p = ast_pool -> NewLocalVariableDeclarationStatement();
  2574.     //
  2575.     // The list of modifiers is guaranteed not empty
  2576.     //
  2577.     {
  2578.         AstListNode *tail = (AstListNode *) Sym(1);
  2579.         p -> AllocateLocalModifiers(tail -> index + 1);
  2580.         AstListNode *root = tail;
  2581.         do
  2582.         {
  2583.             root = root -> next;
  2584.             p -> AddLocalModifier((AstModifier *) root -> element);
  2585.         } while(root != tail);
  2586.         FreeCircularList(tail);
  2587.     }
  2588.     p -> type = Sym(2);
  2589.     //
  2590.     // The list of declarators is guaranteed not empty
  2591.     //
  2592.     {
  2593.         AstListNode *tail = (AstListNode *) Sym(3);
  2594.         p -> AllocateVariableDeclarators(tail -> index + 1);
  2595.         AstListNode *root = tail;
  2596.         do
  2597.         {
  2598.             root = root -> next;
  2599.             p -> AddVariableDeclarator((AstVariableDeclarator *) root -> element);
  2600.         } while(root != tail);
  2601.         FreeCircularList(tail);
  2602.     }
  2603.     p -> semicolon_token_opt  = 0;
  2604.     Sym(1) = p;
  2605. }
  2606. ./
  2607.  
  2608. Statement -> StatementWithoutTrailingSubstatement
  2609. \:$NoAction:\
  2610. /.$shared_NoAction./
  2611.  
  2612. Statement -> LabeledStatement
  2613. \:$NoAction:\
  2614. /.$shared_NoAction./
  2615.  
  2616. Statement -> IfThenStatement
  2617. \:$NoAction:\
  2618. /.$shared_NoAction./
  2619.  
  2620. Statement -> IfThenElseStatement
  2621. \:$NoAction:\
  2622. /.$shared_NoAction./
  2623.  
  2624. Statement -> WhileStatement
  2625. \:$NoAction:\
  2626. /.$shared_NoAction./
  2627.  
  2628. Statement -> ForStatement
  2629. \:$NoAction:\
  2630. /.$shared_NoAction./
  2631.  
  2632. StatementNoShortIf -> StatementWithoutTrailingSubstatement
  2633. \:$NoAction:\
  2634. /.$shared_NoAction./
  2635.  
  2636. StatementNoShortIf -> LabeledStatementNoShortIf
  2637. \:$NoAction:\
  2638. /.$shared_NoAction./
  2639.  
  2640. StatementNoShortIf -> IfThenElseStatementNoShortIf
  2641. \:$NoAction:\
  2642. /.$shared_NoAction./
  2643.  
  2644. StatementNoShortIf -> WhileStatementNoShortIf
  2645. \:$NoAction:\
  2646. /.$shared_NoAction./
  2647.  
  2648. StatementNoShortIf -> ForStatementNoShortIf
  2649. \:$NoAction:\
  2650. /.$shared_NoAction./
  2651.  
  2652. StatementWithoutTrailingSubstatement -> Block
  2653. \:$NoAction:\
  2654. /.$shared_NoAction./
  2655.  
  2656. StatementWithoutTrailingSubstatement -> EmptyStatement
  2657. \:$NoAction:\
  2658. /.$shared_NoAction./
  2659.  
  2660. StatementWithoutTrailingSubstatement -> ExpressionStatement
  2661. \:$NoAction:\
  2662. /.$shared_NoAction./
  2663.  
  2664. StatementWithoutTrailingSubstatement -> SwitchStatement
  2665. \:$NoAction:\
  2666. /.$shared_NoAction./
  2667.  
  2668. StatementWithoutTrailingSubstatement -> DoStatement
  2669. \:$NoAction:\
  2670. /.$shared_NoAction./
  2671.  
  2672. StatementWithoutTrailingSubstatement -> BreakStatement
  2673. \:$NoAction:\
  2674. /.$shared_NoAction./
  2675.  
  2676. StatementWithoutTrailingSubstatement -> ContinueStatement
  2677. \:$NoAction:\
  2678. /.$shared_NoAction./
  2679.  
  2680. StatementWithoutTrailingSubstatement -> ReturnStatement
  2681. \:$NoAction:\
  2682. /.$shared_NoAction./
  2683.  
  2684. StatementWithoutTrailingSubstatement -> SynchronizedStatement
  2685. \:$NoAction:\
  2686. /.$shared_NoAction./
  2687.  
  2688. StatementWithoutTrailingSubstatement -> ThrowStatement
  2689. \:$NoAction:\
  2690. /.$shared_NoAction./
  2691.  
  2692. StatementWithoutTrailingSubstatement -> TryStatement
  2693. \:$NoAction:\
  2694. /.$shared_NoAction./
  2695.  
  2696. EmptyStatement ::= ';'
  2697. \:$MakeEmptyStatement:\
  2698. /.$shared_function
  2699. //
  2700. // void MakeEmptyStatement(void);
  2701. //./
  2702.  
  2703. LabeledStatement ::= 'Identifier' ':' Statement
  2704. \:$MakeLabeledStatement:\
  2705. /.$location
  2706. void Parser::MakeLabeledStatement(void)
  2707. {
  2708.     AstBlock *p = Sym(3) -> BlockCast();
  2709.  
  2710.     if (! (p && p -> NumStatements() == 1 &&
  2711.            (p -> Statement(0) -> kind == Ast::FOR   ||
  2712.             p -> Statement(0) -> kind == Ast::WHILE ||
  2713.             p -> Statement(0) -> kind == Ast::DO)))
  2714.     {
  2715.         //
  2716.         // When a statement is labeled, it is enclosed in a block.
  2717.         // This is necessary in order to allow the same name to be
  2718.         // reused to label a subsequent statement at the same nesting
  2719.         // level... See ProcessBlock, ProcessStatement,...
  2720.         //
  2721.         p = ast_pool -> NewBlock();
  2722.         p -> AllocateBlockStatements(1); // allocate 1 element
  2723.         p -> left_brace_token  = Token(1);
  2724.         p -> AddStatement((AstStatement *) Sym(3));
  2725.         p -> right_brace_token = Sym(3) -> RightToken();
  2726.     }
  2727.  
  2728.     p -> AddLabel(Token(1)); // add label to statement
  2729.     Sym(1) = p; // The final result is a block containing the labeled-statement
  2730. }
  2731. ./
  2732.  
  2733. LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf
  2734. \:$MakeLabeledStatement:\
  2735. /.$shared_function
  2736. //
  2737. // void MakeLabeledStatement(void);
  2738. //./
  2739.  
  2740. ExpressionStatement ::= StatementExpression ';'
  2741. \:$action:\
  2742. /.$location
  2743. void Parser::Act$rule_number(void)
  2744. {
  2745.     ((AstExpressionStatement *) Sym(1)) -> semicolon_token_opt = Token(2);
  2746. }
  2747. ./
  2748.  
  2749. StatementExpression ::= Assignment
  2750. \:$MakeExpressionStatement:\
  2751. /.$location
  2752. void Parser::MakeExpressionStatement(void)
  2753. {
  2754.     AstExpressionStatement *p = ast_pool -> NewExpressionStatement();
  2755.     p -> expression          = (AstExpression *) Sym(1);
  2756.     p -> semicolon_token_opt = 0;
  2757.     Sym(1) = p;
  2758. }
  2759. ./
  2760.  
  2761. StatementExpression ::= PreIncrementExpression
  2762. \:$MakeExpressionStatement:\
  2763. /.$shared_function
  2764. //
  2765. // void MakeExpressionStatement(void);
  2766. //./
  2767.  
  2768. StatementExpression ::= PreDecrementExpression
  2769. \:$MakeExpressionStatement:\
  2770. /.$shared_function
  2771. //
  2772. // void MakeExpressionStatement(void);
  2773. //./
  2774.  
  2775. StatementExpression ::= PostIncrementExpression
  2776. \:$MakeExpressionStatement:\
  2777. /.$shared_function
  2778. //
  2779. // void MakeExpressionStatement(void);
  2780. //./
  2781.  
  2782. StatementExpression ::= PostDecrementExpression
  2783. \:$MakeExpressionStatement:\
  2784. /.$shared_function
  2785. //
  2786. // void MakeExpressionStatement(void);
  2787. //./
  2788.  
  2789. StatementExpression ::= MethodInvocation
  2790. \:$MakeExpressionStatement:\
  2791. /.$shared_function
  2792. //
  2793. // void MakeExpressionStatement(void);
  2794. //./
  2795.  
  2796. StatementExpression ::= ClassInstanceCreationExpression
  2797. \:$MakeExpressionStatement:\
  2798. /.$shared_function
  2799. //
  2800. // void MakeExpressionStatement(void);
  2801. //./
  2802.  
  2803. IfThenStatement ::=  'if' '(' Expression ')' Statement
  2804. \:$action:\
  2805. /.$location
  2806. void Parser::Act$rule_number(void)
  2807. {
  2808.     AstBlock *block = Sym(5) -> BlockCast();
  2809.     if (! block)
  2810.     {
  2811.         block = ast_pool -> NewBlock();
  2812.         block -> AllocateBlockStatements(1); // allocate 1 element
  2813.         block -> left_brace_token  = Token(5);
  2814.         block -> AddStatement((AstStatement *) Sym(5));
  2815.         block -> right_brace_token = Sym(5) -> RightToken();
  2816.     }
  2817.  
  2818.     AstIfStatement *p = ast_pool -> NewIfStatement();
  2819.     p -> if_token            = Token(1);
  2820.     p -> expression          = (AstExpression *) Sym(3);
  2821.     p -> true_statement      = block;
  2822.     p -> false_statement_opt = NULL;
  2823.     Sym(1) = p;
  2824. }
  2825. ./
  2826.  
  2827. IfThenElseStatement ::=  'if' '(' Expression ')' StatementNoShortIf 'else' Statement
  2828. \:$MakeIfThenElseStatement:\
  2829. /.$location
  2830. void Parser::MakeIfThenElseStatement(void)
  2831. {
  2832.     AstBlock *true_block = Sym(5) -> BlockCast();
  2833.     if (! true_block)
  2834.     {
  2835.         true_block = ast_pool -> NewBlock();
  2836.         true_block -> AllocateBlockStatements(1); // allocate 1 element
  2837.         true_block -> left_brace_token  = Token(5);
  2838.         true_block -> AddStatement((AstStatement *) Sym(5));
  2839.         true_block -> right_brace_token = Sym(5) -> RightToken();
  2840.     }
  2841.  
  2842.     AstBlock *false_block = Sym(7) -> BlockCast();
  2843.     if (! false_block)
  2844.     {
  2845.         false_block = ast_pool -> NewBlock();
  2846.         false_block -> AllocateBlockStatements(1); // allocate 1 element
  2847.         false_block -> left_brace_token  = Token(7);
  2848.         false_block -> AddStatement((AstStatement *) Sym(7));
  2849.         false_block -> right_brace_token = Sym(7) -> RightToken();
  2850.     }
  2851.  
  2852.     AstIfStatement *p = ast_pool -> NewIfStatement();
  2853.     p -> if_token            = Token(1);
  2854.     p -> expression          = (AstExpression *) Sym(3);
  2855.     p -> true_statement      = true_block;
  2856.     p -> false_statement_opt = false_block;
  2857.     Sym(1) = p;
  2858. }
  2859. ./
  2860.  
  2861. IfThenElseStatementNoShortIf ::=  'if' '(' Expression ')' StatementNoShortIf 'else' StatementNoShortIf
  2862. \:$MakeIfThenElseStatement:\
  2863. /.$shared_function
  2864. //
  2865. // void MakeIfThenElseStatement(void);
  2866. //./
  2867.  
  2868. SwitchStatement ::= 'switch' '(' Expression ')' SwitchBlock
  2869. \:$action:\
  2870. /.$location
  2871. void Parser::Act$rule_number(void)
  2872. {
  2873.     AstSwitchStatement *p = (AstSwitchStatement *) Sym(5);
  2874.     p -> switch_token = Token(1);
  2875.     p -> expression   = (AstExpression *) Sym(3);
  2876.     Sym(1) = p;
  2877. }
  2878. ./
  2879.  
  2880. SwitchBlock ::= '{' '}'
  2881. \:$action:\
  2882. /.$location
  2883. void Parser::Act$rule_number(void)
  2884. {
  2885.     AstSwitchStatement *p = ast_pool -> NewSwitchStatement();
  2886.  
  2887.     AstBlock *block = ast_pool -> NewBlock();
  2888.     block -> left_brace_token  = Token(1);
  2889.     block -> right_brace_token = Token(2);
  2890.  
  2891.     p -> switch_block = block;
  2892.  
  2893.     Sym(1) = p;
  2894. }
  2895. ./
  2896.  
  2897. SwitchBlock ::= '{' SwitchBlockStatements '}'
  2898. \:$action:\
  2899. /.$location
  2900. void Parser::Act$rule_number(void)
  2901. {
  2902.     AstSwitchStatement *p = ast_pool -> NewSwitchStatement();
  2903.  
  2904.     AstBlock *block = ast_pool -> NewBlock();
  2905.     block -> left_brace_token  = Token(1);
  2906.     if (Sym(2) != NULL)
  2907.     {
  2908.         AstListNode *tail = (AstListNode *) Sym(2);
  2909.         block -> AllocateBlockStatements(tail -> index + 1);
  2910.         AstListNode *root = tail;
  2911.         do
  2912.         {
  2913.             root = root -> next;
  2914.             block -> AddStatement((AstStatement *) root -> element);
  2915.         } while(root != tail);
  2916.         FreeCircularList(tail);
  2917.     }
  2918.     block -> right_brace_token = Token(3);
  2919.  
  2920.     p -> switch_block  = block;
  2921.  
  2922.     Sym(1) = p;
  2923. }
  2924. ./
  2925.  
  2926. SwitchBlock ::= '{' SwitchLabels '}'
  2927. \:$action:\
  2928. /.$location
  2929. void Parser::Act$rule_number(void)
  2930. {
  2931.     AstSwitchStatement *p = ast_pool -> NewSwitchStatement();
  2932.  
  2933.     AstSwitchBlockStatement *q = ast_pool -> NewSwitchBlockStatement();
  2934.     q -> AddStatement(ast_pool -> NewEmptyStatement(Sym(2) -> RightToken()));
  2935.  
  2936.     //
  2937.     // The list of SwitchBlockStatements is never null
  2938.     //
  2939.     {
  2940.         AstListNode *tail = (AstListNode *) Sym(2);
  2941.         q -> AllocateSwitchLabels(tail -> index + 1);
  2942.         AstListNode *root = tail;
  2943.         do
  2944.         {
  2945.             root = root -> next;
  2946.             q -> AddSwitchLabel((AstStatement *) root -> element);
  2947.         } while(root != tail);
  2948.         FreeCircularList(tail);
  2949.     }
  2950.  
  2951.     AstBlock *block = ast_pool -> NewBlock();
  2952.     block -> AllocateBlockStatements(1); // allocate 1 element
  2953.     block -> left_brace_token  = Token(1);
  2954.     block -> AddStatement(q);
  2955.     block -> right_brace_token = Token(3);
  2956.  
  2957.     p -> switch_block  = block;
  2958.  
  2959.     Sym(1) = p;
  2960. }
  2961. ./
  2962.  
  2963. SwitchBlock ::= '{' SwitchBlockStatements SwitchLabels '}'
  2964. \:$action:\
  2965. /.$location
  2966. void Parser::Act$rule_number(void)
  2967. {
  2968.     AstSwitchStatement *p = ast_pool -> NewSwitchStatement();
  2969.  
  2970.     AstBlock *block = ast_pool -> NewBlock();
  2971.     block -> left_brace_token  = Token(1);
  2972.     //
  2973.     // The list of SwitchBlockStatements is never null
  2974.     //
  2975.     {
  2976.         AstListNode *tail = (AstListNode *) Sym(2);
  2977.         block -> AllocateBlockStatements(tail -> index + 2); // +1 because of extra statement for additional SwithLabels
  2978.         AstListNode *root = tail;
  2979.         do
  2980.         {
  2981.             root = root -> next;
  2982.             block -> AddStatement((AstStatement *) root -> element);
  2983.         } while(root != tail);
  2984.         FreeCircularList(tail);
  2985.     }
  2986.  
  2987.     AstSwitchBlockStatement *q = ast_pool -> NewSwitchBlockStatement();
  2988.     q -> AddStatement(ast_pool -> NewEmptyStatement(Sym(3) -> RightToken()));
  2989.  
  2990.     //
  2991.     // The list of SwitchLabels is never null
  2992.     //
  2993.     {
  2994.         AstListNode *tail = (AstListNode *) Sym(3);
  2995.         q -> AllocateSwitchLabels(tail -> index + 1);
  2996.         AstListNode *root = tail;
  2997.         do
  2998.         {
  2999.             root = root -> next;
  3000.             q -> AddSwitchLabel(root -> element);
  3001.         } while(root != tail);
  3002.         FreeCircularList(tail);
  3003.     }
  3004.  
  3005.     block -> AddStatement(q);
  3006.     block -> right_brace_token = Token(4);
  3007.  
  3008.     p -> switch_block  = block;
  3009.  
  3010.     Sym(1) = p;
  3011. }
  3012. ./
  3013.  
  3014. SwitchBlockStatements ::= SwitchBlockStatement
  3015. \:$action:\
  3016. /.$location
  3017. //
  3018. // Note that the list is circular so as to preserve the order of the elements
  3019. //
  3020. void Parser::Act$rule_number(void)
  3021. {
  3022.     AstListNode *p = AllocateListNode();
  3023.     p -> next = p;
  3024.     p -> element = Sym(1);
  3025.     p -> index = 0;
  3026.  
  3027.     Sym(1) = p;
  3028. }
  3029. ./
  3030.  
  3031. SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement
  3032. \:$action:\
  3033. /.$location
  3034. //
  3035. // Note that the list is circular so as to preserve the order of the elements
  3036. //
  3037. void Parser::Act$rule_number(void)
  3038. {
  3039.     AstListNode *tail = (AstListNode *) Sym(1);
  3040.  
  3041.     AstListNode *p = AllocateListNode();
  3042.     p -> element = Sym(2);
  3043.     p -> index = tail -> index + 1;
  3044.  
  3045.     p -> next = tail -> next;
  3046.     tail -> next = p;
  3047.  
  3048.     Sym(1) = p;
  3049. }
  3050. ./
  3051.  
  3052. SwitchBlockStatement ::= SwitchLabels BlockStatements
  3053. \:$action:\
  3054. /.$location
  3055. void Parser::Act$rule_number(void)
  3056. {
  3057.     AstSwitchBlockStatement *p = ast_pool -> NewSwitchBlockStatement();
  3058.     //
  3059.     // The list of SwitchLabels is never null
  3060.     //
  3061.     {
  3062.         AstListNode *tail = (AstListNode *) Sym(1);
  3063.         p -> AllocateSwitchLabels(tail -> index + 1);
  3064.         AstListNode *root = tail;
  3065.         do
  3066.         {
  3067.             root = root -> next;
  3068.             p -> AddSwitchLabel(root -> element);
  3069.         } while(root != tail);
  3070.         FreeCircularList(tail);
  3071.     }
  3072.  
  3073.     //
  3074.     // The list of SwitchBlockStatements is never null
  3075.     //
  3076.     {
  3077.         AstListNode *tail = (AstListNode *) Sym(2);
  3078.         p -> AllocateBlockStatements(tail -> index + 1);
  3079.         AstListNode *root = tail;
  3080.         do
  3081.         {
  3082.             root = root -> next;
  3083.             p -> AddStatement((AstStatement *) root -> element);
  3084.         } while(root != tail);
  3085.         FreeCircularList(tail);
  3086.     }
  3087.     Sym(1) = p;
  3088. }
  3089. ./
  3090.  
  3091. SwitchLabels ::= SwitchLabel
  3092. \:$action:\
  3093. /.$location
  3094. //
  3095. // Note that the list is circular so as to preserve the order of the elements
  3096. //
  3097. void Parser::Act$rule_number(void)
  3098. {
  3099.     AstListNode *p = AllocateListNode();
  3100.     p -> next = p;
  3101.     p -> element = Sym(1);
  3102.     p -> index = 0;
  3103.  
  3104.     Sym(1) = p;
  3105. }
  3106. ./
  3107.  
  3108. SwitchLabels ::= SwitchLabels SwitchLabel
  3109. \:$action:\
  3110. /.$location
  3111. //
  3112. // Note that the list is circular so as to preserve the order of the elements
  3113. //
  3114. void Parser::Act$rule_number(void)
  3115. {
  3116.     AstListNode *tail = (AstListNode *) Sym(1);
  3117.  
  3118.     AstListNode *p = AllocateListNode();
  3119.     p -> element = Sym(2);
  3120.     p -> index = tail -> index + 1;
  3121.  
  3122.     p -> next = tail -> next;
  3123.     tail -> next = p;
  3124.  
  3125.     Sym(1) = p;
  3126. }
  3127. ./
  3128.  
  3129. SwitchLabel ::= 'case' ConstantExpression ':'
  3130. \:$action:\
  3131. /.$location
  3132. void Parser::Act$rule_number(void)
  3133. {
  3134.     AstCaseLabel *p = ast_pool -> NewCaseLabel();
  3135.     p -> case_token  = Token(1);
  3136.     p -> expression  = (AstExpression *) Sym(2);
  3137.     p -> colon_token = Token(3);
  3138.     Sym(1) = p;
  3139. }
  3140. ./
  3141.  
  3142. SwitchLabel ::= 'default' ':'
  3143. \:$action:\
  3144. /.$location
  3145. void Parser::Act$rule_number(void)
  3146. {
  3147.     AstDefaultLabel *p = ast_pool -> NewDefaultLabel();
  3148.     p -> default_token = Token(1);
  3149.     p -> colon_token   = Token(2);
  3150.     Sym(1) = p;
  3151. }
  3152. ./
  3153.  
  3154. WhileStatement ::= 'while' '(' Expression ')' Statement
  3155. \:$MakeWhileStatement:\
  3156. /.$location
  3157. void Parser::MakeWhileStatement(void)
  3158. {
  3159.     AstWhileStatement *p = ast_pool -> NewWhileStatement();
  3160.     p -> while_token = Token(1);
  3161.     p -> expression  = (AstExpression *) Sym(3);
  3162.     p -> statement   = (AstStatement *) Sym(5);
  3163.  
  3164.     AstBlock *block = ast_pool -> NewBlock();
  3165.     block -> AllocateBlockStatements(1); // allocate 1 element
  3166.     block -> left_brace_token  = Token(1); // point to 'FOR' keyword
  3167.     block -> AddStatement(p);
  3168.     block -> right_brace_token = Sym(5) -> RightToken(); // point to last token in statement
  3169.  
  3170.     Sym(1) = block;
  3171. }
  3172. ./
  3173.  
  3174. WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf
  3175. \:$MakeWhileStatement:\
  3176. /.$shared_function
  3177. //
  3178. // void MakeWhileStatement(void);
  3179. //./
  3180.  
  3181. DoStatement ::= 'do' Statement 'while' '(' Expression ')' ';'
  3182. \:$action:\
  3183. /.$location
  3184. void Parser::Act$rule_number(void)
  3185. {
  3186.     AstDoStatement *p = ast_pool -> NewDoStatement();
  3187.     p -> do_token        = Token(1);
  3188.     p -> statement       = (AstStatement *) Sym(2);
  3189.     p -> while_token     = Token(3);
  3190.     p -> expression      = (AstExpression *) Sym(5);
  3191.     p -> semicolon_token = Token(7);
  3192.  
  3193.     AstBlock *block = ast_pool -> NewBlock();
  3194.     block -> AllocateBlockStatements(1); // allocate 1 element
  3195.     block -> left_brace_token  = Token(1);
  3196.     block -> AddStatement(p);
  3197.     block -> right_brace_token = Token(7);
  3198.  
  3199.     Sym(1) = block;
  3200. }
  3201. ./
  3202.  
  3203. ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' Statement
  3204. \:$MakeForStatement:\
  3205. /.$location
  3206. void Parser::MakeForStatement(void)
  3207. {
  3208.     AstForStatement *p = ast_pool -> NewForStatement();
  3209.     p -> for_token = Token(1);
  3210.     if (Sym(3) != NULL)
  3211.     {
  3212.         AstListNode *tail = (AstListNode *) Sym(3);
  3213.         p -> AllocateForInitStatements(tail -> index + 1);
  3214.         AstListNode *root = tail;
  3215.         do
  3216.         {
  3217.             root = root -> next;
  3218.             p -> AddForInitStatement((AstStatement *) root -> element);
  3219.         } while(root != tail);
  3220.         FreeCircularList(tail);
  3221.     }
  3222.     p -> end_expression_opt = (AstExpression *) Sym(5);
  3223.     if (Sym(7) != NULL)
  3224.     {
  3225.         AstListNode *tail = (AstListNode *) Sym(7);
  3226.         p -> AllocateForUpdateStatements(tail -> index + 1);
  3227.         AstListNode *root = tail;
  3228.         do
  3229.         {
  3230.             root = root -> next;
  3231.             p -> AddForUpdateStatement((AstExpressionStatement *) root -> element);
  3232.         } while(root != tail);
  3233.         FreeCircularList(tail);
  3234.     }
  3235.     p -> statement = (AstStatement *) Sym(9);
  3236.  
  3237.     AstBlock *block = ast_pool -> NewBlock();
  3238.     block -> AllocateBlockStatements(1); // allocate 1 element
  3239.     block -> left_brace_token  = Token(1);
  3240.     block -> AddStatement(p);
  3241.     block -> right_brace_token = Sym(9) -> RightToken();
  3242.  
  3243.     Sym(1) = block;
  3244. }
  3245. ./
  3246.  
  3247. ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf
  3248. \:$MakeForStatement:\
  3249. /.$shared_function
  3250. //
  3251. // void MakeForStatement(void);
  3252. //./
  3253.  
  3254. ForInit -> StatementExpressionList
  3255. \:$NoAction:\
  3256. /.$shared_NoAction./
  3257.  
  3258. ForInit ::= LocalVariableDeclaration
  3259. \:$action:\
  3260. /.$location
  3261. //
  3262. // Note that the list is circular so as to preserve the order of the elements
  3263. //
  3264. void Parser::Act$rule_number(void)
  3265. {
  3266.     AstListNode *p = AllocateListNode();
  3267.     p -> next = p;
  3268.     p -> element = Sym(1);
  3269.     p -> index = 0;
  3270.  
  3271.     Sym(1) = p;
  3272. }
  3273. ./
  3274.  
  3275. ForUpdate -> StatementExpressionList
  3276. \:$NoAction:\
  3277. /.$shared_NoAction./
  3278.  
  3279. StatementExpressionList ::= StatementExpression
  3280. \:$action:\
  3281. /.$location
  3282. //
  3283. // Note that the list is circular so as to preserve the order of the elements
  3284. //
  3285. void Parser::Act$rule_number(void)
  3286. {
  3287.     AstListNode *p = AllocateListNode();
  3288.     p -> next = p;
  3289.     p -> element = Sym(1);
  3290.     p -> index = 0;
  3291.  
  3292.     Sym(1) = p;
  3293. }
  3294. ./
  3295.  
  3296. StatementExpressionList ::= StatementExpressionList ',' StatementExpression
  3297. \:$action:\
  3298. /.$location
  3299. //
  3300. // Note that the list is circular so as to preserve the order of the elements
  3301. //
  3302. void Parser::Act$rule_number(void)
  3303. {
  3304.     AstListNode *tail = (AstListNode *) Sym(1);
  3305.  
  3306.     AstListNode *p = AllocateListNode();
  3307.     p -> element = Sym(3);
  3308.     p -> index = tail -> index + 1;
  3309.  
  3310.     p -> next = tail -> next;
  3311.     tail -> next = p;
  3312.  
  3313.     Sym(1) = p;
  3314. }
  3315. ./
  3316.  
  3317. --
  3318. -- NOTE that the rule Identifieropt was expanded in line in the two
  3319. -- contexts where it appeared: Break and Continue statements.
  3320. -- This was done because there is no straightforward way of passing
  3321. -- optional token information in the parse stack.
  3322. --
  3323. BreakStatement ::= 'break' ';'
  3324. \:$action:\
  3325. /.$location
  3326. void Parser::Act$rule_number(void)
  3327. {
  3328.     AstBreakStatement *p = ast_pool -> NewBreakStatement();
  3329.     p -> break_token          = Token(1);
  3330.     p -> identifier_token_opt = 0;
  3331.     p -> semicolon_token      = Token(2);
  3332.     Sym(1) = p;
  3333. }
  3334. ./
  3335.  
  3336. BreakStatement ::= 'break' 'Identifier' ';'
  3337. \:$action:\
  3338. /.$location
  3339. void Parser::Act$rule_number(void)
  3340. {
  3341.     AstBreakStatement *p = ast_pool -> NewBreakStatement();
  3342.     p -> break_token          = Token(1);
  3343.     p -> identifier_token_opt = Token(2);
  3344.     p -> semicolon_token      = Token(3);
  3345.     Sym(1) = p;
  3346. }
  3347. ./
  3348.  
  3349. ContinueStatement ::= 'continue' ';'
  3350. \:$action:\
  3351. /.$location
  3352. void Parser::Act$rule_number(void)
  3353. {
  3354.     AstContinueStatement *p = ast_pool -> NewContinueStatement();
  3355.     p -> continue_token       = Token(1);
  3356.     p -> identifier_token_opt = 0;
  3357.     p -> semicolon_token      = Token(2);
  3358.     Sym(1) = p;
  3359. }
  3360. ./
  3361.  
  3362. ContinueStatement ::= 'continue' 'Identifier' ';'
  3363. \:$action:\
  3364. /.$location
  3365. void Parser::Act$rule_number(void)
  3366. {
  3367.     AstContinueStatement *p = ast_pool -> NewContinueStatement();
  3368.     p -> continue_token       = Token(1);
  3369.     p -> identifier_token_opt = Token(2);
  3370.     p -> semicolon_token      = Token(3);
  3371.     Sym(1) = p;
  3372. }
  3373. ./
  3374.  
  3375. ReturnStatement ::= 'return' Expressionopt ';'
  3376. \:$action:\
  3377. /.$location
  3378. void Parser::Act$rule_number(void)
  3379. {
  3380.     AstReturnStatement *p = ast_pool -> NewReturnStatement();
  3381.     p -> return_token    = Token(1);
  3382.     p -> expression_opt  = (AstExpression *) Sym(2);
  3383.     p -> semicolon_token = Token(3);
  3384.     Sym(1) = p;
  3385. }
  3386. ./
  3387.  
  3388. ThrowStatement ::= 'throw' Expression ';'
  3389. \:$action:\
  3390. /.$location
  3391. void Parser::Act$rule_number(void)
  3392. {
  3393.     AstThrowStatement *p = ast_pool -> NewThrowStatement();
  3394.     p -> throw_token     = Token(1);
  3395.     p -> expression      = (AstExpression *) Sym(2);
  3396.     p -> semicolon_token = Token(3);
  3397.     Sym(1) = p;
  3398. }
  3399. ./
  3400.  
  3401. SynchronizedStatement ::= 'synchronized' '(' Expression ')' Block
  3402. \:$action:\
  3403. /.$location
  3404. void Parser::Act$rule_number(void)
  3405. {
  3406.     AstSynchronizedStatement *p = ast_pool -> NewSynchronizedStatement();
  3407.     p -> synchronized_token = Token(1);
  3408.     p -> expression         = (AstExpression *) Sym(3);
  3409.     p -> block              = (AstBlock *) Sym(5);
  3410.     p -> block -> block_tag = AstBlock::SYNCHRONIZED;
  3411.  
  3412.     Sym(1) = p;
  3413. }
  3414. ./
  3415.  
  3416. TryStatement ::= 'try' Block Catches
  3417. \:$action:\
  3418. /.$location
  3419. void Parser::Act$rule_number(void)
  3420. {
  3421.     AstTryStatement *p = ast_pool -> NewTryStatement();
  3422.     p -> try_token          = Token(1);
  3423.     p -> block              = (AstBlock *) Sym(2);
  3424.  
  3425.     //
  3426.     // The list of modifiers is guaranteed not empty
  3427.     //
  3428.     {
  3429.         AstListNode *tail = (AstListNode *) Sym(3);
  3430.         p -> AllocateCatchClauses(tail -> index + 1);
  3431.         AstListNode *root = tail;
  3432.         do
  3433.         {
  3434.             root = root -> next;
  3435.             p -> AddCatchClause((AstCatchClause *) root -> element);
  3436.         } while(root != tail);
  3437.         FreeCircularList(tail);
  3438.     }
  3439.     p -> finally_clause_opt = NULL;
  3440.     Sym(1) = p;
  3441. }
  3442. ./
  3443.  
  3444. TryStatement ::= 'try' Block Catchesopt Finally
  3445. \:$action:\
  3446. /.$location
  3447. void Parser::Act$rule_number(void)
  3448. {
  3449.     AstTryStatement *p = ast_pool -> NewTryStatement();
  3450.     p -> try_token      = Token(1);
  3451.     p -> block          = (AstBlock *) Sym(2);
  3452.     p -> block -> block_tag = AstBlock::TRY_CLAUSE_WITH_FINALLY;
  3453.  
  3454.     if (Sym(3) != NULL)
  3455.     {
  3456.         AstListNode *tail = (AstListNode *) Sym(3);
  3457.         p -> AllocateCatchClauses(tail -> index + 1);
  3458.         AstListNode *root = tail;
  3459.         do
  3460.         {
  3461.             root = root -> next;
  3462.             p -> AddCatchClause((AstCatchClause *) root -> element);
  3463.         } while(root != tail);
  3464.         FreeCircularList(tail);
  3465.     }
  3466.  
  3467.     for (int i = 0; i < p -> NumCatchClauses(); i++)
  3468.         p -> CatchClause(i) -> block -> block_tag = AstBlock::TRY_CLAUSE_WITH_FINALLY;
  3469.  
  3470.     p -> finally_clause_opt = (AstFinallyClause *) Sym(4);
  3471.  
  3472.     Sym(1) = p;
  3473. }
  3474. ./
  3475.  
  3476. Catches ::= CatchClause
  3477. \:$action:\
  3478. /.$location
  3479. //
  3480. // Note that the list is circular so as to preserve the order of the elements
  3481. //
  3482. void Parser::Act$rule_number(void)
  3483. {
  3484.     AstListNode *p = AllocateListNode();
  3485.     p -> next = p;
  3486.     p -> element = Sym(1);
  3487.     p -> index = 0;
  3488.  
  3489.     Sym(1) = p;
  3490. }
  3491. ./
  3492.  
  3493. Catches ::= Catches CatchClause
  3494. \:$action:\
  3495. /.$location
  3496. //
  3497. // Note that the list is circular so as to preserve the order of the elements
  3498. //
  3499. void Parser::Act$rule_number(void)
  3500. {
  3501.     AstListNode *tail = (AstListNode *) Sym(1);
  3502.  
  3503.     AstListNode *p = AllocateListNode();
  3504.     p -> element = Sym(2);
  3505.     p -> index = tail -> index + 1;
  3506.  
  3507.     p -> next = tail -> next;
  3508.     tail -> next = p;
  3509.  
  3510.     Sym(1) = p;
  3511. }
  3512. ./
  3513.  
  3514. CatchClause ::= 'catch' '(' FormalParameter ')' Block
  3515. \:$action:\
  3516. /.$location
  3517. void Parser::Act$rule_number(void)
  3518. {
  3519.     AstCatchClause *p = ast_pool -> NewCatchClause();
  3520.     p -> catch_token      = Token(1);
  3521.     p -> formal_parameter = (AstFormalParameter *) Sym(3);
  3522.     p -> block            = (AstBlock *) Sym(5);
  3523.  
  3524.     Sym(1) = p;
  3525. }
  3526. ./
  3527.  
  3528. Finally ::= 'finally' Block
  3529. \:$action:\
  3530. /.$location
  3531. void Parser::Act$rule_number(void)
  3532. {
  3533.     AstFinallyClause *p     = ast_pool -> NewFinallyClause();
  3534.     p -> finally_token      = Token(1);
  3535.     p -> block              = (AstBlock *) Sym(2);
  3536.     p -> block -> block_tag = AstBlock::FINALLY;
  3537.  
  3538.     Sym(1) = p;
  3539. }
  3540. ./
  3541.  
  3542. --18.12 Productions from 14: Expressions
  3543.  
  3544. Primary -> PrimaryNoNewArray
  3545. \:$NoAction:\
  3546. /.$shared_NoAction./
  3547.  
  3548. Primary -> ArrayCreationExpression
  3549. \:$NoAction:\
  3550. /.$shared_NoAction./
  3551.  
  3552. PrimaryNoNewArray -> Literal
  3553. \:$NoAction:\
  3554. /.$shared_NoAction./
  3555.  
  3556. PrimaryNoNewArray ::= this
  3557. \:$action:\
  3558. /.$location
  3559. void Parser::Act$rule_number(void)
  3560. {
  3561.     Sym(1) = ast_pool -> NewThisExpression(Token(1));
  3562. }
  3563. ./
  3564.  
  3565. PrimaryNoNewArray ::= '(' Expression ')'
  3566. \:$action:\
  3567. /.$location
  3568. void Parser::Act$rule_number(void)
  3569. {
  3570.     AstParenthesizedExpression *p = ast_pool -> NewParenthesizedExpression();
  3571.     p -> left_parenthesis_token = Token(1);
  3572.     p -> expression = (AstExpression *) Sym(2);
  3573.     p -> right_parenthesis_token = Token(3);
  3574.     Sym(1) = p;
  3575. }
  3576. ./
  3577.  
  3578. PrimaryNoNewArray -> ClassInstanceCreationExpression
  3579. \:$NoAction:\
  3580. /.$shared_NoAction./
  3581.  
  3582. PrimaryNoNewArray -> FieldAccess
  3583. \:$NoAction:\
  3584. /.$shared_NoAction./
  3585.  
  3586. --1.1 feature
  3587. PrimaryNoNewArray ::= Name '.' 'this'
  3588. \:$action:\
  3589. /.$location
  3590. void Parser::Act$rule_number(void)
  3591. {
  3592.     AstFieldAccess *p = ast_pool -> NewFieldAccess(AstFieldAccess::THIS_TAG);
  3593.     p -> base = (AstExpression *) Sym(1);
  3594.     p -> dot_token = Token(2);
  3595.     p -> identifier_token = Token(3);
  3596.     Sym(1) = p;
  3597. }
  3598. ./
  3599.  
  3600. --1.1 feature
  3601. PrimaryNoNewArray ::= Type '.' 'class'
  3602. \:$action:\
  3603. /.$location
  3604. void Parser::Act$rule_number(void)
  3605. {
  3606.     AstFieldAccess *p = ast_pool -> NewFieldAccess(AstFieldAccess::CLASS_TAG);
  3607.     p -> base = ast_pool -> NewTypeExpression(Sym(1));
  3608.     p -> dot_token = Token(2);
  3609.     p -> identifier_token = Token(3);
  3610.     Sym(1) = p;
  3611. }
  3612. ./
  3613.  
  3614. --1.1 feature
  3615. PrimaryNoNewArray ::= 'void' '.' 'class'
  3616. \:$action:\
  3617. /.$location
  3618. void Parser::Act$rule_number(void)
  3619. {
  3620.     AstFieldAccess *p = ast_pool -> NewFieldAccess(AstFieldAccess::CLASS_TAG);
  3621.     p -> base = ast_pool -> NewTypeExpression(ast_pool -> NewPrimitiveType(Ast::VOID_TYPE, Token(1)));
  3622.     p -> dot_token = Token(2);
  3623.     p -> identifier_token = Token(3);
  3624.     Sym(1) = p;
  3625. }
  3626. ./
  3627.  
  3628. PrimaryNoNewArray -> MethodInvocation
  3629. \:$NoAction:\
  3630. /.$shared_NoAction./
  3631.  
  3632. PrimaryNoNewArray -> ArrayAccess
  3633. \:$NoAction:\
  3634. /.$shared_NoAction./
  3635.  
  3636. --1.1 feature
  3637. --
  3638. -- In Java 1.0 a ClassBody could not appear at all in a
  3639. -- ClassInstanceCreationExpression.
  3640. --
  3641. ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
  3642. \:$action:\
  3643. /.$location
  3644. void Parser::Act$rule_number(void)
  3645. {
  3646.     AstClassInstanceCreationExpression *p = ast_pool -> NewClassInstanceCreationExpression();
  3647.     p -> base_opt                = NULL;
  3648.     p -> dot_token_opt           = 0;
  3649.     p -> new_token               = Token(1);
  3650.     p -> class_type              = ast_pool -> NewTypeExpression(Sym(2));
  3651.     p -> left_parenthesis_token  = Token(3);
  3652.     if (Sym(4) != NULL)
  3653.     {
  3654.         AstListNode *tail = (AstListNode *) Sym(4);
  3655.         p -> AllocateArguments(tail -> index + 1);
  3656.         AstListNode *root = tail;
  3657.         do
  3658.         {
  3659.             root = root -> next;
  3660.             p -> AddArgument((AstExpression *) root -> element);
  3661.         } while(root != tail);
  3662.         FreeCircularList(tail);
  3663.     }
  3664.     p -> right_parenthesis_token = Token(5);
  3665.     p -> class_body_opt          = (AstClassBody *) Sym(6);
  3666.     Sym(1) = p;
  3667. }
  3668. ./
  3669.  
  3670. --1.1 feature
  3671. ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
  3672. \:$MakeQualifiedNew:\
  3673. /.$location
  3674. void Parser::MakeQualifiedNew(void)
  3675. {
  3676.     AstClassInstanceCreationExpression *p = ast_pool -> NewClassInstanceCreationExpression();
  3677.     p -> base_opt                = (AstExpression *) Sym(1);
  3678.     p -> dot_token_opt           = Token(2);
  3679.     p -> new_token               = Token(3);
  3680.     p -> class_type              = ast_pool -> NewTypeExpression(Sym(4));
  3681.     p -> left_parenthesis_token  = Token(5);
  3682.     if (Sym(6) != NULL)
  3683.     {
  3684.         AstListNode *tail = (AstListNode *) Sym(6);
  3685.         p -> AllocateArguments(tail -> index + 1);
  3686.         AstListNode *root = tail;
  3687.         do
  3688.         {
  3689.             root = root -> next;
  3690.             p -> AddArgument((AstExpression *) root -> element);
  3691.         } while(root != tail);
  3692.         FreeCircularList(tail);
  3693.     }
  3694.     p -> right_parenthesis_token = Token(7);
  3695.     p -> class_body_opt          = (AstClassBody *) Sym(8);
  3696.     Sym(1) = p;
  3697. }
  3698. ./
  3699.  
  3700. --1.1 feature
  3701. ClassInstanceCreationExpression ::= Name '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
  3702. \:$MakeQualifiedNew:\
  3703. /.$shared_function
  3704. //
  3705. // void MakeQualifiedNew(void);
  3706. //./
  3707.  
  3708. ArgumentList ::= Expression
  3709. \:$action:\
  3710. /.$location
  3711. //
  3712. // Note that the list is circular so as to preserve the order of the elements
  3713. //
  3714. void Parser::Act$rule_number(void)
  3715. {
  3716.     AstListNode *p = AllocateListNode();
  3717.     p -> next = p;
  3718.     p -> element = Sym(1);
  3719.     p -> index = 0;
  3720.  
  3721.     Sym(1) = p;
  3722. }
  3723. ./
  3724.  
  3725. ArgumentList ::= ArgumentList ',' Expression
  3726. \:$action:\
  3727. /.$location
  3728. //
  3729. // Note that the list is circular so as to preserve the order of the elements
  3730. //
  3731. void Parser::Act$rule_number(void)
  3732. {
  3733.     AstListNode *tail = (AstListNode *) Sym(1);
  3734.  
  3735.     AstListNode *p = AllocateListNode();
  3736.     p -> element = Sym(3);
  3737.     p -> index = tail -> index + 1;
  3738.  
  3739.     p -> next = tail -> next;
  3740.     tail -> next = p;
  3741.  
  3742.     Sym(1) = p;
  3743. }
  3744. ./
  3745.  
  3746. ArrayCreationExpression ::= 'new' PrimitiveType DimExprs Dimsopt
  3747. \:$MakeArrayCreationExpression:\
  3748. /.$location
  3749. void Parser::MakeArrayCreationExpression(void)
  3750. {
  3751.     AstArrayCreationExpression *p = ast_pool -> NewArrayCreationExpression();
  3752.     p -> new_token             = Token(1);
  3753.     p -> array_type            = Sym(2);
  3754.     //
  3755.     // The list of DimExprs is never null
  3756.     //
  3757.     {
  3758.         AstListNode *tail = (AstListNode *) Sym(3);
  3759.         p -> AllocateDimExprs(tail -> index + 1);
  3760.         AstListNode *root = tail;
  3761.         do
  3762.         {
  3763.             root = root -> next;
  3764.             p -> AddDimExpr((AstDimExpr *) root -> element);
  3765.         } while(root != tail);
  3766.         FreeCircularList(tail);
  3767.     }
  3768.  
  3769.     if (Sym(4) != NULL)
  3770.     {
  3771.         AstListNode *tail = (AstListNode *) Sym(4);
  3772.         p -> AllocateBrackets(tail -> index + 1);
  3773.         AstListNode *root = tail;
  3774.         do
  3775.         {
  3776.             root = root -> next;
  3777.             p -> AddBrackets((AstBrackets *) root -> element);
  3778.         } while(root != tail);
  3779.         FreeCircularList(tail);
  3780.     }
  3781.     p -> array_initializer_opt = NULL;
  3782.     Sym(1) = p;
  3783. }
  3784. ./
  3785.  
  3786. ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimExprs Dimsopt
  3787. \:$MakeArrayCreationExpression:\
  3788. /.$shared_function
  3789. //
  3790. // void MakeArrayCreationExpression(void);
  3791. //./
  3792.  
  3793. --1.1 feature
  3794. ArrayCreationExpression ::= 'new' ArrayType ArrayInitializer
  3795. \:$action:\
  3796. /.$location
  3797. void Parser::Act$rule_number(void)
  3798. {
  3799.     AstArrayCreationExpression *p = ast_pool -> NewArrayCreationExpression();
  3800.     p -> new_token             = Token(1);
  3801.     p -> array_type            = Sym(2);
  3802.     p -> array_initializer_opt = (AstArrayInitializer *) Sym(3);
  3803.     Sym(1) = p;
  3804. }
  3805. ./
  3806.  
  3807. DimExprs ::= DimExpr
  3808. \:$action:\
  3809. /.$location
  3810. //
  3811. // Note that the list is circular so as to preserve the order of the elements
  3812. //
  3813. void Parser::Act$rule_number(void)
  3814. {
  3815.     AstListNode *p = AllocateListNode();
  3816.     p -> next = p;
  3817.     p -> element = Sym(1);
  3818.     p -> index = 0;
  3819.  
  3820.     Sym(1) = p;
  3821. }
  3822. ./
  3823.  
  3824. DimExprs ::= DimExprs DimExpr
  3825. \:$action:\
  3826. /.$location
  3827. //
  3828. // Note that the list is circular so as to preserve the order of the elements
  3829. //
  3830. void Parser::Act$rule_number(void)
  3831. {
  3832.     AstListNode *tail = (AstListNode *) Sym(1);
  3833.  
  3834.     AstListNode *p = AllocateListNode();
  3835.     p -> element = Sym(2);
  3836.     p -> index = tail -> index + 1;
  3837.  
  3838.     p -> next = tail -> next;
  3839.     tail -> next = p;
  3840.  
  3841.     Sym(1) = p;
  3842. }
  3843. ./
  3844.  
  3845. DimExpr ::= '[' Expression ']'
  3846. \:$action:\
  3847. /.$location
  3848. void Parser::Act$rule_number(void)
  3849. {
  3850.     AstDimExpr *p = ast_pool -> NewDimExpr();
  3851.     p -> left_bracket_token  = Token(1);
  3852.     p -> expression          = (AstExpression *) Sym(2);
  3853.     p -> right_bracket_token = Token(3);
  3854.     Sym(1) = p;
  3855. }
  3856. ./
  3857.  
  3858. Dims ::= '[' ']'
  3859. \:$action:\
  3860. /.$location
  3861. //
  3862. // Note that the list is circular so as to preserve the order of the elements
  3863. //
  3864. void Parser::Act$rule_number(void)
  3865. {
  3866.     AstListNode *p = AllocateListNode();
  3867.     p -> next = p;
  3868.     p -> element = ast_pool -> NewBrackets(Token(1), Token(2));
  3869.     p -> index = 0;
  3870.  
  3871.     Sym(1) = p;
  3872. }
  3873. ./
  3874.  
  3875. Dims ::= Dims '[' ']'
  3876. \:$action:\
  3877. /.$location
  3878. //
  3879. // Note that the list is circular so as to preserve the order of the elements
  3880. //
  3881. void Parser::Act$rule_number(void)
  3882. {
  3883.     AstListNode *tail = (AstListNode *) Sym(1);
  3884.  
  3885.     AstListNode *p = AllocateListNode();
  3886.     p -> element = ast_pool -> NewBrackets(Token(2), Token(3));
  3887.     p -> index = tail -> index + 1;
  3888.  
  3889.     p -> next = tail -> next;
  3890.     tail -> next = p;
  3891.  
  3892.     Sym(1) = p;
  3893. }
  3894. ./
  3895.  
  3896. FieldAccess ::= Primary '.' 'Identifier'
  3897. \:$MakeFieldAccess:\
  3898. /.$shared_function
  3899. //
  3900. // void MakeFieldAccess(void);
  3901. //./
  3902.  
  3903. FieldAccess ::= 'super' '.' 'Identifier'
  3904. \:$MakeSuperFieldAccess:\
  3905. /.$location
  3906. void Parser::MakeSuperFieldAccess(void)
  3907. {
  3908.     Sym(1) = ast_pool -> NewSuperExpression(Token(1));
  3909.  
  3910.     MakeFieldAccess();
  3911. }
  3912. ./
  3913.  
  3914. --1.2 feature
  3915. FieldAccess ::= Name '.' 'super' '.' 'Identifier'
  3916. \:$MakeSuperDoubleFieldAccess:\
  3917. /.$location
  3918. void Parser::MakeSuperDoubleFieldAccess(void)
  3919. {
  3920.     AstFieldAccess *p = ast_pool -> NewFieldAccess();
  3921.  
  3922.          AstFieldAccess *q = ast_pool -> NewFieldAccess(AstFieldAccess::SUPER_TAG);
  3923.          q -> base = (AstExpression *) Sym(1);
  3924.          q -> dot_token = Token(2);
  3925.          q -> identifier_token = Token(3);
  3926.  
  3927.     p -> base = q;
  3928.     p -> dot_token = Token(4);
  3929.     p -> identifier_token = Token(5);
  3930.  
  3931.     Sym(1) = p;
  3932. }
  3933. ./
  3934.  
  3935. MethodInvocation ::= Name '(' ArgumentListopt ')'
  3936. \:$action:\
  3937. /.$location
  3938. void Parser::Act$rule_number(void)
  3939. {
  3940.     AstMethodInvocation *p = ast_pool -> NewMethodInvocation();
  3941.     p -> method                  = (AstExpression *) Sym(1);
  3942.     p -> left_parenthesis_token  = Token(2);
  3943.     if (Sym(3) != NULL)
  3944.     {
  3945.         AstListNode *tail = (AstListNode *) Sym(3);
  3946.         p -> AllocateArguments(tail -> index + 1);
  3947.         AstListNode *root = tail;
  3948.         do
  3949.         {
  3950.             root = root -> next;
  3951.             p -> AddArgument((AstExpression *) root -> element);
  3952.         } while(root != tail);
  3953.         FreeCircularList(tail);
  3954.     }
  3955.     p -> right_parenthesis_token = Token(4);
  3956.     Sym(1) = p;
  3957. }
  3958. ./
  3959.  
  3960. MethodInvocation ::= Primary '.' 'Identifier' '(' ArgumentListopt ')'
  3961. \:$action:\
  3962. /.$location
  3963. void Parser::Act$rule_number(void)
  3964. {
  3965.     MakeFieldAccess();
  3966.  
  3967.     AstMethodInvocation *p = ast_pool -> NewMethodInvocation();
  3968.     p -> method                  = (AstExpression *) Sym(1);
  3969.     p -> left_parenthesis_token  = Token(4);
  3970.     if (Sym(5) != NULL)
  3971.     {
  3972.         AstListNode *tail = (AstListNode *) Sym(5);
  3973.         p -> AllocateArguments(tail -> index + 1);
  3974.         AstListNode *root = tail;
  3975.         do
  3976.         {
  3977.             root = root -> next;
  3978.             p -> AddArgument((AstExpression *) root -> element);
  3979.         } while(root != tail);
  3980.         FreeCircularList(tail);
  3981.     }
  3982.     p -> right_parenthesis_token = Token(6);
  3983.     Sym(1) = p;
  3984. }
  3985. ./
  3986.  
  3987. MethodInvocation ::= 'super' '.' 'Identifier' '(' ArgumentListopt ')'
  3988. \:$action:\
  3989. /.$location
  3990. void Parser::Act$rule_number(void)
  3991. {
  3992.     MakeSuperFieldAccess();
  3993.  
  3994.     AstMethodInvocation *p = ast_pool -> NewMethodInvocation();
  3995.     p -> method                  = (AstExpression *) Sym(1);
  3996.     p -> left_parenthesis_token  = Token(4);
  3997.     if (Sym(5) != NULL)
  3998.     {
  3999.         AstListNode *tail = (AstListNode *) Sym(5);
  4000.         p -> AllocateArguments(tail -> index + 1);
  4001.         AstListNode *root = tail;
  4002.         do
  4003.         {
  4004.             root = root -> next;
  4005.             p -> AddArgument((AstExpression *) root -> element);
  4006.         } while(root != tail);
  4007.         FreeCircularList(tail);
  4008.     }
  4009.     p -> right_parenthesis_token = Token(6);
  4010.     Sym(1) = p;
  4011. }
  4012. ./
  4013.  
  4014. --1.2 feature
  4015. MethodInvocation ::= Name '.' 'super' '.' 'Identifier' '(' ArgumentListopt ')'
  4016. \:$action:\
  4017. /.$location
  4018. void Parser::Act$rule_number(void)
  4019. {
  4020.     MakeSuperDoubleFieldAccess();
  4021.  
  4022.     AstMethodInvocation *p = ast_pool -> NewMethodInvocation();
  4023.     p -> method                  = (AstExpression *) Sym(1);
  4024.     p -> left_parenthesis_token  = Token(6);
  4025.     if (Sym(7) != NULL)
  4026.     {
  4027.         AstListNode *tail = (AstListNode *) Sym(7);
  4028.         p -> AllocateArguments(tail -> index + 1);
  4029.         AstListNode *root = tail;
  4030.         do
  4031.         {
  4032.             root = root -> next;
  4033.             p -> AddArgument((AstExpression *) root -> element);
  4034.         } while(root != tail);
  4035.         FreeCircularList(tail);
  4036.     }
  4037.     p -> right_parenthesis_token = Token(8);
  4038.     Sym(1) = p;
  4039. }
  4040. ./
  4041.  
  4042. ArrayAccess ::= Name '[' Expression ']'
  4043. \:$MakeArrayAccess:\
  4044. /.$location
  4045. void Parser::MakeArrayAccess(void)
  4046. {
  4047.     AstArrayAccess *p = ast_pool -> NewArrayAccess();
  4048.     p -> base                = (AstExpression *) Sym(1);
  4049.     p -> left_bracket_token  = Token(2);
  4050.     p -> expression          = (AstExpression *) Sym(3);
  4051.     p -> right_bracket_token = Token(4);
  4052.     Sym(1) = p;
  4053. }
  4054. ./
  4055.  
  4056. ArrayAccess ::= PrimaryNoNewArray '[' Expression ']'
  4057. \:$MakeArrayAccess:\
  4058. /.$shared_function
  4059. //
  4060. // void MakeArrayAccess(void);
  4061. //./
  4062.  
  4063. PostfixExpression -> Primary
  4064. \:$NoAction:\
  4065. /.$shared_NoAction./
  4066.  
  4067. PostfixExpression -> Name
  4068. \:$NoAction:\
  4069. /.$shared_NoAction./
  4070.  
  4071. PostfixExpression -> PostIncrementExpression
  4072. \:$NoAction:\
  4073. /.$shared_NoAction./
  4074.  
  4075. PostfixExpression -> PostDecrementExpression
  4076. \:$NoAction:\
  4077. /.$shared_NoAction./
  4078.  
  4079. PostIncrementExpression ::= PostfixExpression '++'
  4080. \:$action:\
  4081. /.$location
  4082. void Parser::Act$rule_number(void)
  4083. {
  4084.     AstPostUnaryExpression *p = ast_pool -> NewPostUnaryExpression(AstPostUnaryExpression::PLUSPLUS);
  4085.     p -> expression          = (AstExpression *) Sym(1);
  4086.     p -> post_operator_token = Token(2);
  4087.     Sym(1) = p;
  4088. }
  4089. ./
  4090.  
  4091. PostDecrementExpression ::= PostfixExpression '--'
  4092. \:$action:\
  4093. /.$location
  4094. void Parser::Act$rule_number(void)
  4095. {
  4096.     AstPostUnaryExpression *p = ast_pool -> NewPostUnaryExpression(AstPostUnaryExpression::MINUSMINUS);
  4097.     p -> expression          = (AstExpression *) Sym(1);
  4098.     p -> post_operator_token = Token(2);
  4099.     Sym(1) = p;
  4100. }
  4101. ./
  4102.  
  4103. UnaryExpression -> PreIncrementExpression
  4104. \:$NoAction:\
  4105. /.$shared_NoAction./
  4106.  
  4107. UnaryExpression -> PreDecrementExpression
  4108. \:$NoAction:\
  4109. /.$shared_NoAction./
  4110.  
  4111. UnaryExpression ::= '+' UnaryExpression
  4112. \:$action:\
  4113. /.$location
  4114. void Parser::Act$rule_number(void)
  4115. {
  4116.     AstPreUnaryExpression *p = ast_pool -> NewPreUnaryExpression(AstPreUnaryExpression::PLUS);
  4117.     p -> pre_operator_token = Token(1);
  4118.     p -> expression         = (AstExpression *) Sym(2);
  4119.     Sym(1) = p;
  4120. }
  4121. ./
  4122.  
  4123. UnaryExpression ::= '-' UnaryExpression
  4124. \:$action:\
  4125. /.$location
  4126. void Parser::Act$rule_number(void)
  4127. {
  4128.     AstPreUnaryExpression *p = ast_pool -> NewPreUnaryExpression(AstPreUnaryExpression::MINUS);
  4129.     p -> pre_operator_token = Token(1);
  4130.     p -> expression         = (AstExpression *) Sym(2);
  4131.     Sym(1) = p;
  4132. }
  4133. ./
  4134.  
  4135. UnaryExpression -> UnaryExpressionNotPlusMinus
  4136. \:$NoAction:\
  4137. /.$shared_NoAction./
  4138.  
  4139. PreIncrementExpression ::= '++' UnaryExpression
  4140. \:$action:\
  4141. /.$location
  4142. void Parser::Act$rule_number(void)
  4143. {
  4144.     AstPreUnaryExpression *p = ast_pool -> NewPreUnaryExpression(AstPreUnaryExpression::PLUSPLUS);
  4145.     p -> pre_operator_token = Token(1);
  4146.     p -> expression         = (AstExpression *) Sym(2);
  4147.     Sym(1) = p;
  4148. }
  4149. ./
  4150.  
  4151. PreDecrementExpression ::= '--' UnaryExpression
  4152. \:$action:\
  4153. /.$location
  4154. void Parser::Act$rule_number(void)
  4155. {
  4156.     AstPreUnaryExpression *p = ast_pool -> NewPreUnaryExpression(AstPreUnaryExpression::MINUSMINUS);
  4157.     p -> pre_operator_token = Token(1);
  4158.     p -> expression         = (AstExpression *) Sym(2);
  4159.     Sym(1) = p;
  4160. }
  4161. ./
  4162.  
  4163. UnaryExpressionNotPlusMinus -> PostfixExpression
  4164. \:$NoAction:\
  4165. /.$shared_NoAction./
  4166.  
  4167. UnaryExpressionNotPlusMinus ::= '~' UnaryExpression
  4168. \:$action:\
  4169. /.$location
  4170. void Parser::Act$rule_number(void)
  4171. {
  4172.     AstPreUnaryExpression *p = ast_pool -> NewPreUnaryExpression(AstPreUnaryExpression::TWIDDLE);
  4173.     p -> pre_operator_token = Token(1);
  4174.     p -> expression         = (AstExpression *) Sym(2);
  4175.     Sym(1) = p;
  4176. }
  4177. ./
  4178.  
  4179. UnaryExpressionNotPlusMinus ::= '!' UnaryExpression
  4180. \:$action:\
  4181. /.$location
  4182. void Parser::Act$rule_number(void)
  4183. {
  4184.     AstPreUnaryExpression *p = ast_pool -> NewPreUnaryExpression(AstPreUnaryExpression::NOT);
  4185.     p -> pre_operator_token = Token(1);
  4186.     p -> expression         = (AstExpression *) Sym(2);
  4187.     Sym(1) = p;
  4188. }
  4189. ./
  4190.  
  4191. UnaryExpressionNotPlusMinus -> CastExpression
  4192. \:$NoAction:\
  4193. /.$shared_NoAction./
  4194.  
  4195. CastExpression ::= '(' PrimitiveType Dimsopt ')' UnaryExpression
  4196. \:$MakeCastExpression:\
  4197. /.$location
  4198. void Parser::MakeCastExpression(void)
  4199. {
  4200.     AstCastExpression *p = ast_pool -> NewCastExpression();
  4201.     p -> left_parenthesis_token_opt  = Token(1);
  4202.     p -> type_opt                    = Sym(2);
  4203.     if (Sym(3) != NULL)
  4204.     {
  4205.         AstListNode *tail = (AstListNode *) Sym(3);
  4206.         p -> AllocateBrackets(tail -> index + 1);
  4207.         AstListNode *root = tail;
  4208.         do
  4209.         {
  4210.             root = root -> next;
  4211.             p -> AddBrackets((AstBrackets *) root -> element);
  4212.         } while(root != tail);
  4213.         FreeCircularList(tail);
  4214.     }
  4215.     p -> right_parenthesis_token_opt = Token(4);
  4216.     p -> expression                  = (AstExpression *) Sym(5);
  4217.     Sym(1) = p;
  4218. }
  4219. ./
  4220.  
  4221. CastExpression ::= '(' Expression ')' UnaryExpressionNotPlusMinus
  4222. \:$action:\
  4223. /.$location
  4224. void Parser::Act$rule_number(void)
  4225. {
  4226.     //
  4227.     // Note that Expression must be a name - i.e., Sym(2) -> isName() == true
  4228.     // This check is not performed here and should be performed during
  4229.     // semantic processing.
  4230.     //
  4231.     AstCastExpression *p = ast_pool -> NewCastExpression();
  4232.     p -> left_parenthesis_token_opt  = Token(1);
  4233.     p -> type_opt                    = Sym(2);
  4234.     p -> right_parenthesis_token_opt = Token(3);
  4235.     p -> expression                  = (AstExpression *) Sym(4);
  4236.     Sym(1) = p;
  4237. }
  4238. ./
  4239.  
  4240. CastExpression ::= '(' Name Dims ')' UnaryExpressionNotPlusMinus
  4241. \:$MakeCastExpression:\
  4242. /.$shared_function
  4243. //
  4244. // void MakeCastExpression(void);
  4245. //./
  4246.  
  4247. MultiplicativeExpression -> UnaryExpression
  4248. \:$NoAction:\
  4249. /.$shared_NoAction./
  4250.  
  4251. MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression
  4252. \:$action:\
  4253. /.$location
  4254. void Parser::Act$rule_number(void)
  4255. {
  4256.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::STAR);
  4257.     p -> left_expression       = (AstExpression *) Sym(1);
  4258.     p -> binary_operator_token = Token(2);
  4259.     p -> right_expression      = (AstExpression *) Sym(3);
  4260.     Sym(1) = p;
  4261. }
  4262. ./
  4263.  
  4264. MultiplicativeExpression ::= MultiplicativeExpression '/' UnaryExpression
  4265. \:$action:\
  4266. /.$location
  4267. void Parser::Act$rule_number(void)
  4268. {
  4269.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::SLASH);
  4270.     p -> left_expression       = (AstExpression *) Sym(1);
  4271.     p -> binary_operator_token = Token(2);
  4272.     p -> right_expression      = (AstExpression *) Sym(3);
  4273.     Sym(1) = p;
  4274. }
  4275. ./
  4276.  
  4277. MultiplicativeExpression ::= MultiplicativeExpression '%' UnaryExpression
  4278. \:$action:\
  4279. /.$location
  4280. void Parser::Act$rule_number(void)
  4281. {
  4282.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::MOD);
  4283.     p -> left_expression       = (AstExpression *) Sym(1);
  4284.     p -> binary_operator_token = Token(2);
  4285.     p -> right_expression      = (AstExpression *) Sym(3);
  4286.     Sym(1) = p;
  4287. }
  4288. ./
  4289.  
  4290. AdditiveExpression -> MultiplicativeExpression
  4291. \:$NoAction:\
  4292. /.$shared_NoAction./
  4293.  
  4294. AdditiveExpression ::= AdditiveExpression '+' MultiplicativeExpression
  4295. \:$action:\
  4296. /.$location
  4297. void Parser::Act$rule_number(void)
  4298. {
  4299.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::PLUS);
  4300.     p -> left_expression       = (AstExpression *) Sym(1);
  4301.     p -> binary_operator_token = Token(2);
  4302.     p -> right_expression      = (AstExpression *) Sym(3);
  4303.     Sym(1) = p;
  4304. }
  4305. ./
  4306.  
  4307. AdditiveExpression ::= AdditiveExpression '-' MultiplicativeExpression
  4308. \:$action:\
  4309. /.$location
  4310. void Parser::Act$rule_number(void)
  4311. {
  4312.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::MINUS);
  4313.     p -> left_expression       = (AstExpression *) Sym(1);
  4314.     p -> binary_operator_token = Token(2);
  4315.     p -> right_expression      = (AstExpression *) Sym(3);
  4316.     Sym(1) = p;
  4317. }
  4318. ./
  4319.  
  4320. ShiftExpression -> AdditiveExpression
  4321. \:$NoAction:\
  4322. /.$shared_NoAction./
  4323.  
  4324. ShiftExpression ::= ShiftExpression '<<'  AdditiveExpression
  4325. \:$action:\
  4326. /.$location
  4327. void Parser::Act$rule_number(void)
  4328. {
  4329.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::LEFT_SHIFT);
  4330.     p -> left_expression       = (AstExpression *) Sym(1);
  4331.     p -> binary_operator_token = Token(2);
  4332.     p -> right_expression      = (AstExpression *) Sym(3);
  4333.     Sym(1) = p;
  4334. }
  4335. ./
  4336.  
  4337. ShiftExpression ::= ShiftExpression '>>'  AdditiveExpression
  4338. \:$action:\
  4339. /.$location
  4340. void Parser::Act$rule_number(void)
  4341. {
  4342.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::RIGHT_SHIFT);
  4343.     p -> left_expression       = (AstExpression *) Sym(1);
  4344.     p -> binary_operator_token = Token(2);
  4345.     p -> right_expression      = (AstExpression *) Sym(3);
  4346.     Sym(1) = p;
  4347. }
  4348. ./
  4349.  
  4350. ShiftExpression ::= ShiftExpression '>>>' AdditiveExpression
  4351. \:$action:\
  4352. /.$location
  4353. void Parser::Act$rule_number(void)
  4354. {
  4355.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::UNSIGNED_RIGHT_SHIFT);
  4356.     p -> left_expression       = (AstExpression *) Sym(1);
  4357.     p -> binary_operator_token = Token(2);
  4358.     p -> right_expression      = (AstExpression *) Sym(3);
  4359.     Sym(1) = p;
  4360. }
  4361. ./
  4362.  
  4363. RelationalExpression -> ShiftExpression
  4364. \:$NoAction:\
  4365. /.$shared_NoAction./
  4366.  
  4367. RelationalExpression ::= RelationalExpression '<'  ShiftExpression
  4368. \:$action:\
  4369. /.$location
  4370. void Parser::Act$rule_number(void)
  4371. {
  4372.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::LESS);
  4373.     p -> left_expression       = (AstExpression *) Sym(1);
  4374.     p -> binary_operator_token = Token(2);
  4375.     p -> right_expression      = (AstExpression *) Sym(3);
  4376.     Sym(1) = p;
  4377. }
  4378. ./
  4379.  
  4380. RelationalExpression ::= RelationalExpression '>'  ShiftExpression
  4381. \:$action:\
  4382. /.$location
  4383. void Parser::Act$rule_number(void)
  4384. {
  4385.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::GREATER);
  4386.     p -> left_expression       = (AstExpression *) Sym(1);
  4387.     p -> binary_operator_token = Token(2);
  4388.     p -> right_expression      = (AstExpression *) Sym(3);
  4389.     Sym(1) = p;
  4390. }
  4391. ./
  4392.  
  4393. RelationalExpression ::= RelationalExpression '<=' ShiftExpression
  4394. \:$action:\
  4395. /.$location
  4396. void Parser::Act$rule_number(void)
  4397. {
  4398.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::LESS_EQUAL);
  4399.     p -> left_expression       = (AstExpression *) Sym(1);
  4400.     p -> binary_operator_token = Token(2);
  4401.     p -> right_expression      = (AstExpression *) Sym(3);
  4402.     Sym(1) = p;
  4403. }
  4404. ./
  4405.  
  4406. RelationalExpression ::= RelationalExpression '>=' ShiftExpression
  4407. \:$action:\
  4408. /.$location
  4409. void Parser::Act$rule_number(void)
  4410. {
  4411.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::GREATER_EQUAL);
  4412.     p -> left_expression       = (AstExpression *) Sym(1);
  4413.     p -> binary_operator_token = Token(2);
  4414.     p -> right_expression      = (AstExpression *) Sym(3);
  4415.     Sym(1) = p;
  4416. }
  4417. ./
  4418.  
  4419. RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType
  4420. \:$action:\
  4421. /.$location
  4422. void Parser::Act$rule_number(void)
  4423. {
  4424.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::INSTANCEOF);
  4425.     p -> left_expression       = (AstExpression *) Sym(1);
  4426.     p -> binary_operator_token = Token(2);
  4427.     p -> right_expression      = ast_pool -> NewTypeExpression(Sym(3));
  4428.     Sym(1) = p;
  4429. }
  4430. ./
  4431.  
  4432. EqualityExpression -> RelationalExpression
  4433. \:$NoAction:\
  4434. /.$shared_NoAction./
  4435.  
  4436. EqualityExpression ::= EqualityExpression '==' RelationalExpression
  4437. \:$action:\
  4438. /.$location
  4439. void Parser::Act$rule_number(void)
  4440. {
  4441.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::EQUAL_EQUAL);
  4442.     p -> left_expression       = (AstExpression *) Sym(1);
  4443.     p -> binary_operator_token = Token(2);
  4444.     p -> right_expression      = (AstExpression *) Sym(3);
  4445.     Sym(1) = p;
  4446. }
  4447. ./
  4448.  
  4449. EqualityExpression ::= EqualityExpression '!=' RelationalExpression
  4450. \:$action:\
  4451. /.$location
  4452. void Parser::Act$rule_number(void)
  4453. {
  4454.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::NOT_EQUAL);
  4455.     p -> left_expression       = (AstExpression *) Sym(1);
  4456.     p -> binary_operator_token = Token(2);
  4457.     p -> right_expression      = (AstExpression *) Sym(3);
  4458.     Sym(1) = p;
  4459. }
  4460. ./
  4461.  
  4462.  
  4463. AndExpression -> EqualityExpression
  4464. \:$NoAction:\
  4465. /.$shared_NoAction./
  4466.  
  4467. AndExpression ::= AndExpression '&' EqualityExpression
  4468. \:$action:\
  4469. /.$location
  4470. void Parser::Act$rule_number(void)
  4471. {
  4472.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::AND);
  4473.     p -> left_expression       = (AstExpression *) Sym(1);
  4474.     p -> binary_operator_token = Token(2);
  4475.     p -> right_expression      = (AstExpression *) Sym(3);
  4476.     Sym(1) = p;
  4477. }
  4478. ./
  4479.  
  4480. ExclusiveOrExpression -> AndExpression
  4481. \:$NoAction:\
  4482. /.$shared_NoAction./
  4483.  
  4484. ExclusiveOrExpression ::= ExclusiveOrExpression '^' AndExpression
  4485. \:$action:\
  4486. /.$location
  4487. void Parser::Act$rule_number(void)
  4488. {
  4489.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::XOR);
  4490.     p -> left_expression       = (AstExpression *) Sym(1);
  4491.     p -> binary_operator_token = Token(2);
  4492.     p -> right_expression      = (AstExpression *) Sym(3);
  4493.     Sym(1) = p;
  4494. }
  4495. ./
  4496.  
  4497. InclusiveOrExpression -> ExclusiveOrExpression
  4498. \:$NoAction:\
  4499. /.$shared_NoAction./
  4500.  
  4501. InclusiveOrExpression ::= InclusiveOrExpression '|' ExclusiveOrExpression
  4502. \:$action:\
  4503. /.$location
  4504. void Parser::Act$rule_number(void)
  4505. {
  4506.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::IOR);
  4507.     p -> left_expression       = (AstExpression *) Sym(1);
  4508.     p -> binary_operator_token = Token(2);
  4509.     p -> right_expression      = (AstExpression *) Sym(3);
  4510.     Sym(1) = p;
  4511. }
  4512. ./
  4513.  
  4514. ConditionalAndExpression -> InclusiveOrExpression
  4515. \:$NoAction:\
  4516. /.$shared_NoAction./
  4517.  
  4518. ConditionalAndExpression ::= ConditionalAndExpression '&&' InclusiveOrExpression
  4519. \:$action:\
  4520. /.$location
  4521. void Parser::Act$rule_number(void)
  4522. {
  4523.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::AND_AND);
  4524.     p -> left_expression       = (AstExpression *) Sym(1);
  4525.     p -> binary_operator_token = Token(2);
  4526.     p -> right_expression      = (AstExpression *) Sym(3);
  4527.     Sym(1) = p;
  4528. }
  4529. ./
  4530.  
  4531. ConditionalOrExpression -> ConditionalAndExpression
  4532. \:$NoAction:\
  4533. /.$shared_NoAction./
  4534.  
  4535. ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpression
  4536. \:$action:\
  4537. /.$location
  4538. void Parser::Act$rule_number(void)
  4539. {
  4540.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::OR_OR);
  4541.     p -> left_expression       = (AstExpression *) Sym(1);
  4542.     p -> binary_operator_token = Token(2);
  4543.     p -> right_expression      = (AstExpression *) Sym(3);
  4544.     Sym(1) = p;
  4545. }
  4546. ./
  4547.  
  4548. ConditionalExpression -> ConditionalOrExpression
  4549. \:$NoAction:\
  4550. /.$shared_NoAction./
  4551.  
  4552. ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression
  4553. \:$action:\
  4554. /.$location
  4555. void Parser::Act$rule_number(void)
  4556. {
  4557.     AstConditionalExpression *p = ast_pool -> NewConditionalExpression();
  4558.     p -> test_expression  = (AstExpression *) Sym(1);
  4559.     p -> question_token   = Token(2);
  4560.     p -> true_expression  = (AstExpression *) Sym(3);
  4561.     p -> colon_token      = Token(4);
  4562.     p -> false_expression = (AstExpression *) Sym(5);
  4563.     Sym(1) = p;
  4564. }
  4565. ./
  4566.  
  4567. AssignmentExpression -> ConditionalExpression
  4568. \:$NoAction:\
  4569. /.$shared_NoAction./
  4570.  
  4571. AssignmentExpression -> Assignment
  4572. \:$NoAction:\
  4573. /.$shared_NoAction./
  4574.  
  4575. Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression
  4576. \:$action:\
  4577. /.$location
  4578. void Parser::Act$rule_number(void)
  4579. {
  4580.     AstAssignmentExpression *p = (AstAssignmentExpression *) Sym(2);
  4581.     p -> left_hand_side = (AstExpression *) Sym(1);
  4582.     p -> expression     = (AstExpression *) Sym(3);
  4583.     Sym(1) = p;
  4584. }
  4585. ./
  4586.  
  4587. LeftHandSide -> Name
  4588. \:$NoAction:\
  4589. /.$shared_NoAction./
  4590.  
  4591. LeftHandSide -> FieldAccess
  4592. \:$NoAction:\
  4593. /.$shared_NoAction./
  4594.  
  4595. LeftHandSide -> ArrayAccess
  4596. \:$NoAction:\
  4597. /.$shared_NoAction./
  4598.  
  4599. AssignmentOperator ::= '='
  4600. \:$action:\
  4601. /.$location
  4602. void Parser::Act$rule_number(void)
  4603. {
  4604.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::SIMPLE_EQUAL, Token(1));
  4605. }
  4606. ./
  4607.  
  4608. AssignmentOperator ::= '*='
  4609. \:$action:\
  4610. /.$location
  4611. void Parser::Act$rule_number(void)
  4612. {
  4613.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::STAR_EQUAL, Token(1));
  4614. }
  4615. ./
  4616.  
  4617. AssignmentOperator ::= '/='
  4618. \:$action:\
  4619. /.$location
  4620. void Parser::Act$rule_number(void)
  4621. {
  4622.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::SLASH_EQUAL, Token(1));
  4623. }
  4624. ./
  4625.  
  4626. AssignmentOperator ::= '%='
  4627. \:$action:\
  4628. /.$location
  4629. void Parser::Act$rule_number(void)
  4630. {
  4631.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::MOD_EQUAL, Token(1));
  4632. }
  4633. ./
  4634.  
  4635. AssignmentOperator ::= '+='
  4636. \:$action:\
  4637. /.$location
  4638. void Parser::Act$rule_number(void)
  4639. {
  4640.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::PLUS_EQUAL, Token(1));
  4641. }
  4642. ./
  4643.  
  4644. AssignmentOperator ::= '-='
  4645. \:$action:\
  4646. /.$location
  4647. void Parser::Act$rule_number(void)
  4648. {
  4649.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::MINUS_EQUAL, Token(1));
  4650. }
  4651. ./
  4652.  
  4653. AssignmentOperator ::= '<<='
  4654. \:$action:\
  4655. /.$location
  4656. void Parser::Act$rule_number(void)
  4657. {
  4658.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::LEFT_SHIFT_EQUAL, Token(1));
  4659. }
  4660. ./
  4661.  
  4662. AssignmentOperator ::= '>>='
  4663. \:$action:\
  4664. /.$location
  4665. void Parser::Act$rule_number(void)
  4666. {
  4667.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::RIGHT_SHIFT_EQUAL, Token(1));
  4668. }
  4669. ./
  4670.  
  4671. AssignmentOperator ::= '>>>='
  4672. \:$action:\
  4673. /.$location
  4674. void Parser::Act$rule_number(void)
  4675. {
  4676.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::UNSIGNED_RIGHT_SHIFT_EQUAL, Token(1));
  4677. }
  4678. ./
  4679.  
  4680. AssignmentOperator ::= '&='
  4681. \:$action:\
  4682. /.$location
  4683. void Parser::Act$rule_number(void)
  4684. {
  4685.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::AND_EQUAL, Token(1));
  4686. }
  4687. ./
  4688.  
  4689. AssignmentOperator ::= '^='
  4690. \:$action:\
  4691. /.$location
  4692. void Parser::Act$rule_number(void)
  4693. {
  4694.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::XOR_EQUAL, Token(1));
  4695. }
  4696. ./
  4697.  
  4698. AssignmentOperator ::= '|='
  4699. \:$action:\
  4700. /.$location
  4701. void Parser::Act$rule_number(void)
  4702. {
  4703.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::IOR_EQUAL, Token(1));
  4704. }
  4705. ./
  4706.  
  4707. Expression -> AssignmentExpression
  4708. \:$NoAction:\
  4709. /.$shared_NoAction./
  4710.  
  4711. ConstantExpression -> Expression
  4712. \:$NoAction:\
  4713. /.$shared_NoAction./
  4714.  
  4715. ---------------------------------------------------------------------------------------
  4716. --
  4717. -- The following rules are for optional nonterminals.
  4718. --
  4719. ---------------------------------------------------------------------------------------
  4720.  
  4721. PackageDeclarationopt ::= $empty
  4722. \:$NullAction:\
  4723. /.$location
  4724. //
  4725. // Given a rule of the form A ::= x1 x2 ... xn
  4726. //
  4727. // Construct a NULL Ast for A.
  4728. //
  4729. void Parser::NullAction(void) { Sym(1) = NULL; }
  4730. ./
  4731.  
  4732. PackageDeclarationopt -> PackageDeclaration
  4733. \:$NoAction:\
  4734. /.$shared_NoAction./
  4735.  
  4736. Superopt ::= $empty
  4737. \:$NullAction:\
  4738. /.$shared_NullAction./
  4739.  
  4740. Superopt -> Super
  4741. \:$NoAction:\
  4742. /.$shared_NoAction./
  4743.  
  4744. Expressionopt ::= $empty
  4745. \:$NullAction:\
  4746. /.$shared_NullAction./
  4747.  
  4748. Expressionopt -> Expression
  4749. \:$NoAction:\
  4750. /.$shared_NoAction./
  4751.  
  4752. --1.1 feature
  4753. ClassBodyopt ::= $empty
  4754. \:$NullAction:\
  4755. /.$shared_NullAction./
  4756.  
  4757. --1.1 feature
  4758. ClassBodyopt -> ClassBody
  4759. \:$NoAction:\
  4760. /.$shared_NoAction./
  4761.  
  4762. ---------------------------------------------------------------------------------------
  4763. --
  4764. -- The rules below are for optional terminal symbols.  An optional comma,
  4765. -- is only used in the context of an array initializer - It is a
  4766. -- "syntactic sugar" that otherwise serves no other purpose. By contrast,
  4767. -- an optional identifier is used in the definition of a break and
  4768. -- continue statement. When the identifier does not appear, a NULL
  4769. -- is produced. When the identifier is present, the user should use the
  4770. -- corresponding Token(i) method. See break statement as an example.
  4771. --
  4772. ---------------------------------------------------------------------------------------
  4773.  
  4774. ,opt ::= $empty
  4775. \:$NullAction:\
  4776. /.$shared_NullAction./
  4777.  
  4778. ,opt -> ,
  4779. \:$NoAction:\
  4780. /.$shared_NoAction./
  4781.  
  4782. ImportDeclarationsopt ::= $empty
  4783. \:$NullAction:\
  4784. /.$shared_NullAction./
  4785.  
  4786. ImportDeclarationsopt -> ImportDeclarations
  4787. \:$NoAction:\
  4788. /.$shared_NoAction./
  4789.  
  4790. TypeDeclarationsopt ::= $empty
  4791. \:$NullAction:\
  4792. /.$shared_NullAction./
  4793.  
  4794. TypeDeclarationsopt -> TypeDeclarations
  4795. \:$NoAction:\
  4796. /.$shared_NoAction./
  4797.  
  4798. ClassBodyDeclarationsopt ::= $empty
  4799. \:$NullAction:\
  4800. /.$shared_NullAction./
  4801.  
  4802. ClassBodyDeclarationsopt -> ClassBodyDeclarations
  4803. \:$NoAction:\
  4804. /.$shared_NoAction./
  4805.  
  4806. Modifiersopt ::= $empty
  4807. \:$NullAction:\
  4808. /.$shared_NullAction./
  4809.  
  4810. Modifiersopt -> Modifiers
  4811. \:$NoAction:\
  4812. /.$shared_NoAction./
  4813.  
  4814. BlockStatementsopt ::= $empty
  4815. \:$NullAction:\
  4816. /.$shared_NullAction./
  4817.  
  4818. BlockStatementsopt -> BlockStatements
  4819. \:$NoAction:\
  4820. /.$shared_NoAction./
  4821.  
  4822. Dimsopt ::= $empty
  4823. \:$NullAction:\
  4824. /.$shared_NullAction./
  4825.  
  4826. Dimsopt -> Dims
  4827. \:$NoAction:\
  4828. /.$shared_NoAction./
  4829.  
  4830. ArgumentListopt ::= $empty
  4831. \:$NullAction:\
  4832. /.$shared_NullAction./
  4833.  
  4834. ArgumentListopt -> ArgumentList
  4835. \:$NoAction:\
  4836. /.$shared_NoAction./
  4837.  
  4838. Throwsopt ::= $empty
  4839. \:$NullAction:\
  4840. /.$shared_NullAction./
  4841.  
  4842. Throwsopt -> Throws
  4843. \:$NoAction:\
  4844. /.$shared_NoAction./
  4845.  
  4846. FormalParameterListopt ::= $empty
  4847. \:$NullAction:\
  4848. /.$shared_NullAction./
  4849.  
  4850. FormalParameterListopt -> FormalParameterList
  4851. \:$NoAction:\
  4852. /.$shared_NoAction./
  4853.  
  4854. Interfacesopt ::= $empty
  4855. \:$NullAction:\
  4856. /.$shared_NullAction./
  4857.  
  4858. Interfacesopt -> Interfaces
  4859. \:$NoAction:\
  4860. /.$shared_NoAction./
  4861.  
  4862. InterfaceMemberDeclarationsopt ::= $empty
  4863. \:$NullAction:\
  4864. /.$shared_NullAction./
  4865.  
  4866. InterfaceMemberDeclarationsopt -> InterfaceMemberDeclarations
  4867. \:$NoAction:\
  4868. /.$shared_NoAction./
  4869.  
  4870. ForInitopt ::= $empty
  4871. \:$NullAction:\
  4872. /.$shared_NullAction./
  4873.  
  4874. ForInitopt -> ForInit
  4875. \:$NoAction:\
  4876. /.$shared_NoAction./
  4877.  
  4878. ForUpdateopt ::= $empty
  4879. \:$NullAction:\
  4880. /.$shared_NullAction./
  4881.  
  4882. ForUpdateopt -> ForUpdate
  4883. \:$NoAction:\
  4884. /.$shared_NoAction./
  4885.  
  4886. ExtendsInterfacesopt ::= $empty
  4887. \:$NullAction:\
  4888. /.$shared_NullAction./
  4889.  
  4890. ExtendsInterfacesopt -> ExtendsInterfaces
  4891. \:$NoAction:\
  4892. /.$shared_NoAction./
  4893.  
  4894. Catchesopt ::= $empty
  4895. \:$NullAction:\
  4896. /.$shared_NullAction./
  4897.  
  4898. Catchesopt -> Catches
  4899. \:$NoAction:\
  4900. /.$shared_NoAction./
  4901.  
  4902. PackageHeaderMarker ::= $empty
  4903. \:$action:\
  4904. /.$location
  4905. //
  4906. // When this function is invoked, if the "parse_package_header_only" flag
  4907. // is turned on, we skip to the end-of-file token.
  4908. //
  4909. void Parser::Act$rule_number(void)
  4910. {
  4911.     if (parse_package_header_only)
  4912.         lex_stream -> Reset(lex_stream -> NumTokens() - 1); // point to the EOF token
  4913.     Sym(1) = NULL;
  4914. }
  4915. ./
  4916.  
  4917. MethodHeaderMarker ::= $empty
  4918. \:$action:\
  4919. /.$location
  4920. //
  4921. // When this function is invoked, if the "parse_header_only" flag
  4922. // is turned on, the body of the method being parsed is skipped.
  4923. //
  4924. void Parser::Act$rule_number(void)
  4925. {
  4926.     if (parse_header_only)
  4927.     {
  4928.         TokenObject token = Token(1);
  4929.  
  4930.         //
  4931.         // If the first token immediately following the method header
  4932.         // is not an open brace, then we have a syntactic error. Do
  4933.         // nothing and let the error recovery take care of it.
  4934.         //
  4935.         if (lex_stream -> Kind(token) == TK_LBRACE)
  4936.             lex_stream -> Reset(lex_stream -> MatchingBrace(token));
  4937.     }
  4938.  
  4939.     Sym(1) = NULL;
  4940. }
  4941. ./
  4942.  
  4943. ---------------------------------------------------------------------------------------
  4944.  
  4945. \:
  4946. #ifndef HEADERS
  4947.     return;
  4948. }
  4949.  
  4950. #ifdef    HAVE_NAMESPACE
  4951. }            // Close namespace Jikes block
  4952. #endif
  4953.  
  4954. #endif
  4955. :\
  4956.  
  4957. $names
  4958.  
  4959. BodyMarker ::= '"class Identifier { ... MethodHeader "'
  4960.  
  4961. void ::= ResultType
  4962.  
  4963. PLUS_PLUS ::=    '++'
  4964. MINUS_MINUS ::=    '--'
  4965. EQUAL_EQUAL ::=    '=='
  4966. LESS_EQUAL ::=    '<='
  4967. GREATER_EQUAL ::=    '>='
  4968. NOT_EQUAL ::=    '!='
  4969. LEFT_SHIFT ::=    '<<'
  4970. RIGHT_SHIFT ::=    '>>'
  4971. UNSIGNED_RIGHT_SHIFT ::=    '>>>'
  4972. PLUS_EQUAL ::=    '+='
  4973. MINUS_EQUAL ::=    '-='
  4974. MULTIPLY_EQUAL ::=    '*='
  4975. DIVIDE_EQUAL ::=    '/='
  4976. AND_EQUAL ::=    '&='
  4977. OR_EQUAL ::=    '|='
  4978. XOR_EQUAL ::=    '^='
  4979. REMAINDER_EQUAL ::=    '%='
  4980. LEFT_SHIFT_EQUAL ::=    '<<='
  4981. RIGHT_SHIFT_EQUAL ::=    '>>='
  4982. UNSIGNED_RIGHT_SHIFT_EQUAL ::=    '>>>='
  4983. OR_OR ::=    '||'
  4984. AND_AND ::=    '&&'
  4985.  
  4986. PLUS ::=    '+'
  4987. MINUS ::=    '-'
  4988. NOT ::=    '!'
  4989. REMAINDER ::=    '%'
  4990. XOR ::=    '^'
  4991. AND ::=    '&'
  4992. MULTIPLY ::=    '*'
  4993. OR ::=    '|'
  4994. TWIDDLE ::=    '~'
  4995. DIVIDE ::=    '/'
  4996. GREATER ::=    '>'
  4997. LESS ::=    '<'
  4998. LPAREN ::=    '('
  4999. RPAREN ::=    ')'
  5000. LBRACE ::=    '{'
  5001. RBRACE ::=    '}'
  5002. LBRACKET ::=    '['
  5003. RBRACKET ::=    ']'
  5004. SEMICOLON ::=    ';'
  5005. QUESTION ::=    '?'
  5006. COLON ::=    ':'
  5007. COMMA ::=    ','
  5008. DOT ::=    '.'
  5009. EQUAL ::=    '='
  5010.  
  5011. $end
  5012.