home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / jikes-1.02 / src / ast.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-26  |  70.1 KB  |  2,253 lines

  1. // $Id: ast.cpp,v 1.13 1999/08/26 15:34:01 shields Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10.  
  11. #include "config.h"
  12. #include "ast.h"
  13. #ifdef TEST
  14.     unsigned Ast::count = 0;
  15. #endif
  16.  
  17.  
  18. void AstCompilationUnit::FreeAst()
  19. {
  20.      delete ast_pool;
  21. }
  22.  
  23. //
  24. // This procedure uses a  quick sort algorithm to sort the cases
  25. // in a switch statement.
  26. //
  27. void AstSwitchStatement::SortCases()
  28. {
  29.     int lower,
  30.         upper,
  31.         lostack[32],
  32.         histack[32];
  33.  
  34.     int top,
  35.         i,
  36.         j;
  37.  
  38.     CaseElement pivot, temp;
  39.  
  40.     AstArray<CaseElement *> &map = *cases;
  41.  
  42.     top = 0;
  43.     lostack[top] = 0;
  44.     histack[top] = map.Length() - 1;
  45.  
  46.     while(top >= 0)
  47.     {
  48.         lower = lostack[top];
  49.         upper = histack[top];
  50.         top--;
  51.  
  52.         while(upper > lower)
  53.         {
  54.             //
  55.             // The array is most-likely almost sorted. Therefore,
  56.             // we use the middle element as the pivot element.
  57.             //
  58.             i = (lower + upper) / 2;
  59.             pivot = *map[i];
  60.             *map[i] = *map[lower];
  61.  
  62.             //
  63.             // Split the array section indicated by LOWER and UPPER
  64.             // using ARRAY(LOWER) as the pivot.
  65.             //
  66.             i = lower;
  67.             for (j = lower + 1; j <= upper; j++)
  68.                 if (map[j] -> Value() < pivot.Value() ||
  69.                     (map[j] -> Value() == pivot.Value() && map[j] -> index < pivot.index)) // keep the sort stable
  70.                 {
  71.                     temp = *map[++i];
  72.                     *map[i] = *map[j];
  73.                     *map[j] = temp;
  74.                 }
  75.             *map[lower] = *map[i];
  76.             *map[i] = pivot;
  77.  
  78.             top++;
  79.             if ((i - lower) < (upper - i))
  80.             {
  81.                 lostack[top] = i + 1;
  82.                 histack[top] = upper;
  83.                 upper = i - 1;
  84.             }
  85.             else
  86.             {
  87.                 histack[top] = i - 1;
  88.                 lostack[top] = lower;
  89.                 lower = i + 1;
  90.             }
  91.         }
  92.     }
  93.  
  94.     return;
  95. }
  96.  
  97.  
  98. Ast *Ast::Clone(StoragePool *ast_pool)
  99. {
  100.     return (Ast *) NULL;
  101. }
  102.  
  103. Ast *AstBlock::Clone(StoragePool *ast_pool)
  104. {
  105.     AstBlock *clone = ast_pool -> GenBlock();
  106.  
  107.     for (int i = 0; i < this -> NumLabels(); i++)
  108.         clone -> AddLabel(this -> Label(i));
  109.     clone -> nesting_level = this -> nesting_level;
  110.     clone -> left_brace_token = this -> left_brace_token;
  111.     if (this -> NumStatements() == 0)
  112.         clone -> block_statements = NULL;
  113.     else
  114.     {
  115.         for (int j = 0; j < this -> NumStatements(); j++)
  116.             clone -> AddStatement(this -> Statement(j) -> Clone(ast_pool));
  117.     }
  118.     clone -> right_brace_token = this -> right_brace_token;
  119.  
  120.     return clone;
  121. }
  122.  
  123. Ast *AstPrimitiveType::Clone(StoragePool *ast_pool)
  124. {
  125.     AstPrimitiveType *clone = ast_pool -> GenPrimitiveType(this -> kind, this -> primitive_kind_token);
  126.  
  127.     return clone;
  128. }
  129.  
  130. Ast *AstArrayType::Clone(StoragePool *ast_pool)
  131. {
  132.     AstArrayType *clone = ast_pool -> GenArrayType();
  133.  
  134.     clone -> type = this -> type -> Clone(ast_pool);
  135.     clone -> AllocateBrackets(this -> NumBrackets());
  136.     for (int i = 0; i < this -> NumBrackets(); i++)
  137.         clone -> AddBrackets((AstBrackets *) this -> Brackets(i) -> Clone(ast_pool));
  138.  
  139.     return clone;
  140. }
  141.  
  142. Ast *AstSimpleName::Clone(StoragePool *ast_pool)
  143. {
  144.     AstSimpleName *clone = ast_pool -> GenSimpleName(this -> identifier_token);
  145.     clone -> resolution_opt = (AstExpression *) (this -> resolution_opt ? this -> resolution_opt -> Clone(ast_pool) : NULL);
  146.  
  147.     return clone;
  148. }
  149.  
  150. Ast *AstPackageDeclaration::Clone(StoragePool *ast_pool)
  151. {
  152.     AstPackageDeclaration *clone = ast_pool -> GenPackageDeclaration();
  153.  
  154.     clone -> package_token = this -> package_token;
  155.     clone -> name = (AstExpression *) this -> name -> Clone(ast_pool);
  156.     clone -> semicolon_token = this -> semicolon_token;
  157.  
  158.     return clone;
  159. }
  160.  
  161. Ast *AstImportDeclaration::Clone(StoragePool *ast_pool)
  162. {
  163.     AstImportDeclaration *clone = ast_pool -> GenImportDeclaration();
  164.  
  165.     clone -> import_token = this -> import_token;
  166.     clone -> name = (AstExpression *) this -> name -> Clone(ast_pool);
  167.     clone -> star_token_opt = this -> star_token_opt;
  168.     clone -> semicolon_token = this -> semicolon_token;
  169.  
  170.     return clone;
  171. }
  172.  
  173. Ast *AstCompilationUnit::Clone(StoragePool *ast_pool)
  174. {
  175.     AstCompilationUnit *clone = ast_pool -> GenCompilationUnit();
  176.  
  177.     clone -> package_declaration_opt = (AstPackageDeclaration *)
  178.                                        (this -> package_declaration_opt
  179.                                               ? this -> package_declaration_opt -> Clone(ast_pool) : NULL);
  180.     for (int i = 0; i < this -> NumImportDeclarations(); i++)
  181.         clone -> AddImportDeclaration((AstImportDeclaration *) this -> ImportDeclaration(i) -> Clone(ast_pool));
  182.     for (int k = 0; k < this -> NumTypeDeclarations(); k++)
  183.         clone -> AddTypeDeclaration(this -> TypeDeclaration(k) -> Clone(ast_pool));
  184.  
  185.     return clone;
  186. }
  187.  
  188. Ast *AstModifier::Clone(StoragePool *ast_pool)
  189. {
  190.     AstModifier *clone = ast_pool -> GenModifier(this -> kind, this -> modifier_kind_token);
  191.  
  192.     return clone;
  193. }
  194.  
  195. Ast *AstEmptyDeclaration::Clone(StoragePool *ast_pool)
  196. {
  197.     AstEmptyDeclaration *clone = ast_pool -> GenEmptyDeclaration(this -> semicolon_token);
  198.  
  199.     return clone;
  200. }
  201.  
  202. Ast *AstClassBody::Clone(StoragePool *ast_pool)
  203. {
  204.     AstClassBody *clone = ast_pool -> GenClassBody();
  205.  
  206.     clone -> left_brace_token = this -> left_brace_token;
  207.     for (int i = 0; i < this -> NumClassBodyDeclarations(); i++)
  208.         clone -> AddClassBodyDeclaration(this -> ClassBodyDeclaration(i) -> Clone(ast_pool));
  209.     clone -> right_brace_token = this -> right_brace_token;
  210.  
  211.     return clone;
  212. }
  213.  
  214. Ast *AstClassDeclaration::Clone(StoragePool *ast_pool)
  215. {
  216.     AstClassDeclaration *clone = ast_pool -> GenClassDeclaration();
  217.  
  218.     for (int i = 0; i < this -> NumClassModifiers(); i++)
  219.         clone -> AddClassModifier((AstModifier *) this -> ClassModifier(i) -> Clone(ast_pool));
  220.     clone -> class_token = this -> class_token;
  221.     clone -> identifier_token = this -> identifier_token;
  222.     clone -> super_opt = (Ast *) (this -> super_opt ? this -> super_opt -> Clone(ast_pool) : NULL);
  223.     for (int k = 0; k < this -> NumInterfaces(); k++)
  224.         clone -> AddInterface((AstExpression *) this -> Interface(k) -> Clone(ast_pool));
  225.     clone -> class_body = (AstClassBody *) this -> class_body -> Clone(ast_pool);
  226.  
  227.     return clone;
  228. }
  229.  
  230. Ast *AstArrayInitializer::Clone(StoragePool *ast_pool)
  231. {
  232.     AstArrayInitializer *clone = ast_pool -> GenArrayInitializer();
  233.  
  234.     clone -> left_brace_token = this -> left_brace_token;
  235.     for (int k = 0; k < this -> NumVariableInitializers(); k++)
  236.         clone -> AddVariableInitializer(this -> VariableInitializer(k) -> Clone(ast_pool));
  237.     clone -> right_brace_token = this -> right_brace_token;
  238.  
  239.     return clone;
  240. }
  241.  
  242. Ast *AstBrackets::Clone(StoragePool *ast_pool)
  243. {
  244.     AstBrackets *clone = ast_pool -> GenBrackets(this -> left_bracket_token, this -> right_bracket_token);
  245.  
  246.     return clone;
  247. }
  248.  
  249. Ast *AstVariableDeclaratorId::Clone(StoragePool *ast_pool)
  250. {
  251.     AstVariableDeclaratorId *clone = ast_pool -> GenVariableDeclaratorId();
  252.  
  253.     clone -> identifier_token = this -> identifier_token;
  254.     clone -> AllocateBrackets(this -> NumBrackets());
  255.     for (int i = 0; i < this -> NumBrackets(); i++)
  256.         clone -> AddBrackets((AstBrackets *) this -> Brackets(i) -> Clone(ast_pool));
  257.  
  258.     return clone;
  259. }
  260.  
  261. Ast *AstVariableDeclarator::Clone(StoragePool *ast_pool)
  262. {
  263.     AstVariableDeclarator *clone = ast_pool -> GenVariableDeclarator();
  264.  
  265.     clone -> variable_declarator_name = (AstVariableDeclaratorId *) this -> variable_declarator_name -> Clone(ast_pool);
  266.     clone -> variable_initializer_opt = (Ast *) (this -> variable_initializer_opt
  267.                                                        ? this -> variable_initializer_opt -> Clone(ast_pool)
  268.                                                        : NULL);
  269.  
  270.     return clone;
  271. }
  272.  
  273. Ast *AstFieldDeclaration::Clone(StoragePool *ast_pool)
  274. {
  275.     AstFieldDeclaration *clone = ast_pool -> GenFieldDeclaration();
  276.  
  277.     for (int i = 0; i < this -> NumVariableModifiers(); i++)
  278.         clone -> AddVariableModifier((AstModifier *) this -> VariableModifier(i) -> Clone(ast_pool));
  279.     clone -> type = this -> type -> Clone(ast_pool);
  280.     for (int k = 0; k < this -> NumVariableDeclarators(); k++)
  281.         clone -> AddVariableDeclarator((AstVariableDeclarator *) this -> VariableDeclarator(k) -> Clone(ast_pool));
  282.     clone -> semicolon_token = this -> semicolon_token;
  283.  
  284.     return clone;
  285. }
  286.  
  287. Ast *AstFormalParameter::Clone(StoragePool *ast_pool)
  288. {
  289.     AstFormalParameter *clone = ast_pool -> GenFormalParameter();
  290.  
  291.     if (this -> NumParameterModifiers() == 0)
  292.         clone -> parameter_modifiers = NULL;
  293.     else
  294.     {
  295.         for (int i = 0; i < this -> NumParameterModifiers(); i++)
  296.             clone -> AddParameterModifier((AstModifier *) this -> ParameterModifier(i) -> Clone(ast_pool));
  297.     }
  298.     clone -> type = this -> type -> Clone(ast_pool);
  299.     clone -> formal_declarator = (AstVariableDeclarator *) this -> formal_declarator -> Clone(ast_pool);
  300.  
  301.     return clone;
  302. }
  303.  
  304. Ast *AstMethodDeclarator::Clone(StoragePool *ast_pool)
  305. {
  306.     AstMethodDeclarator *clone = ast_pool -> GenMethodDeclarator();
  307.  
  308.     clone -> identifier_token = this -> identifier_token;
  309.     clone -> left_parenthesis_token = this -> left_parenthesis_token;
  310.     clone -> AllocateFormalParameters(this -> NumFormalParameters());
  311.     for (int i = 0; i < this -> NumFormalParameters(); i++)
  312.         clone -> AddFormalParameter((AstFormalParameter *) this -> FormalParameter(i) -> Clone(ast_pool));
  313.     clone -> right_parenthesis_token = this -> right_parenthesis_token;
  314.     clone -> AllocateBrackets(this -> NumBrackets());
  315.     for (int k = 0; k < this -> NumBrackets(); k++)
  316.         clone -> AddBrackets((AstBrackets *) this -> Brackets(k) -> Clone(ast_pool));
  317.  
  318.     return clone;
  319. }
  320.  
  321. Ast *AstMethodDeclaration::Clone(StoragePool *ast_pool)
  322. {
  323.     AstMethodDeclaration *clone = ast_pool -> GenMethodDeclaration();
  324.  
  325.     for (int i = 0; i < this -> NumMethodModifiers(); i++)
  326.         clone -> AddMethodModifier((AstModifier *) this -> MethodModifier(i) -> Clone(ast_pool));
  327.     clone -> type = this -> type -> Clone(ast_pool);
  328.     clone -> method_declarator = (AstMethodDeclarator *) this -> method_declarator -> Clone(ast_pool);
  329.     for (int k = 0; k < this -> NumThrows(); k++)
  330.         clone -> AddThrow((AstExpression *) this -> Throw(k) -> Clone(ast_pool));
  331.     clone -> method_body = (AstStatement *) this -> method_body -> Clone(ast_pool);
  332.  
  333.     return clone;
  334. }
  335.  
  336. Ast *AstStaticInitializer::Clone(StoragePool *ast_pool)
  337. {
  338.     AstStaticInitializer *clone = ast_pool -> GenStaticInitializer();
  339.  
  340.     clone -> static_token = this -> static_token;
  341.     clone -> block = (AstBlock *) this -> block -> Clone(ast_pool);
  342.  
  343.     return clone;
  344. }
  345.  
  346. Ast *AstThisCall::Clone(StoragePool *ast_pool)
  347. {
  348.     AstThisCall *clone = ast_pool -> GenThisCall();
  349.  
  350.     clone -> this_token = this -> this_token;
  351.     clone -> left_parenthesis_token = this -> left_parenthesis_token;
  352.     clone -> AllocateArguments(this -> NumArguments());
  353.     for (int i = 0; i < this -> NumArguments(); i++)
  354.         clone -> AddArgument((AstExpression *) this -> Argument(i) -> Clone(ast_pool));
  355.     clone -> right_parenthesis_token = this -> right_parenthesis_token;
  356.     clone -> semicolon_token = this -> semicolon_token;
  357.  
  358.     return clone;
  359. }
  360.  
  361. Ast *AstSuperCall::Clone(StoragePool *ast_pool)
  362. {
  363.     AstSuperCall *clone = ast_pool -> GenSuperCall();
  364.  
  365.     clone -> base_opt = (AstExpression *) (this -> base_opt ? this -> base_opt -> Clone(ast_pool) : NULL);
  366.     clone -> dot_token_opt = this -> dot_token_opt;
  367.     clone -> super_token = this -> super_token;
  368.     clone -> left_parenthesis_token = this -> left_parenthesis_token;
  369.     clone -> AllocateArguments(this -> NumArguments());
  370.     for (int i = 0; i < this -> NumArguments(); i++)
  371.         clone -> AddArgument((AstExpression *) this -> Argument(i) -> Clone(ast_pool));
  372.     clone -> right_parenthesis_token = this -> right_parenthesis_token;
  373.     clone -> semicolon_token = this -> semicolon_token;
  374.     clone -> AllocateLocalArguments(this -> NumLocalArguments());
  375.     for (int k = 0; k < this -> NumLocalArguments(); k++)
  376.         clone -> AddLocalArgument((AstExpression *) this -> LocalArgument(k) -> Clone(ast_pool));
  377.  
  378.     return clone;
  379. }
  380.  
  381. Ast *AstConstructorBlock::Clone(StoragePool *ast_pool)
  382. {
  383.     AstConstructorBlock *clone = ast_pool -> GenConstructorBlock();
  384.  
  385.     clone -> left_brace_token = this -> left_brace_token;
  386.     clone -> explicit_constructor_invocation_opt = (Ast *)
  387.                                                    (this -> explicit_constructor_invocation_opt
  388.                                                           ? this -> explicit_constructor_invocation_opt -> Clone(ast_pool)
  389.                                                           : NULL);
  390.     clone -> block = (AstBlock *) this -> block -> Clone(ast_pool);
  391.     clone -> right_brace_token = this -> right_brace_token;
  392.  
  393.     return clone;
  394. }
  395.  
  396. Ast *AstConstructorDeclaration::Clone(StoragePool *ast_pool)
  397. {
  398.     AstConstructorDeclaration *clone = ast_pool -> GenConstructorDeclaration();
  399.  
  400.     for (int i = 0; i < this -> NumConstructorModifiers(); i++)
  401.         clone -> AddConstructorModifier((AstModifier *) this -> ConstructorModifier(i) -> Clone(ast_pool));
  402.     clone -> constructor_declarator = (AstMethodDeclarator *) this -> constructor_declarator -> Clone(ast_pool);
  403.     for (int k = 0; k < this -> NumThrows(); k++)
  404.         clone -> AddThrow((AstExpression *) this -> Throw(k) -> Clone(ast_pool));
  405.     clone -> constructor_body = (AstConstructorBlock *) this -> constructor_body -> Clone(ast_pool);
  406.  
  407.     return clone;
  408. }
  409.  
  410. Ast *AstInterfaceDeclaration::Clone(StoragePool *ast_pool)
  411. {
  412.     AstInterfaceDeclaration *clone = ast_pool -> GenInterfaceDeclaration();
  413.  
  414.     for (int i = 0; i < this -> NumInterfaceModifiers(); i++)
  415.         clone -> AddInterfaceModifier((AstModifier *) this -> InterfaceModifier(i) -> Clone(ast_pool));
  416.     clone -> interface_token = this -> interface_token;
  417.     clone -> identifier_token = this -> identifier_token;
  418.     for (int k = 0; k < this -> NumExtendsInterfaces(); k++)
  419.         clone -> AddExtendsInterface((AstExpression *) this -> ExtendsInterface(k) -> Clone(ast_pool));
  420.     clone -> left_brace_token = this -> left_brace_token;
  421.     for (int l = 0; l < this -> NumExtendsInterfaces(); l++)
  422.         clone -> AddInterfaceMemberDeclaration((AstExpression *) this -> InterfaceMemberDeclaration(l) -> Clone(ast_pool));
  423.     clone -> right_brace_token = this -> right_brace_token;
  424.  
  425.     return clone;
  426. }
  427.  
  428. Ast *AstLocalVariableDeclarationStatement::Clone(StoragePool *ast_pool)
  429. {
  430.     AstLocalVariableDeclarationStatement *clone = ast_pool -> GenLocalVariableDeclarationStatement();
  431.  
  432.     for (int i = 0; i < this -> NumLocalModifiers(); i++)
  433.         clone -> AddLocalModifier((AstModifier *) this -> LocalModifier(i) -> Clone(ast_pool));
  434.     clone -> type = this -> type -> Clone(ast_pool);
  435.     for (int k = 0; k < this -> NumVariableDeclarators(); k++)
  436.         clone -> AddVariableDeclarator((AstVariableDeclarator *) this -> VariableDeclarator(k) -> Clone(ast_pool));
  437.     clone -> semicolon_token_opt = this -> semicolon_token_opt;
  438.  
  439.     return clone;
  440. }
  441.  
  442. Ast *AstIfStatement::Clone(StoragePool *ast_pool)
  443. {
  444.     AstIfStatement *clone = ast_pool -> GenIfStatement();
  445.  
  446.     clone -> if_token = this -> if_token;
  447.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  448.     clone -> true_statement = (AstStatement *) this -> true_statement -> Clone(ast_pool);
  449.     clone -> false_statement_opt = (AstStatement *)
  450.                                    (this -> false_statement_opt
  451.                                           ? this -> false_statement_opt -> Clone(ast_pool)
  452.                                           : NULL);
  453.  
  454.     return clone;
  455. }
  456.  
  457. Ast *AstEmptyStatement::Clone(StoragePool *ast_pool)
  458. {
  459.     AstEmptyStatement *clone = ast_pool -> GenEmptyStatement(this -> semicolon_token);
  460.  
  461.     return clone;
  462. }
  463.  
  464. Ast *AstExpressionStatement::Clone(StoragePool *ast_pool)
  465. {
  466.     AstExpressionStatement *clone = ast_pool -> GenExpressionStatement();
  467.  
  468.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  469.     clone -> semicolon_token_opt = this -> semicolon_token_opt;
  470.  
  471.     return clone;
  472. }
  473.  
  474. Ast *AstCaseLabel::Clone(StoragePool *ast_pool)
  475. {
  476.     AstCaseLabel *clone = ast_pool -> GenCaseLabel();
  477.  
  478.     clone -> case_token = this -> case_token;
  479.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  480.     clone -> colon_token = this -> colon_token;
  481.     clone -> map_index = this -> map_index;
  482.  
  483.     return clone;
  484. }
  485.  
  486. Ast *AstDefaultLabel::Clone(StoragePool *ast_pool)
  487. {
  488.     AstDefaultLabel *clone = ast_pool -> GenDefaultLabel();
  489.  
  490.     clone -> default_token = this -> default_token;
  491.     clone -> colon_token = this -> colon_token;
  492.  
  493.     return clone;
  494. }
  495.  
  496. Ast *AstSwitchBlockStatement::Clone(StoragePool *ast_pool)
  497. {
  498.     AstSwitchBlockStatement *clone = ast_pool -> GenSwitchBlockStatement();
  499.  
  500.     clone -> AllocateSwitchLabels(this -> NumSwitchLabels());
  501.     for (int i = 0; i < this -> NumSwitchLabels(); i++)
  502.         clone -> AddSwitchLabel(this -> SwitchLabel(i) -> Clone(ast_pool));
  503.  
  504.     clone -> AllocateBlockStatements(this -> NumStatements());
  505.     for (int k = 0; k < this -> NumStatements(); k++)
  506.         clone -> AddStatement((AstStatement *) this -> Statement(k) -> Clone(ast_pool));
  507.  
  508.     return clone;
  509. }
  510.  
  511. Ast *AstSwitchStatement::Clone(StoragePool *ast_pool)
  512. {
  513.     AstSwitchStatement *clone = ast_pool -> GenSwitchStatement();
  514.  
  515.     clone -> switch_token = this -> switch_token;
  516.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  517.     clone -> switch_block = (AstBlock *) this -> switch_block -> Clone(ast_pool);
  518.  
  519.     return clone;
  520. }
  521.  
  522. Ast *AstWhileStatement::Clone(StoragePool *ast_pool)
  523. {
  524.     AstWhileStatement *clone = ast_pool -> GenWhileStatement();
  525.  
  526.     clone -> while_token = this -> while_token;
  527.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  528.     clone -> statement = (AstStatement *) this -> statement -> Clone(ast_pool);
  529.  
  530.     return clone;
  531. }
  532.  
  533. Ast *AstDoStatement::Clone(StoragePool *ast_pool)
  534. {
  535.     AstDoStatement *clone = ast_pool -> GenDoStatement();
  536.  
  537.     clone -> do_token = this -> do_token;
  538.     clone -> statement = (AstStatement *) this -> statement -> Clone(ast_pool);
  539.     clone -> while_token = this -> while_token;
  540.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  541.     clone -> semicolon_token = this -> semicolon_token;
  542.  
  543.     return clone;
  544. }
  545.  
  546. Ast *AstForStatement::Clone(StoragePool *ast_pool)
  547. {
  548.     AstForStatement *clone = ast_pool -> GenForStatement();
  549.  
  550.     clone -> for_token = this -> for_token;
  551.     for (int i = 0; i < this -> NumForInitStatements(); i++)
  552.         clone -> AddForInitStatement((AstStatement *) this -> ForInitStatement(i) -> Clone(ast_pool));
  553.     clone -> end_expression_opt = (AstExpression *)
  554.                                   (this -> end_expression_opt
  555.                                          ? this -> end_expression_opt -> Clone(ast_pool)
  556.                                          : NULL);
  557.     for (int k = 0; k < this -> NumForUpdateStatements(); k++)
  558.         clone -> AddForUpdateStatement((AstExpressionStatement *) this -> ForUpdateStatement(k) -> Clone(ast_pool));
  559.     clone -> statement = (AstStatement *) this -> statement -> Clone(ast_pool);
  560.  
  561.     return clone;
  562. }
  563.  
  564. Ast *AstBreakStatement::Clone(StoragePool *ast_pool)
  565. {
  566.     AstBreakStatement *clone = ast_pool -> GenBreakStatement();
  567.  
  568.     clone -> break_token = this -> break_token;
  569.     clone -> identifier_token_opt = this -> identifier_token_opt;
  570.     clone -> semicolon_token = this -> semicolon_token;
  571.     clone -> nesting_level = this -> nesting_level;
  572.  
  573.     return clone;
  574. }
  575.  
  576. Ast *AstContinueStatement::Clone(StoragePool *ast_pool)
  577. {
  578.     AstContinueStatement *clone = ast_pool -> GenContinueStatement();
  579.  
  580.     clone -> continue_token = this -> continue_token;
  581.     clone -> identifier_token_opt = this -> identifier_token_opt;
  582.     clone -> semicolon_token = this -> semicolon_token;
  583.     clone -> nesting_level = this -> nesting_level;
  584.  
  585.     return clone;
  586. }
  587.  
  588. Ast *AstReturnStatement::Clone(StoragePool *ast_pool)
  589. {
  590.     AstReturnStatement *clone = ast_pool -> GenReturnStatement();
  591.  
  592.     clone -> return_token = this -> return_token;
  593.     clone -> expression_opt = (AstExpression *) (this -> expression_opt ? this -> expression_opt -> Clone(ast_pool) : NULL);
  594.     clone -> semicolon_token = this -> semicolon_token;
  595.  
  596.     return clone;
  597. }
  598.  
  599. Ast *AstThrowStatement::Clone(StoragePool *ast_pool)
  600. {
  601.     AstThrowStatement *clone = ast_pool -> GenThrowStatement();
  602.  
  603.     clone -> throw_token = this -> throw_token;
  604.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  605.     clone -> semicolon_token = this -> semicolon_token;
  606.  
  607.     return clone;
  608. }
  609.  
  610. Ast *AstSynchronizedStatement::Clone(StoragePool *ast_pool)
  611. {
  612.     AstSynchronizedStatement *clone = ast_pool -> GenSynchronizedStatement();
  613.  
  614.     clone -> synchronized_token = this -> synchronized_token;
  615.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  616.     clone -> block = (AstBlock *) this -> block -> Clone(ast_pool);
  617.  
  618.     return clone;
  619. }
  620.  
  621. Ast *AstCatchClause::Clone(StoragePool *ast_pool)
  622. {
  623.     AstCatchClause *clone = ast_pool -> GenCatchClause();
  624.  
  625.     clone -> catch_token = this -> catch_token;
  626.     clone -> formal_parameter = (AstFormalParameter *) this -> formal_parameter -> Clone(ast_pool);
  627.     clone -> block = (AstBlock *) this -> block -> Clone(ast_pool);
  628.  
  629.     return clone;
  630. }
  631.  
  632. Ast *AstFinallyClause::Clone(StoragePool *ast_pool)
  633. {
  634.     AstFinallyClause *clone = ast_pool -> GenFinallyClause();
  635.  
  636.     clone -> finally_token = this -> finally_token;
  637.     clone -> block = (AstBlock *) this -> block -> Clone(ast_pool);
  638.  
  639.     return clone;
  640. }
  641.  
  642. Ast *AstTryStatement::Clone(StoragePool *ast_pool)
  643. {
  644.     AstTryStatement *clone = ast_pool -> GenTryStatement();
  645.  
  646.     clone -> try_token = this -> try_token;
  647.     clone -> block = (AstBlock *) this -> block -> Clone(ast_pool);
  648.     for (int k = 0; k < this -> NumCatchClauses(); k++)
  649.         clone -> AddCatchClause((AstCatchClause *) this -> CatchClause(k) -> Clone(ast_pool));
  650.     clone -> finally_clause_opt = (AstFinallyClause *)
  651.                                   (this -> finally_clause_opt
  652.                                          ? this -> finally_clause_opt -> Clone(ast_pool)
  653.                                          : NULL);
  654.  
  655.     return clone;
  656. }
  657.  
  658. Ast *AstIntegerLiteral::Clone(StoragePool *ast_pool)
  659. {
  660.     AstIntegerLiteral *clone = ast_pool -> GenIntegerLiteral(this -> integer_literal_token);
  661.  
  662.     return clone;
  663. }
  664.  
  665. Ast *AstLongLiteral::Clone(StoragePool *ast_pool)
  666. {
  667.     AstLongLiteral *clone = ast_pool -> GenLongLiteral(this -> long_literal_token);
  668.  
  669.     return clone;
  670. }
  671.  
  672. Ast *AstFloatingPointLiteral::Clone(StoragePool *ast_pool)
  673. {
  674.     AstFloatingPointLiteral *clone = ast_pool -> GenFloatingPointLiteral(this -> floating_point_literal_token);
  675.  
  676.     return clone;
  677. }
  678.  
  679. Ast *AstDoubleLiteral::Clone(StoragePool *ast_pool)
  680. {
  681.     AstDoubleLiteral *clone = ast_pool -> GenDoubleLiteral(this -> double_literal_token);
  682.  
  683.     return clone;
  684. }
  685.  
  686. Ast *AstTrueLiteral::Clone(StoragePool *ast_pool)
  687. {
  688.     AstTrueLiteral *clone = ast_pool -> GenTrueLiteral(this -> true_literal_token);
  689.  
  690.     return clone;
  691. }
  692.  
  693. Ast *AstFalseLiteral::Clone(StoragePool *ast_pool)
  694. {
  695.     AstFalseLiteral *clone = ast_pool -> GenFalseLiteral(this -> false_literal_token);
  696.  
  697.     return clone;
  698. }
  699.  
  700. Ast *AstStringLiteral::Clone(StoragePool *ast_pool)
  701. {
  702.     AstStringLiteral *clone = ast_pool -> GenStringLiteral(this -> string_literal_token);
  703.  
  704.     return clone;
  705. }
  706.  
  707. Ast *AstCharacterLiteral::Clone(StoragePool *ast_pool)
  708. {
  709.     AstCharacterLiteral *clone = ast_pool -> GenCharacterLiteral(this -> character_literal_token);
  710.  
  711.     return clone;
  712. }
  713.  
  714. Ast *AstNullLiteral::Clone(StoragePool *ast_pool)
  715. {
  716.     AstNullLiteral *clone = ast_pool -> GenNullLiteral(this -> null_token);
  717.  
  718.     return clone;
  719. }
  720.  
  721. Ast *AstThisExpression::Clone(StoragePool *ast_pool)
  722. {
  723.     AstThisExpression *clone = ast_pool -> GenThisExpression(this -> this_token);
  724.  
  725.     return clone;
  726. }
  727.  
  728. Ast *AstSuperExpression::Clone(StoragePool *ast_pool)
  729. {
  730.     AstSuperExpression *clone = ast_pool -> GenSuperExpression(this -> super_token);
  731.  
  732.     return clone;
  733. }
  734.  
  735. Ast *AstParenthesizedExpression::Clone(StoragePool *ast_pool)
  736. {
  737.     AstParenthesizedExpression *clone = ast_pool -> GenParenthesizedExpression();
  738.  
  739.     clone -> left_parenthesis_token = this -> left_parenthesis_token;
  740.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  741.     clone -> right_parenthesis_token = this -> right_parenthesis_token;
  742.  
  743.     return clone;
  744. }
  745.  
  746. Ast *AstTypeExpression::Clone(StoragePool *ast_pool)
  747. {
  748.     AstTypeExpression *clone = ast_pool -> GenTypeExpression(this -> type -> Clone(ast_pool));
  749.  
  750.     return clone;
  751. }
  752.  
  753. Ast *AstClassInstanceCreationExpression::Clone(StoragePool *ast_pool)
  754. {
  755.     AstClassInstanceCreationExpression *clone = ast_pool -> GenClassInstanceCreationExpression();
  756.  
  757.     clone -> base_opt = (AstExpression *) (this -> base_opt ? this -> base_opt -> Clone(ast_pool) : NULL);
  758.     clone -> dot_token_opt = this -> dot_token_opt;
  759.     clone -> new_token = this -> new_token;
  760.     clone -> class_type = (AstTypeExpression *) this -> class_type -> Clone(ast_pool);
  761.     clone -> left_parenthesis_token = this -> left_parenthesis_token;
  762.     clone -> AllocateArguments(this -> NumArguments());
  763.     for (int i = 0; i < this -> NumArguments(); i++)
  764.         clone -> AddArgument((AstExpression *) this -> Argument(i) -> Clone(ast_pool));
  765.     clone -> right_parenthesis_token = this -> right_parenthesis_token;
  766.     clone -> class_body_opt = (AstClassBody *) (this -> class_body_opt ? this -> class_body_opt -> Clone(ast_pool) : NULL);
  767.     clone -> AllocateLocalArguments(this -> NumLocalArguments());
  768.     for (int k = 0; k < this -> NumLocalArguments(); k++)
  769.         clone -> AddLocalArgument((AstExpression *) this -> LocalArgument(k) -> Clone(ast_pool));
  770.  
  771.     return clone;
  772. }
  773.  
  774. Ast *AstDimExpr::Clone(StoragePool *ast_pool)
  775. {
  776.     AstDimExpr *clone = ast_pool -> GenDimExpr();
  777.  
  778.     clone -> left_bracket_token = this -> left_bracket_token;
  779.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  780.     clone -> right_bracket_token = this -> right_bracket_token;
  781.  
  782.     return clone;
  783. }
  784.  
  785. Ast *AstArrayCreationExpression::Clone(StoragePool *ast_pool)
  786. {
  787.     AstArrayCreationExpression *clone = ast_pool -> GenArrayCreationExpression();
  788.  
  789.     clone -> new_token = this -> new_token;
  790.     clone -> array_type = this -> array_type -> Clone(ast_pool);
  791.     clone -> AllocateDimExprs(this -> NumDimExprs());
  792.     for (int i = 0; i < this -> NumDimExprs(); i++)
  793.         clone -> AddDimExpr((AstDimExpr *) this -> DimExpr(i) -> Clone(ast_pool));
  794.     clone -> AllocateBrackets(this -> NumBrackets());
  795.     for (int k = 0; k < this -> NumBrackets(); k++)
  796.         clone -> AddBrackets((AstBrackets *) this -> Brackets(k) -> Clone(ast_pool));
  797.     clone -> array_initializer_opt = (AstArrayInitializer *)
  798.                                      (this -> array_initializer_opt ? this -> array_initializer_opt -> Clone(ast_pool) : NULL);
  799.  
  800.     return clone;
  801. }
  802.  
  803. Ast *AstFieldAccess::Clone(StoragePool *ast_pool)
  804. {
  805.     AstFieldAccess *clone = ast_pool -> GenFieldAccess(this -> field_access_tag);
  806.  
  807.     clone -> base = (AstExpression *) this -> base -> Clone(ast_pool);
  808.     clone -> dot_token = this -> dot_token;
  809.     clone -> identifier_token = this -> identifier_token;
  810.     clone -> resolution_opt = (AstExpression *) (this -> resolution_opt ? this -> resolution_opt -> Clone(ast_pool) : NULL);
  811.  
  812.     return clone;
  813. }
  814.  
  815. Ast *AstMethodInvocation::Clone(StoragePool *ast_pool)
  816. {
  817.     AstMethodInvocation *clone = ast_pool -> GenMethodInvocation();
  818.  
  819.     clone -> method = (AstExpression *) this -> method -> Clone(ast_pool);
  820.     clone -> left_parenthesis_token = this -> left_parenthesis_token;
  821.     clone -> AllocateArguments(this -> NumArguments());
  822.     for (int i = 0; i < this -> NumArguments(); i++)
  823.         clone -> AddArgument((AstExpression *) this -> Argument(i) -> Clone(ast_pool));
  824.     clone -> right_parenthesis_token = this -> right_parenthesis_token;
  825.     clone -> resolution_opt = (AstExpression *) (this -> resolution_opt ? this -> resolution_opt -> Clone(ast_pool) : NULL);
  826.  
  827.     return clone;
  828. }
  829.  
  830. Ast *AstArrayAccess::Clone(StoragePool *ast_pool)
  831. {
  832.     AstArrayAccess *clone = ast_pool -> GenArrayAccess();
  833.  
  834.     clone -> base = (AstExpression *) this -> base -> Clone(ast_pool);
  835.     clone -> left_bracket_token = this -> left_bracket_token;
  836.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  837.     clone -> right_bracket_token = this -> right_bracket_token;
  838.  
  839.     return clone;
  840. }
  841.  
  842. Ast *AstPostUnaryExpression::Clone(StoragePool *ast_pool)
  843. {
  844.     AstPostUnaryExpression *clone = ast_pool -> GenPostUnaryExpression(this -> post_unary_tag);
  845.  
  846.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  847.     clone -> post_operator_token = this -> post_operator_token;
  848.  
  849.     return clone;
  850. }
  851.  
  852. Ast *AstPreUnaryExpression::Clone(StoragePool *ast_pool)
  853. {
  854.     AstPreUnaryExpression *clone = ast_pool -> GenPreUnaryExpression(this -> pre_unary_tag);
  855.  
  856.     clone -> pre_operator_token = this -> pre_operator_token;
  857.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  858.  
  859.     return clone;
  860. }
  861.  
  862. Ast *AstCastExpression::Clone(StoragePool *ast_pool)
  863. {
  864.     AstCastExpression *clone = ast_pool -> GenCastExpression();
  865.  
  866.     clone -> left_parenthesis_token_opt = this -> left_parenthesis_token_opt;
  867.     clone -> type_opt = (Ast *) (this -> type_opt ? this -> type_opt -> Clone(ast_pool) : NULL);
  868.     clone -> AllocateBrackets(this -> NumBrackets());
  869.     for (int i = 0; i < this -> NumBrackets(); i++)
  870.         clone -> AddBrackets((AstBrackets *) this -> Brackets(i) -> Clone(ast_pool));
  871.     clone -> right_parenthesis_token_opt = this -> right_parenthesis_token_opt;
  872.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  873.  
  874.     return clone;
  875. }
  876.  
  877. Ast *AstBinaryExpression::Clone(StoragePool *ast_pool)
  878. {
  879.     AstBinaryExpression *clone = ast_pool -> GenBinaryExpression(this -> binary_tag);
  880.  
  881.     clone -> left_expression = (AstExpression *) this -> left_expression -> Clone(ast_pool);
  882.     clone -> binary_operator_token = this -> binary_operator_token;
  883.     clone -> right_expression = (AstExpression *) this -> right_expression -> Clone(ast_pool);
  884.  
  885.     return clone;
  886. }
  887.  
  888. Ast *AstConditionalExpression::Clone(StoragePool *ast_pool)
  889. {
  890.     AstConditionalExpression *clone = ast_pool -> GenConditionalExpression();
  891.  
  892.     clone -> test_expression = (AstExpression *) this -> test_expression -> Clone(ast_pool);
  893.     clone -> question_token = this -> question_token;
  894.     clone -> true_expression = (AstExpression *) this -> true_expression -> Clone(ast_pool);
  895.     clone -> colon_token = this -> colon_token;
  896.     clone -> false_expression = (AstExpression *) this -> false_expression -> Clone(ast_pool);
  897.  
  898.     return clone;
  899. }
  900.  
  901. Ast *AstAssignmentExpression::Clone(StoragePool *ast_pool)
  902. {
  903.     AstAssignmentExpression *clone = ast_pool -> GenAssignmentExpression(this -> assignment_tag, this -> assignment_operator_token);
  904.  
  905.     clone -> left_hand_side = (AstExpression *) this -> left_hand_side -> Clone(ast_pool);
  906.     clone -> expression = (AstExpression *) this -> expression -> Clone(ast_pool);
  907.  
  908.     return clone;
  909. }
  910.  
  911. #ifdef TEST
  912.     void Ast::Print(LexStream& lex_stream)
  913.     {
  914.         Coutput << "#" << this -> id << " (Ast):  "
  915.                 << "Node number " << (int) kind << " does not contain a print routine\n";
  916.     }
  917.  
  918.     void AstBlock::Print(LexStream& lex_stream)
  919.     {
  920.         Coutput << "#" << this -> id << " (";
  921.         for (int i = 0; i < this -> NumLabels(); i++)
  922.         {
  923.              Coutput << lex_stream.NameString(this -> Label(i))
  924.                      << ": ";
  925.         }
  926.         Coutput << "Block at level " << nesting_level;
  927.         if (block_symbol)
  928.              Coutput << ", max_variable_index " << block_symbol -> max_variable_index
  929.                      << ", try_variable_index " << block_symbol -> try_variable_index;
  930.         else Coutput << ", BLOCK_SYMBOL NOT SET";
  931.         Coutput << ")";
  932.  
  933.         if (NumStatements() > 0)
  934.         {
  935.             Coutput << "    {";
  936.             for (int j = 0; j < this -> NumStatements(); j++)
  937.             {
  938.                 if (j % 10 == 0)
  939.                     Coutput << "\n        ";
  940.                 Coutput << " #" << this -> Statement(j) -> id;
  941.             }
  942.             Coutput << "    }\n";
  943.             for (int k = 0; k < this -> NumStatements(); k++)
  944.                 this -> Statement(k) -> Print(lex_stream);
  945.         }
  946.         else Coutput <<"\n";
  947.     }
  948.  
  949.     void AstPrimitiveType::Print(LexStream& lex_stream)
  950.     {
  951.         Coutput << "#" << this -> id << " (PrimitiveType):  "
  952.                 << lex_stream.NameString(primitive_kind_token)
  953.                 << "\n";
  954.     }
  955.  
  956.     void AstArrayType::Print(LexStream& lex_stream)
  957.     {
  958.         Coutput << "#" << this -> id << " (ArrayType):  "
  959.                 << "#" << type -> id;
  960.         for (int i = 0; i < this -> NumBrackets(); i++)
  961.              Coutput << " []";
  962.         Coutput << "\n";
  963.         type -> Print(lex_stream);
  964.     }
  965.  
  966.     void AstSimpleName::Print(LexStream& lex_stream)
  967.     {
  968.         Coutput << "#" << this -> id << " (SimpleName):  "
  969.                 << lex_stream.NameString(identifier_token)
  970.                 << "\n";
  971.     }
  972.  
  973.     void AstPackageDeclaration::Print(LexStream& lex_stream)
  974.     {
  975.         Coutput << "#" << this -> id << " (PackageDeclaration):  "
  976.                 << lex_stream.NameString(package_token)
  977.                 << " #" << name -> id << "\n";
  978.         name -> Print(lex_stream);
  979.     }
  980.  
  981.     void AstImportDeclaration::Print(LexStream& lex_stream)
  982.     {
  983.         Coutput << "#" << this -> id << " (ImportDeclaration):  "
  984.                 << lex_stream.NameString(import_token)
  985.                 << " #" << name -> id << (star_token_opt ? "." : "")
  986.                 << (star_token_opt ? lex_stream.NameString(star_token_opt) : L"")
  987.                 << "\n";
  988.         name -> Print(lex_stream);
  989.     }
  990.  
  991.     void AstCompilationUnit::Print(LexStream& lex_stream)
  992.     {
  993.         Coutput << "\nAST structure for "
  994.                 << lex_stream.FileName()
  995.                 << ":\n\n"
  996.                 << "#" << this -> id << " (CompilationUnit):  "
  997.                 << "#" << (package_declaration_opt ? package_declaration_opt -> id : 0)
  998.                 << " (";
  999.         for (int i = 0; i < this -> NumImportDeclarations(); i++)
  1000.             Coutput << " #" << this -> ImportDeclaration(i) -> id;
  1001.         Coutput << " ) (";
  1002.         for (int k = 0; k < this -> NumTypeDeclarations(); k++)
  1003.             Coutput << " #" << this -> TypeDeclaration(k) -> id;
  1004.         Coutput << ")\n";
  1005.  
  1006.         if (package_declaration_opt)
  1007.             package_declaration_opt -> Print(lex_stream);
  1008.         for (int m = 0; m < this -> NumImportDeclarations(); m++)
  1009.             this -> ImportDeclaration(m) -> Print(lex_stream);
  1010.         for (int n = 0; n < this -> NumTypeDeclarations(); n++)
  1011.             this -> TypeDeclaration(n) -> Print(lex_stream);
  1012.     }
  1013.  
  1014.     void AstModifier::Print(LexStream& lex_stream)
  1015.     {
  1016.         Coutput << "#" << this -> id << " (Modifier):  "
  1017.                 << lex_stream.NameString(modifier_kind_token)
  1018.                 << "\n";
  1019.     }
  1020.  
  1021.     void AstEmptyDeclaration::Print(LexStream& lex_stream)
  1022.     {
  1023.         Coutput << "#" << this -> id << " (EmptyDeclaration):  "
  1024.                 << lex_stream.NameString(semicolon_token)
  1025.                 << "\n";
  1026.     }
  1027.  
  1028.     void AstClassBody::Print(LexStream& lex_stream)
  1029.     {
  1030.         Coutput << "#" << this -> id << " (ClassBody):  "
  1031.                 << "\n    {";
  1032.         for (int i = 0; i < this -> NumClassBodyDeclarations(); i++)
  1033.         {
  1034.             if (i % 10 == 0)
  1035.                  Coutput << "\n       ";
  1036.             Coutput << " #" << this -> ClassBodyDeclaration(i) -> id;
  1037.         }
  1038.         Coutput << "\n    }\n";
  1039.  
  1040.         for (int k = 0; k < this -> NumClassBodyDeclarations(); k++)
  1041.             this -> ClassBodyDeclaration(k) -> Print(lex_stream);
  1042.     }
  1043.  
  1044.     void AstClassDeclaration::Print(LexStream& lex_stream)
  1045.     {
  1046.         Coutput << "#" << this -> id << " (ClassDeclaration):  ";
  1047.         for (int i = 0; i < this -> NumClassModifiers(); i++)
  1048.         {
  1049.             Coutput << lex_stream.NameString(this -> ClassModifier(i) -> modifier_kind_token)
  1050.                     << " ";
  1051.         }
  1052.         Coutput << lex_stream.NameString(class_token)
  1053.                 << " "
  1054.                 << lex_stream.NameString(identifier_token)
  1055.                 << " #" << (super_opt ? super_opt -> id : 0)
  1056.                 << "(";
  1057.         for (int j = 0; j < NumInterfaces(); j++)
  1058.             Coutput << " #" << this -> Interface(j) -> id;
  1059.         Coutput << ") #" << class_body -> id << "\n";
  1060.  
  1061.         if (super_opt)
  1062.             super_opt -> Print(lex_stream);
  1063.         for (int k = 0; k < NumInterfaces(); k++)
  1064.             this -> Interface(k) -> Print(lex_stream);
  1065.         class_body -> Print(lex_stream);
  1066.     }
  1067.  
  1068.     void AstArrayInitializer::Print(LexStream& lex_stream)
  1069.     {
  1070.         Coutput << "#" << this -> id << " (ArrayInitializer):  "
  1071.                 << "\n    {";
  1072.         for (int i = 0; i < NumVariableInitializers(); i++)
  1073.         {
  1074.             if (i % 10 == 0)
  1075.                  Coutput << "\n       ";
  1076.             Coutput << " #" << this -> VariableInitializer(i) -> id;
  1077.         }
  1078.         Coutput << "\n    }\n";
  1079.  
  1080.         for (int k = 0; k < NumVariableInitializers(); k++)
  1081.             this -> VariableInitializer(k) -> Print(lex_stream);
  1082.     }
  1083.  
  1084.     void AstBrackets::Print(LexStream& lex_stream)
  1085.     {
  1086.         Coutput << "#" << this -> id << " (Brackets):  []" << "\n";
  1087.     }
  1088.  
  1089.     void AstVariableDeclaratorId::Print(LexStream& lex_stream)
  1090.     {
  1091.         Coutput << "#" << this -> id << " (VariableDeclaratorId):  "
  1092.                 << lex_stream.NameString(identifier_token);
  1093.         for (int i = 0; i < NumBrackets(); i++)
  1094.              Coutput << " []";
  1095.         Coutput << "\n";
  1096.     }
  1097.  
  1098.     void AstVariableDeclarator::Print(LexStream& lex_stream)
  1099.     {
  1100.         Coutput << "#" << this -> id << " (VariableDeclarator):  " << "#" << variable_declarator_name -> id << " #" <<
  1101.                    (variable_initializer_opt ? variable_initializer_opt -> id : 0) << "\n";
  1102.         variable_declarator_name -> Print(lex_stream);
  1103.         if (variable_initializer_opt)
  1104.             variable_initializer_opt -> Print(lex_stream);
  1105.  
  1106.     }
  1107.  
  1108.     void AstFieldDeclaration::Print(LexStream& lex_stream)
  1109.     {
  1110.         Coutput << "#" << this -> id << " (FieldDeclaration):  ";
  1111.         for (int i = 0; i < this -> NumVariableModifiers(); i++)
  1112.         {
  1113.             Coutput << lex_stream.NameString(this -> VariableModifier(i) -> modifier_kind_token)
  1114.                     << " ";
  1115.         }
  1116.         Coutput << " #" << type -> id
  1117.                 << "(";
  1118.         for (int j = 0; j < this -> NumVariableDeclarators(); j++)
  1119.             Coutput << " #" << this -> VariableDeclarator(j) -> id;
  1120.         Coutput << ") \n";
  1121.  
  1122.         type -> Print(lex_stream);
  1123.         for (int k = 0; k < this -> NumVariableDeclarators(); k++)
  1124.             this -> VariableDeclarator(k) -> Print(lex_stream);
  1125.     }
  1126.  
  1127.     void AstFormalParameter::Print(LexStream& lex_stream)
  1128.     {
  1129.         Coutput << "#" << this -> id << " (FormalParameter):  ";
  1130.         for (int i = 0; i < this -> NumParameterModifiers(); i++)
  1131.         {
  1132.             Coutput << lex_stream.NameString(this -> ParameterModifier(i) -> modifier_kind_token)
  1133.                     << " ";
  1134.         }
  1135.         Coutput << "#" << type -> id
  1136.                 << " #" << formal_declarator -> id << "\n";
  1137.         type -> Print(lex_stream);
  1138.         formal_declarator -> Print(lex_stream);
  1139.     }
  1140.  
  1141.     void AstMethodDeclarator::Print(LexStream& lex_stream)
  1142.     {
  1143.         Coutput << "#" << this -> id << " (MethodDeclarator):  "
  1144.                 << lex_stream.NameString(identifier_token)
  1145.                 << " (";
  1146.         for (int k = 0; k < this -> NumFormalParameters(); k++)
  1147.             Coutput << " #" << this -> FormalParameter(k) -> id;
  1148.         Coutput << " )";
  1149.         for (int i = 0; i < NumBrackets(); i++)
  1150.              Coutput << " []";
  1151.         Coutput <<  "\n";
  1152.  
  1153.         for (int j = 0; j < this -> NumFormalParameters(); j++)
  1154.             this -> FormalParameter(j) -> Print(lex_stream);
  1155.     }
  1156.  
  1157.     void AstMethodDeclaration::Print(LexStream& lex_stream)
  1158.     {
  1159.         Coutput << "#" << this -> id << " (MethodDeclaration):  ";
  1160.         for (int i = 0; i < this -> NumMethodModifiers(); i++)
  1161.         {
  1162.             Coutput << lex_stream.NameString(this -> MethodModifier(i) -> modifier_kind_token)
  1163.                     << " ";
  1164.         }
  1165.         Coutput << " #" << type -> id
  1166.                 << " #" << method_declarator -> id
  1167.                 << " throws: (";
  1168.         for (int j = 0; j < this -> NumThrows(); j++)
  1169.             Coutput << " #" << this -> Throw(j) -> id;
  1170.         Coutput << ") #" << method_body -> id << "\n";
  1171.  
  1172.         type -> Print(lex_stream);
  1173.         method_declarator -> Print(lex_stream);
  1174.         for (int k = 0; k < this -> NumThrows(); k++)
  1175.             this -> Throw(k) -> Print(lex_stream);
  1176.         method_body -> Print(lex_stream);
  1177.     }
  1178.  
  1179.     void AstStaticInitializer::Print(LexStream& lex_stream)
  1180.     {
  1181.         Coutput << "#" << this -> id << " (StaticInitializer):  "
  1182.                 << lex_stream.NameString(static_token)
  1183.                 << " #" << block -> id << "\n";
  1184.         block -> Print(lex_stream);
  1185.     }
  1186.  
  1187.     void AstThisCall::Print(LexStream& lex_stream)
  1188.     {
  1189.         Coutput << "#" << this -> id << " (ThisCall):  ";
  1190.         if (base_opt)
  1191.         {
  1192.             Coutput << "#" << base_opt -> id
  1193.                     << lex_stream.NameString(dot_token_opt);
  1194.         }
  1195.         Coutput << lex_stream.NameString(this_token)
  1196.                 << " (";
  1197.         for (int i = 0; i < this -> NumArguments(); i++)
  1198.             Coutput << " #" << this -> Argument(i) -> id;
  1199.         Coutput << " ) \n";
  1200.  
  1201.         if (base_opt)
  1202.             base_opt -> Print(lex_stream);
  1203.  
  1204.         for (int j = 0; j < NumArguments(); j++)
  1205.             this -> Argument(j) -> Print(lex_stream);
  1206.     }
  1207.  
  1208.     void AstSuperCall::Print(LexStream& lex_stream)
  1209.     {
  1210.         Coutput << "#" << this -> id << " (SuperCall):  ";
  1211.         if (base_opt)
  1212.         {
  1213.             Coutput << "#" << base_opt -> id
  1214.                     << lex_stream.NameString(dot_token_opt);
  1215.         }
  1216.         Coutput << lex_stream.NameString(super_token)
  1217.                 << " (";
  1218.         for (int i = 0; i < this -> NumArguments(); i++)
  1219.             Coutput << " #" << this -> Argument(i) -> id;
  1220.         Coutput << " ) \n";
  1221.  
  1222.         if (base_opt)
  1223.             base_opt -> Print(lex_stream);
  1224.  
  1225.         for (int j = 0; j < NumArguments(); j++)
  1226.             this -> Argument(j) -> Print(lex_stream);
  1227.     }
  1228.  
  1229.     void AstConstructorBlock::Print(LexStream& lex_stream)
  1230.     {
  1231.         Coutput << "#" << this -> id << " (ConstructorBlock):  ";
  1232.         if (explicit_constructor_invocation_opt)
  1233.              Coutput << " #" << explicit_constructor_invocation_opt -> id;
  1234.         else Coutput << " #0";
  1235.         Coutput << " #" << block -> id
  1236.                 << "\n";
  1237.  
  1238.         if (explicit_constructor_invocation_opt)
  1239.             explicit_constructor_invocation_opt -> Print(lex_stream);
  1240.         block -> Print(lex_stream);
  1241.     }
  1242.  
  1243.     void AstConstructorDeclaration::Print(LexStream& lex_stream)
  1244.     {
  1245.         Coutput << "#" << this -> id << " (ConstructorDeclaration):  ";
  1246.         for (int i = 0; i < this -> NumConstructorModifiers(); i++)
  1247.         {
  1248.             Coutput << lex_stream.NameString(this -> ConstructorModifier(i) -> modifier_kind_token)
  1249.                     << " ";
  1250.         }
  1251.         Coutput << " #" << constructor_declarator -> id
  1252.                 << " throws: (";
  1253.         for (int j = 0; j < this -> NumThrows(); j++)
  1254.             Coutput << " #" << this -> Throw(j) -> id;
  1255.         Coutput << ") #" << constructor_body -> id
  1256.                 << "\n";
  1257.  
  1258.         constructor_declarator -> Print(lex_stream);
  1259.         for (int k = 0; k < this -> NumThrows(); k++)
  1260.             this -> Throw(k) -> Print(lex_stream);
  1261.         constructor_body -> Print(lex_stream);
  1262.     }
  1263.  
  1264.     void AstInterfaceDeclaration::Print(LexStream& lex_stream)
  1265.     {
  1266.         Coutput << "#" << this -> id << " (InterfaceDeclaration):  ";
  1267.         for (int i = 0; i < this -> NumInterfaceModifiers(); i++)
  1268.         {
  1269.             Coutput << lex_stream.NameString(this -> InterfaceModifier(i) -> modifier_kind_token)
  1270.                     << " ";
  1271.         }
  1272.         Coutput << lex_stream.NameString(interface_token)
  1273.                 << " "
  1274.                 << lex_stream.NameString(identifier_token)
  1275.                 << "(";
  1276.         for (int j = 0; j < NumExtendsInterfaces(); j++)
  1277.             Coutput << " #" << this -> ExtendsInterface(j) -> id;
  1278.         Coutput << ") {";
  1279.         for (int m = 0; m < NumInterfaceMemberDeclarations(); m++)
  1280.             Coutput << " #" << this -> InterfaceMemberDeclaration(m) -> id;
  1281.         Coutput << "}\n";
  1282.  
  1283.         for (int k = 0; k < NumExtendsInterfaces(); k++)
  1284.             this -> ExtendsInterface(k) -> Print(lex_stream);
  1285.         for (int n = 0; n < NumInterfaceMemberDeclarations(); n++)
  1286.             this -> InterfaceMemberDeclaration(n) -> Print(lex_stream);
  1287.     }
  1288.  
  1289.     void AstLocalVariableDeclarationStatement::Print(LexStream& lex_stream)
  1290.     {
  1291.         Coutput << "#" << this -> id << " (LocalVariableDeclarationStatement):  ";
  1292.         for (int i = 0; i < this -> NumLocalModifiers(); i++)
  1293.         {
  1294.             Coutput << lex_stream.NameString(this -> LocalModifier(i) -> modifier_kind_token)
  1295.                     << " ";
  1296.         }
  1297.         Coutput << "#" << type -> id
  1298.                 << "(";
  1299.         for (int j = 0; j < this -> NumVariableDeclarators(); j++)
  1300.             Coutput << " #" << this -> VariableDeclarator(j) -> id;
  1301.         Coutput << ") \n";
  1302.  
  1303.         type -> Print(lex_stream);
  1304.         for (int k = 0; k < this -> NumVariableDeclarators(); k++)
  1305.             this -> VariableDeclarator(k) -> Print(lex_stream);
  1306.     }
  1307.  
  1308.     void AstIfStatement::Print(LexStream& lex_stream)
  1309.     {
  1310.         Coutput << "#" << this -> id << " (IfStatement):  "
  1311.                 << lex_stream.NameString(if_token)
  1312.                 << " ( #" << expression -> id << " ) #" << true_statement -> id;
  1313.         if (false_statement_opt)
  1314.              Coutput << " else #" << false_statement_opt -> id;
  1315.         else Coutput << " #0";
  1316.         Coutput << "\n";
  1317.  
  1318.         expression -> Print(lex_stream);
  1319.         true_statement -> Print(lex_stream);
  1320.         if (false_statement_opt)
  1321.             false_statement_opt -> Print(lex_stream);
  1322.     }
  1323.  
  1324.     void AstEmptyStatement::Print(LexStream& lex_stream)
  1325.     {
  1326.         Coutput << "#" << this -> id << " (EmptyStatement):  "
  1327.                 << lex_stream.NameString(semicolon_token)
  1328.                 << "\n";
  1329.     }
  1330.  
  1331.     void AstExpressionStatement::Print(LexStream& lex_stream)
  1332.     {
  1333.         Coutput << "#" << this -> id << " (ExpressionStatement):  " << "#" << expression -> id << "\n";
  1334.         expression -> Print(lex_stream);
  1335.     }
  1336.  
  1337.     void AstCaseLabel::Print(LexStream& lex_stream)
  1338.     {
  1339.         Coutput << "#" << this -> id << " (CaseLabel):  "
  1340.                 << lex_stream.NameString(case_token)
  1341.                 << " #" << expression -> id << ":\n";
  1342.         expression -> Print(lex_stream);
  1343.         Coutput << "    map_index: " << map_index << "\n";
  1344.     }
  1345.  
  1346.     void AstDefaultLabel::Print(LexStream& lex_stream)
  1347.     {
  1348.         Coutput << "#" << this -> id << " (DefaultLabel):  "
  1349.                 << lex_stream.NameString(default_token)
  1350.                 << ":\n";
  1351.     }
  1352.  
  1353.     void AstSwitchBlockStatement::Print(LexStream& lex_stream)
  1354.     {
  1355.         Coutput << "#" << this -> id << " (SwitchBlockStatement): ";
  1356.         for (int i = 0; i < NumSwitchLabels(); i++)
  1357.         {
  1358.             if (i % 10 == 0)
  1359.                  Coutput << "\n        ";
  1360.             Coutput << " #" << this -> SwitchLabel(i) -> id << ':';
  1361.         }
  1362.         Coutput << "\n";
  1363.         for (int k = 0; k < NumStatements(); k++)
  1364.         {
  1365.             if (k % 10 == 0)
  1366.                  Coutput << "\n            ";
  1367.             Coutput << " #" << this -> Statement(k) -> id;
  1368.         }
  1369.         Coutput << "\n";
  1370.  
  1371.         for (int j = 0; j < NumSwitchLabels(); j++)
  1372.             this -> SwitchLabel(j) -> Print(lex_stream);
  1373.         for (int l = 0; l < NumStatements(); l++)
  1374.             this -> Statement(l) -> Print(lex_stream);
  1375.     }
  1376.  
  1377.     void AstSwitchStatement::Print(LexStream& lex_stream)
  1378.     {
  1379.         Coutput << "#" << this -> id << " (SwitchStatement):  "
  1380.                 << lex_stream.NameString(switch_token)
  1381.                 << " ( #" << expression -> id << " ) #" << switch_block -> id << "\n";
  1382.  
  1383.         Coutput << "default case: index " << default_case.index << "\n";
  1384.         for (int i = 0; i < cases -> Length(); i++)
  1385.         {
  1386.             Coutput << "case: " << i << "  index: " << (*cases)[i] -> index << "  value: " << (*cases)[i] -> Value() << "\n";
  1387.         }
  1388.  
  1389.         expression -> Print(lex_stream);
  1390.         switch_block -> Print(lex_stream);
  1391.     }
  1392.  
  1393.     void AstWhileStatement::Print(LexStream& lex_stream)
  1394.     {
  1395.         Coutput << "#" << this -> id << " (WhileStatement):  "
  1396.                 << lex_stream.NameString(while_token)
  1397.                 << " ( #" << expression -> id << " ) #" << statement -> id << "\n";
  1398.         expression -> Print(lex_stream);
  1399.         statement -> Print(lex_stream);
  1400.     }
  1401.  
  1402.     void AstDoStatement::Print(LexStream& lex_stream)
  1403.     {
  1404.         Coutput << "#" << this -> id << " (DoStatement):  "
  1405.                 << lex_stream.NameString(do_token)
  1406.                 << " { #" << statement -> id << " } "
  1407.                 << lex_stream.NameString(while_token)
  1408.                 << " ( #" << expression -> id << " ) #\n";
  1409.  
  1410.         statement -> Print(lex_stream);
  1411.         expression -> Print(lex_stream);
  1412.     }
  1413.  
  1414.     void AstForStatement::Print(LexStream& lex_stream)
  1415.     {
  1416.         Coutput << "#" << this -> id << " (ForStatement):  ("
  1417.                 << lex_stream.NameString(for_token);
  1418.         for (int i = 0; i < this -> NumForInitStatements(); i++)
  1419.             Coutput << " #" << this -> ForInitStatement(i) -> id;
  1420.         Coutput << "; #" << (end_expression_opt ? end_expression_opt -> id : 0) << ";";
  1421.         for (int k = 0; k < this -> NumForInitStatements(); k++)
  1422.             Coutput << " #" << this -> ForUpdateStatement(k) -> id;
  1423.         Coutput << ") #" << statement -> id << "\n";
  1424.  
  1425.         for (int m = 0; m < this -> NumForInitStatements(); m++)
  1426.             this -> ForInitStatement(m) -> Print(lex_stream);
  1427.         if (end_expression_opt)
  1428.             end_expression_opt -> Print(lex_stream);
  1429.         for (int n = 0; n < this -> NumForUpdateStatements(); n++)
  1430.             this -> ForUpdateStatement(n) -> Print(lex_stream);
  1431.         statement -> Print(lex_stream);
  1432.     }
  1433.  
  1434.     void AstBreakStatement::Print(LexStream& lex_stream)
  1435.     {
  1436.         Coutput << "#" << this -> id << " (BreakStatement):  "
  1437.                 << lex_stream.NameString(break_token)
  1438.                 << " "
  1439.                 << (identifier_token_opt ? lex_stream.NameString(identifier_token_opt) : L"")
  1440.                 << " at nesting_level " << nesting_level << "\n";
  1441.     }
  1442.  
  1443.     void AstContinueStatement::Print(LexStream& lex_stream)
  1444.     {
  1445.         Coutput << "#" << this -> id << " (ContinueStatement):  "
  1446.                 << lex_stream.NameString(continue_token)
  1447.                 << " "
  1448.                 << (identifier_token_opt ? lex_stream.NameString(identifier_token_opt) : L"")
  1449.                 << " at nesting_level " << nesting_level << "\n";
  1450.     }
  1451.  
  1452.     void AstReturnStatement::Print(LexStream& lex_stream)
  1453.     {
  1454.         Coutput << "#" << this -> id << " (ReturnStatement):  "
  1455.                 << lex_stream.NameString(return_token)
  1456.                 << " "
  1457.                 << " #" << (expression_opt ? expression_opt -> id : 0) << "\n";
  1458.         if (expression_opt)
  1459.             expression_opt -> Print(lex_stream);
  1460.     }
  1461.  
  1462.     void AstThrowStatement::Print(LexStream& lex_stream)
  1463.     {
  1464.         Coutput << "#" << this -> id << " (ThrowStatement):  "
  1465.                 << lex_stream.NameString(throw_token)
  1466.                 << " "
  1467.                 << " #" << expression -> id << "\n";
  1468.         expression -> Print(lex_stream);
  1469.     }
  1470.  
  1471.     void AstSynchronizedStatement::Print(LexStream& lex_stream)
  1472.     {
  1473.         Coutput << "#" << this -> id << " (SynchronizedStatement):  "
  1474.                 << lex_stream.NameString(synchronized_token)
  1475.                 << " ( #" << expression -> id
  1476.                 << " ) #" << block -> id << "\n";
  1477.         expression -> Print(lex_stream);
  1478.         block -> Print(lex_stream);
  1479.     }
  1480.  
  1481.     void AstCatchClause::Print(LexStream& lex_stream)
  1482.     {
  1483.         Coutput << "#" << this -> id << " (CatchClause):  "
  1484.                 << lex_stream.NameString(catch_token)
  1485.                 << " #" << formal_parameter -> id
  1486.                 << " #" << block -> id << "\n";
  1487.         formal_parameter -> Print(lex_stream);
  1488.         block -> Print(lex_stream);
  1489.     }
  1490.  
  1491.     void AstFinallyClause::Print(LexStream& lex_stream)
  1492.     {
  1493.         Coutput << "#" << this -> id << " (FinallyClause):  "
  1494.                 << lex_stream.NameString(finally_token)
  1495.                 << " #" << block -> id << "\n";
  1496.         block -> Print(lex_stream);
  1497.     }
  1498.  
  1499.     void AstTryStatement::Print(LexStream& lex_stream)
  1500.     {
  1501.         Coutput << "#" << this -> id << " (TryStatement):  "
  1502.                 << lex_stream.NameString(try_token)
  1503.                 << " #" << block -> id
  1504.                 << " catch (";
  1505.         for (int i = 0; i < this -> NumCatchClauses(); i++)
  1506.             Coutput << " #" << this -> CatchClause(i) -> id;
  1507.         Coutput << ") finally " << "#" << (finally_clause_opt ? finally_clause_opt -> id : 0) << "\n";
  1508.  
  1509.         block -> Print(lex_stream);
  1510.         for (int k = 0; k < this -> NumCatchClauses(); k++)
  1511.             this -> CatchClause(k) -> Print(lex_stream);
  1512.         if (finally_clause_opt)
  1513.             finally_clause_opt -> Print(lex_stream);
  1514.     }
  1515.  
  1516.     void AstIntegerLiteral::Print(LexStream& lex_stream)
  1517.     {
  1518.         Coutput << "#" << this -> id << " (IntegerLiteral):  "
  1519.                 << lex_stream.NameString(integer_literal_token)
  1520.                 << "\n";
  1521.     }
  1522.  
  1523.     void AstLongLiteral::Print(LexStream& lex_stream)
  1524.     {
  1525.         Coutput << "#" << this -> id << " (LongLiteral):  "
  1526.                 << lex_stream.NameString(long_literal_token)
  1527.                 << "\n";
  1528.     }
  1529.  
  1530.     void AstFloatingPointLiteral::Print(LexStream& lex_stream)
  1531.     {
  1532.         Coutput << "#" << this -> id << " (FloatingPointLiteral):  "
  1533.                 << lex_stream.NameString(floating_point_literal_token)
  1534.                 << "\n";
  1535.     }
  1536.  
  1537.     void AstDoubleLiteral::Print(LexStream& lex_stream)
  1538.     {
  1539.         Coutput << "#" << this -> id << " (DoubleLiteral):  "
  1540.                 << lex_stream.NameString(double_literal_token)
  1541.                 << "\n";
  1542.     }
  1543.  
  1544.     void AstTrueLiteral::Print(LexStream& lex_stream)
  1545.     {
  1546.         Coutput << "#" << this -> id << " (TrueLiteral):  "
  1547.                 << lex_stream.NameString(true_literal_token)
  1548.                 << "\n";
  1549.     }
  1550.  
  1551.     void AstFalseLiteral::Print(LexStream& lex_stream)
  1552.     {
  1553.         Coutput << "#" << this -> id << " (FalseLiteral):  "
  1554.                 << lex_stream.NameString(false_literal_token)
  1555.                 << "\n";
  1556.     }
  1557.  
  1558.     void AstStringLiteral::Print(LexStream& lex_stream)
  1559.     {
  1560.         Coutput << "#" << this -> id << " (StringLiteral):  "
  1561.                 << lex_stream.NameString(string_literal_token)
  1562.                 << "\n";
  1563.     }
  1564.  
  1565.     void AstCharacterLiteral::Print(LexStream& lex_stream)
  1566.     {
  1567.         Coutput << "#" << this -> id << " (CharacterLiteral):  "
  1568.                 << lex_stream.NameString(character_literal_token)
  1569.                 << "\n";
  1570.     }
  1571.  
  1572.     void AstNullLiteral::Print(LexStream& lex_stream)
  1573.     {
  1574.         Coutput << "#" << this -> id << " (NullLiteral):  "
  1575.                 << lex_stream.NameString(null_token)
  1576.                 << "\n";
  1577.     }
  1578.  
  1579.     void AstThisExpression::Print(LexStream& lex_stream)
  1580.     {
  1581.         Coutput << "#" << this -> id << " (ThisExpression):  "
  1582.                 << lex_stream.NameString(this_token)
  1583.                 << "\n";
  1584.     }
  1585.  
  1586.     void AstSuperExpression::Print(LexStream& lex_stream)
  1587.     {
  1588.         Coutput << "#" << this -> id << " (SuperExpression):  "
  1589.                 << lex_stream.NameString(super_token)
  1590.                 << "\n";
  1591.     }
  1592.  
  1593.     void AstParenthesizedExpression::Print(LexStream& lex_stream)
  1594.     {
  1595.         Coutput << "#" << this -> id << " (ParenthesizedExpression):  "
  1596.                 << lex_stream.NameString(left_parenthesis_token)
  1597.                 << "#" << expression -> id
  1598.                 << lex_stream.NameString(right_parenthesis_token)
  1599.                 << "\n";
  1600.         expression -> Print(lex_stream);
  1601.     }
  1602.  
  1603.     void AstTypeExpression::Print(LexStream& lex_stream)
  1604.     {
  1605.         Coutput << "#" << this -> id << " (TypeExpression):  "
  1606.                 << " #" << type -> id << "\n";
  1607.         type -> Print(lex_stream);
  1608.     }
  1609.  
  1610.     void AstClassInstanceCreationExpression::Print(LexStream& lex_stream)
  1611.     {
  1612.         Coutput << "#" << this -> id << " (ClassInstanceCreationExpression):  ";
  1613.         if (base_opt)
  1614.         {
  1615.             Coutput << "#" << base_opt -> id
  1616.                     << lex_stream.NameString(dot_token_opt) << " ";
  1617.         }
  1618.         Coutput << lex_stream.NameString(new_token)
  1619.                 << " #" << class_type -> id
  1620.                 << " (";
  1621.         for (int i = 0; i < this -> NumArguments(); i++)
  1622.             Coutput << " #" << this -> Argument(i) -> id;
  1623.         Coutput << " ) "
  1624.                 << "#" << (class_body_opt ? class_body_opt -> id : 0) << "\n";
  1625.  
  1626.         if (base_opt)
  1627.             base_opt -> Print(lex_stream);
  1628.  
  1629.         class_type -> Print(lex_stream);
  1630.         for (int j = 0; j < NumArguments(); j++)
  1631.             this -> Argument(j) -> Print(lex_stream);
  1632.  
  1633.         if (class_body_opt)
  1634.             class_body_opt -> Print(lex_stream);
  1635.     }
  1636.  
  1637.     void AstDimExpr::Print(LexStream& lex_stream)
  1638.     {
  1639.         Coutput << "#" << this -> id << " (DimExpr):  [ #" << expression -> id << " ]\n";
  1640.         expression -> Print(lex_stream);
  1641.     }
  1642.  
  1643.     void AstArrayCreationExpression::Print(LexStream& lex_stream)
  1644.     {
  1645.         Coutput << "#" << this -> id << " (ArrayCreationExpression):  "
  1646.                 << lex_stream.NameString(new_token)
  1647.                 << " #" << array_type -> id;
  1648.         for (int i = 0; i < NumDimExprs(); i++)
  1649.             Coutput << " [#" << DimExpr(i) -> id << "]";
  1650.         for (int k = 0; k < NumBrackets(); k++)
  1651.              Coutput << " []";
  1652.         Coutput << " "
  1653.                 << "#" << (array_initializer_opt ? array_initializer_opt -> id : 0) << "\n";
  1654.  
  1655.         array_type -> Print(lex_stream);
  1656.         for (int j = 0; j < this -> NumDimExprs(); j++)
  1657.             DimExpr(j) -> Print(lex_stream);
  1658.     }
  1659.  
  1660.     void AstFieldAccess::Print(LexStream& lex_stream)
  1661.     {
  1662.         Coutput << "#" << this -> id << " (FieldAccess):  "
  1663.                 << " #" << base -> id << " "
  1664.                 << lex_stream.NameString(identifier_token)
  1665.                 << "\n";
  1666.  
  1667.         base -> Print(lex_stream);
  1668.     }
  1669.  
  1670.     void AstMethodInvocation::Print(LexStream& lex_stream)
  1671.     {
  1672.         Coutput << "#" << this -> id << " (MethodInvocation):  "
  1673.                 << "#" << method -> id
  1674.                 << " (";
  1675.         for (int i = 0; i < this -> NumArguments(); i++)
  1676.             Coutput << " #" << this -> Argument(i) -> id;
  1677.         Coutput << " ) \n";
  1678.  
  1679.         method -> Print(lex_stream);
  1680.         for (int j = 0; j < NumArguments(); j++)
  1681.             this -> Argument(j) -> Print(lex_stream);
  1682.     }
  1683.  
  1684.     void AstArrayAccess::Print(LexStream& lex_stream)
  1685.     {
  1686.         Coutput << "#" << this -> id << " (ArrayAccess):  "
  1687.                 << "#" << base -> id
  1688.                 << " [ #" << expression -> id << " ]\n";
  1689.  
  1690.         base -> Print(lex_stream);
  1691.         expression -> Print(lex_stream);
  1692.     }
  1693.  
  1694.     void AstPostUnaryExpression::Print(LexStream& lex_stream)
  1695.     {
  1696.         Coutput << "#" << this -> id << " (PostUnaryExpression):  "
  1697.                 << "#" << expression -> id
  1698.                 << lex_stream.NameString(post_operator_token)
  1699.                 << "\n";
  1700.  
  1701.         expression -> Print(lex_stream);
  1702.     }
  1703.  
  1704.     void AstPreUnaryExpression::Print(LexStream& lex_stream)
  1705.     {
  1706.         Coutput << "#" << this -> id << " (PreUnaryExpression):  "
  1707.                 << lex_stream.NameString(pre_operator_token)
  1708.                 << " #" << expression -> id << "\n";
  1709.  
  1710.         expression -> Print(lex_stream);
  1711.     }
  1712.  
  1713.     void AstCastExpression::Print(LexStream& lex_stream)
  1714.     {
  1715.         if (left_parenthesis_token_opt)
  1716.         {
  1717.           Coutput << "#" << this -> id << (kind == CAST ? " (CastExpression: just cast):  " : " (CastExpression: check and cast):  ")
  1718.                   << "( #" << (type_opt ? type_opt -> id : 0);
  1719.             for (int i = 0; i < NumBrackets(); i++)
  1720.                  Coutput << " []";
  1721.             Coutput << " ) #" << expression -> id << "\n";
  1722.             if (type_opt)
  1723.                 type_opt -> Print(lex_stream);
  1724.         }
  1725.         else
  1726.         {
  1727.             Coutput << "#" << this -> id << " (Java Semantic Cast to " << Type() -> Name()
  1728.                     << "):  #" << expression -> id << "\n";
  1729.         }
  1730.  
  1731.         expression -> Print(lex_stream);
  1732.     }
  1733.  
  1734.     void AstBinaryExpression::Print(LexStream& lex_stream)
  1735.     {
  1736.         Coutput << "#" << this -> id << " (BinaryExpression):  "
  1737.                 << "#" << left_expression -> id << " "
  1738.                 << lex_stream.NameString(binary_operator_token)
  1739.                 << " #" << right_expression -> id << "\n";
  1740.  
  1741.         left_expression -> Print(lex_stream);
  1742.         right_expression -> Print(lex_stream);
  1743.     }
  1744.  
  1745.     void AstConditionalExpression::Print(LexStream& lex_stream)
  1746.     {
  1747.         Coutput << "#" << this -> id << " (ConditionalExpression):  "
  1748.                 << "#" << test_expression -> id
  1749.                 << " ? #" << true_expression -> id
  1750.                 << " : #" << false_expression -> id << "\n";
  1751.  
  1752.         test_expression -> Print(lex_stream);
  1753.         true_expression -> Print(lex_stream);
  1754.         false_expression -> Print(lex_stream);
  1755.     }
  1756.  
  1757.     void AstAssignmentExpression::Print(LexStream& lex_stream)
  1758.     {
  1759.         Coutput << "#" << this -> id << " (AssignmentExpression):  "
  1760.                 << "#" << left_hand_side -> id << " "
  1761.                 << lex_stream.NameString(assignment_operator_token)
  1762.                 << " #" << expression -> id << "\n";
  1763.  
  1764.         left_hand_side -> Print(lex_stream);
  1765.         expression -> Print(lex_stream);
  1766.     }
  1767.  
  1768. #endif
  1769.  
  1770. Ast::~Ast()
  1771. {
  1772.     assert(false);
  1773. }
  1774.  
  1775. AstStatement::~AstStatement()
  1776. {
  1777.     assert(false);
  1778. }
  1779.  
  1780. AstExpression::~AstExpression()
  1781. {
  1782.     assert(false);
  1783. }
  1784.  
  1785. AstBlock::~AstBlock()
  1786. {
  1787.     assert(false);
  1788.     //    delete block_statements;
  1789. }
  1790.  
  1791. AstPrimitiveType::~AstPrimitiveType()
  1792. {
  1793.     assert(false);
  1794. }
  1795.  
  1796. AstArrayType::~AstArrayType()
  1797. {
  1798.     assert(false);
  1799.     //    delete type;
  1800.     //    delete brackets;
  1801. }
  1802.  
  1803. AstSimpleName::~AstSimpleName()
  1804. {
  1805.     assert(false);
  1806.     //    delete resolution_opt;
  1807. }
  1808.  
  1809. AstPackageDeclaration::~AstPackageDeclaration()
  1810. {
  1811.     assert(false);
  1812.     //    delete name;
  1813. }
  1814.  
  1815. AstImportDeclaration::~AstImportDeclaration()
  1816. {
  1817.     assert(false);
  1818.     //    delete name;
  1819. }
  1820.  
  1821. AstCompilationUnit::~AstCompilationUnit()
  1822. {
  1823.     assert(false);
  1824.     //    delete package_declaration_opt;
  1825.     //    delete import_declarations;
  1826.     //    delete type_declarations;
  1827. }
  1828.  
  1829. AstModifier::~AstModifier()
  1830. {
  1831.     assert(false);
  1832. }
  1833.  
  1834. AstEmptyDeclaration::~AstEmptyDeclaration()
  1835. {
  1836.     assert(false);
  1837. }
  1838.  
  1839. AstClassBody::~AstClassBody()
  1840. {
  1841.     assert(false);
  1842.     //    delete default_constructor;
  1843.     //    delete instance_variables;
  1844.     //    delete class_variables;
  1845.     //    delete methods;
  1846.     //    delete constructors;
  1847.     //    delete static_initializers;
  1848.     //    delete inner_classes;
  1849.     //    delete inner_interfaces;
  1850.     //    delete blocks;
  1851.     //    delete class_body_declarations;
  1852.     //    delete this_block;
  1853. }
  1854.  
  1855. AstClassDeclaration::~AstClassDeclaration()
  1856. {
  1857.     assert(false);
  1858.     //    delete class_modifiers;
  1859.     //    delete super_opt;
  1860.     //    delete interfaces;
  1861.     //    delete class_body;
  1862. }
  1863.  
  1864. AstArrayInitializer::~AstArrayInitializer()
  1865. {
  1866.     assert(false);
  1867.     //    delete variable_initializers;
  1868. }
  1869.  
  1870. AstBrackets::~AstBrackets()
  1871. {
  1872.     assert(false);
  1873. }
  1874.  
  1875. AstVariableDeclaratorId::~AstVariableDeclaratorId()
  1876. {
  1877.     assert(false);
  1878.     //    delete brackets;
  1879. }
  1880.  
  1881. AstVariableDeclarator::~AstVariableDeclarator()
  1882. {
  1883.     assert(false);
  1884.     //    delete variable_declarator_name;
  1885.     //    delete variable_initializer_opt;
  1886. }
  1887.  
  1888. AstFieldDeclaration::~AstFieldDeclaration()
  1889. {
  1890.     assert(false);
  1891.     //    delete variable_modifiers;
  1892.     //    delete type;
  1893.     //    delete variable_declarators;
  1894. }
  1895.  
  1896. AstFormalParameter::~AstFormalParameter()
  1897. {
  1898.     assert(false);
  1899.     //    delete parameter_modifiers;
  1900.     //    delete type;
  1901.     //    delete variable_declarator_name;
  1902. }
  1903.  
  1904. AstMethodDeclarator::~AstMethodDeclarator()
  1905. {
  1906.     assert(false);
  1907.     //    delete formal_parameters;
  1908.     //    delete brackets;
  1909. }
  1910.  
  1911. AstMethodDeclaration::~AstMethodDeclaration()
  1912. {
  1913.     assert(false);
  1914.     //    delete method_modifiers;
  1915.     //    delete type;
  1916.     //    delete method_declarator;
  1917.     //    delete throws;
  1918.     //    delete method_body;
  1919. }
  1920.  
  1921. AstStaticInitializer::~AstStaticInitializer()
  1922. {
  1923.     assert(false);
  1924.     //    delete block;
  1925. }
  1926.  
  1927. AstThisCall::~AstThisCall()
  1928. {
  1929.     assert(false);
  1930.     //    delete arguments;
  1931.     //    delete base_opt;
  1932.     //    delete local_arguments_opt;
  1933. }
  1934.  
  1935. AstSuperCall::~AstSuperCall()
  1936. {
  1937.     assert(false);
  1938.     //    delete base_opt;
  1939.     //    delete arguments;
  1940.     //    delete local_arguments_opt;
  1941. }
  1942.  
  1943. AstConstructorBlock::~AstConstructorBlock()
  1944. {
  1945.     assert(false);
  1946.     //    delete explicit_constructor_invocation_opt;
  1947.     //    delete block;
  1948.     //    delete local_init_block;
  1949.     //    delete original_constructor_invocation;
  1950. }
  1951.  
  1952. AstConstructorDeclaration::~AstConstructorDeclaration()
  1953. {
  1954.     assert(false);
  1955.     //    delete constructor_modifiers;
  1956.     //    delete constructor_declarator;
  1957.     //    delete throws;
  1958.     //    delete constructor_body;
  1959. }
  1960.  
  1961. AstInterfaceDeclaration::~AstInterfaceDeclaration()
  1962. {
  1963.     assert(false);
  1964.     //    delete class_variables;
  1965.     //    delete abstract_methods;
  1966.     //    delete inner_classes;
  1967.     //    delete inner_interfaces;
  1968.     //    delete interface_modifiers;
  1969.     //    delete extends_interfaces;
  1970.     //    delete interface_member_declarations;
  1971. }
  1972.  
  1973. AstLocalVariableDeclarationStatement::~AstLocalVariableDeclarationStatement()
  1974. {
  1975.     assert(false);
  1976.     //    delete local_modifiers;
  1977.     //    delete type;
  1978.     //    delete variable_declarators;
  1979. }
  1980.  
  1981. AstIfStatement::~AstIfStatement()
  1982. {
  1983.     assert(false);
  1984.     //    delete expression;
  1985.     //    delete true_statement;
  1986.     //    delete false_statement_opt;
  1987. }
  1988.  
  1989. AstEmptyStatement::~AstEmptyStatement()
  1990. {
  1991.     assert(false);
  1992. }
  1993.  
  1994. AstExpressionStatement::~AstExpressionStatement()
  1995. {
  1996.     assert(false);
  1997.     //    delete expression;
  1998. }
  1999.  
  2000. AstCaseLabel::~AstCaseLabel()
  2001. {
  2002.     assert(false);
  2003.     //    delete expression;
  2004. }
  2005.  
  2006. AstDefaultLabel::~AstDefaultLabel()
  2007. {
  2008.     assert(false);
  2009. }
  2010.  
  2011. AstSwitchBlockStatement::~AstSwitchBlockStatement()
  2012. {
  2013.     assert(false);
  2014.     //    delete switch_labels;
  2015.     //    delete block_statements;
  2016. }
  2017.  
  2018. AstSwitchStatement::~AstSwitchStatement()
  2019. {
  2020.     assert(false);
  2021.     //    delete expression;
  2022.     //    delete switch_block;
  2023. }
  2024.  
  2025. AstWhileStatement::~AstWhileStatement()
  2026. {
  2027.     assert(false);
  2028.     //    delete expression;
  2029.     //    delete statement;
  2030. }
  2031.  
  2032. AstDoStatement::~AstDoStatement()
  2033. {
  2034.     assert(false);
  2035.     //    delete statement;
  2036.     //    delete expression;
  2037. }
  2038.  
  2039. AstForStatement::~AstForStatement()
  2040. {
  2041.     assert(false);
  2042.     //    delete for_init_statements;
  2043.     //    delete end_expression_opt;
  2044.     //    delete for_update_statements;
  2045.     //    delete statement;
  2046. }
  2047.  
  2048. AstBreakStatement::~AstBreakStatement()
  2049. {
  2050.     assert(false);
  2051. }
  2052.  
  2053. AstContinueStatement::~AstContinueStatement()
  2054. {
  2055.     assert(false);
  2056. }
  2057.  
  2058. AstReturnStatement::~AstReturnStatement()
  2059. {
  2060.     assert(false);
  2061.     //    delete expression_opt;
  2062. }
  2063.  
  2064. AstThrowStatement::~AstThrowStatement()
  2065. {
  2066.     assert(false);
  2067.     //    delete expression;
  2068. }
  2069.  
  2070. AstSynchronizedStatement::~AstSynchronizedStatement()
  2071. {
  2072.     assert(false);
  2073.     //    delete expression;
  2074.     //    delete block;
  2075. }
  2076.  
  2077. AstCatchClause::~AstCatchClause()
  2078. {
  2079.     assert(false);
  2080.     //    delete formal_parameter;
  2081.     //    delete block;
  2082. }
  2083.  
  2084. AstFinallyClause::~AstFinallyClause()
  2085. {
  2086.     assert(false);
  2087.     //    delete block;
  2088. }
  2089.  
  2090. AstTryStatement::~AstTryStatement()
  2091. {
  2092.     assert(false);
  2093.     //    delete block;
  2094.     //    delete catch_clauses;
  2095.     //    delete finally_clause_opt;
  2096. }
  2097.  
  2098. AstIntegerLiteral::~AstIntegerLiteral()
  2099. {
  2100.     assert(false);
  2101. }
  2102.  
  2103. AstLongLiteral::~AstLongLiteral()
  2104. {
  2105.     assert(false);
  2106. }
  2107.  
  2108. AstFloatingPointLiteral::~AstFloatingPointLiteral()
  2109. {
  2110.     assert(false);
  2111. }
  2112.  
  2113. AstDoubleLiteral::~AstDoubleLiteral()
  2114. {
  2115.     assert(false);
  2116. }
  2117.  
  2118. AstTrueLiteral::~AstTrueLiteral()
  2119. {
  2120.     assert(false);
  2121. }
  2122.  
  2123. AstFalseLiteral::~AstFalseLiteral()
  2124. {
  2125.     assert(false);
  2126. }
  2127.  
  2128. AstStringLiteral::~AstStringLiteral()
  2129. {
  2130.     assert(false);
  2131. }
  2132.  
  2133. AstCharacterLiteral::~AstCharacterLiteral()
  2134. {
  2135.     assert(false);
  2136. }
  2137.  
  2138. AstNullLiteral::~AstNullLiteral()
  2139. {
  2140.     assert(false);
  2141. }
  2142.  
  2143. AstThisExpression::~AstThisExpression()
  2144. {
  2145.     assert(false);
  2146. }
  2147.  
  2148. AstSuperExpression::~AstSuperExpression()
  2149. {
  2150.     assert(false);
  2151. }
  2152.  
  2153. AstParenthesizedExpression::~AstParenthesizedExpression()
  2154. {
  2155.     assert(false);
  2156.     //    delete expression;
  2157. }
  2158.  
  2159. AstTypeExpression::~AstTypeExpression()
  2160. {
  2161.     assert(false);
  2162.     //    delete type;
  2163. }
  2164.  
  2165. AstClassInstanceCreationExpression::~AstClassInstanceCreationExpression()
  2166. {
  2167.     assert(false);
  2168.     //    delete base_opt;
  2169.     //    delete class_type;
  2170.     //    delete arguments;
  2171.     //    delete class_body_opt;
  2172.     //    delete local_arguments_opt;
  2173. }
  2174.  
  2175. AstDimExpr::~AstDimExpr()
  2176. {
  2177.     assert(false);
  2178.     //    delete expression;
  2179. }
  2180.  
  2181. AstArrayCreationExpression::~AstArrayCreationExpression()
  2182. {
  2183.     assert(false);
  2184.     //    delete array_type;
  2185.     //    delete dim_exprs;
  2186.     //    delete brackets;
  2187.     //    delete array_initializer_opt;
  2188. }
  2189.  
  2190. AstFieldAccess::~AstFieldAccess()
  2191. {
  2192.     assert(false);
  2193.     //    delete base;
  2194.     //    delete resolution_opt;
  2195. }
  2196.  
  2197. AstMethodInvocation::~AstMethodInvocation()
  2198. {
  2199.     assert(false);
  2200.     //    delete method;
  2201.     //    delete arguments;
  2202.     //    delete resolution_opt;
  2203. }
  2204.  
  2205. AstArrayAccess::~AstArrayAccess()
  2206. {
  2207.     assert(false);
  2208.     //    delete base;
  2209.     //    delete expression;
  2210. }
  2211.  
  2212. AstPostUnaryExpression::~AstPostUnaryExpression()
  2213. {
  2214.     assert(false);
  2215.     //    delete expression;
  2216. }
  2217.  
  2218. AstPreUnaryExpression::~AstPreUnaryExpression()
  2219. {
  2220.     assert(false);
  2221.     //    delete expression;
  2222. }
  2223.  
  2224. AstCastExpression::~AstCastExpression()
  2225. {
  2226.     assert(false);
  2227.     //    delete type_opt;
  2228.     //    delete brackets;
  2229.     //    delete expression;
  2230. }
  2231.  
  2232. AstBinaryExpression::~AstBinaryExpression()
  2233. {
  2234.    assert(false);
  2235.    //    delete left_expression;
  2236.    //    delete right_expression;
  2237. }
  2238.  
  2239. AstConditionalExpression::~AstConditionalExpression()
  2240. {
  2241.     assert(false);
  2242.     //    delete test_expression;
  2243.     //    delete true_expression;
  2244.     //    delete false_expression;
  2245. }
  2246.  
  2247. AstAssignmentExpression::~AstAssignmentExpression()
  2248. {
  2249.     assert(false);
  2250.     //    delete left_hand_side;
  2251.     //    delete expression;
  2252. }
  2253.