001//
002// Generated by JTB 1.3.2
003//
004package jtb.visitor;
005
006import jtb.syntaxtree.*;
007import java.util.*;
008
009// A skeleton output formatter for your language grammar.  Using the
010// add() method along with force(), indent(), and outdent(), you can
011// easily specify how this visitor will format the given syntax tree.
012// See the JTB documentation for more details.
013// 
014// Pass your syntax tree to this visitor, and then to the TreeDumper
015// visitor in order to "pretty print" your tree.
016
017// Added by hand to eliminate Enumeration warnings.  (markro)
018@SuppressWarnings("rawtypes")
019public class TreeFormatter extends DepthFirstVisitor {
020   private List<FormatCommand> cmdQueue = new ArrayList<FormatCommand>();
021   private boolean lineWrap;
022   private int wrapWidth;
023   private int indentAmt;
024   private int curLine = 1;
025   private int curColumn = 1;
026   private int curIndent = 0;
027
028   // The default constructor assumes an indentation amount of 3 spaces
029   // and no line-wrap.  You may alternately use the other constructor to
030   // specify your own indentation amount and line width.
031   public TreeFormatter() { this(3, 0); }
032
033   // This constructor accepts an indent amount and a line width which is
034   // used to wrap long lines.  If a token's beginColumn value is greater
035   // than the specified wrapWidth, it will be moved to the next line and
036   // indented one extra level.  To turn off line-wrapping, specify a
037   // wrapWidth of 0.
038   // 
039   // @param   indentAmt   Amount of spaces per indentation level.
040   // @param   wrapWidth   Wrap lines longer than wrapWidth.  0 for no wrap.
041   public TreeFormatter(int indentAmt, int wrapWidth) {
042      this.indentAmt = indentAmt;
043      this.wrapWidth = wrapWidth;
044
045      if ( wrapWidth > 0 )
046         lineWrap = true;
047      else
048         lineWrap = false;
049   }
050
051   // Accepts a NodeListInterface object and performs an optional format
052   // command between each node in the list (but not after the last node).
053   protected void processList(NodeListInterface n) {
054      processList(n, null);
055   }
056
057   protected void processList(NodeListInterface n, FormatCommand cmd) {
058      for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
059         e.nextElement().accept(this);
060         if ( cmd != null && e.hasMoreElements() )
061            cmdQueue.add(cmd);
062      }
063   }
064
065   // A Force command inserts a line break and indents the next line to
066   // the current indentation level.  Use "add(force());".
067   protected FormatCommand force() { return force(1); }
068   protected FormatCommand force(int i) {
069      return new FormatCommand(FormatCommand.FORCE, i);
070   }
071
072   // An Indent command increases the indentation level by one (or a
073   // user-specified amount).  Use "add(indent());".
074   protected FormatCommand indent() { return indent(1); }
075   protected FormatCommand indent(int i) {
076      return new FormatCommand(FormatCommand.INDENT, i);
077   }
078
079   // An Outdent command is the reverse of the Indent command: it reduces
080   // the indentation level.  Use "add(outdent());".
081   protected FormatCommand outdent() { return outdent(1); }
082   protected FormatCommand outdent(int i) {
083      return new FormatCommand(FormatCommand.OUTDENT, i);
084   }
085
086   // A Space command simply adds one or a user-specified number of
087   // spaces between tokens.  Use "add(space());".
088   protected FormatCommand space() { return space(1); }
089   protected FormatCommand space(int i) {
090      return new FormatCommand(FormatCommand.SPACE, i);
091   }
092
093   // Use this method to add FormatCommands to the command queue to be
094   // executed when the next token in the tree is visited.
095   protected void add(FormatCommand cmd) {
096      cmdQueue.add(cmd);
097   }
098
099   // Executes the commands waiting in the command queue, then inserts the
100   // proper location information into the current NodeToken.
101   // 
102   // If there are any special tokens preceding this token, they will be
103   // given the current location information.  The token will follow on
104   // the next line, at the proper indentation level.  If this is not the
105   // behavior you want from special tokens, feel free to modify this
106   // method.
107   public void visit(NodeToken n) {
108      for ( FormatCommand cmd : cmdQueue ) {
109         switch ( cmd.getCommand() ) {
110         case FormatCommand.FORCE :
111            curLine += cmd.getNumCommands();
112            curColumn = curIndent + 1;
113            break;
114         case FormatCommand.INDENT :
115            curIndent += indentAmt * cmd.getNumCommands();
116            break;
117         case FormatCommand.OUTDENT :
118            if ( curIndent >= indentAmt )
119               curIndent -= indentAmt * cmd.getNumCommands();
120            break;
121         case FormatCommand.SPACE :
122            curColumn += cmd.getNumCommands();
123            break;
124         default :
125            throw new TreeFormatterException(
126               "Invalid value in command queue.");
127         }
128      }
129
130      cmdQueue.clear();
131
132      //
133      // Handle all special tokens preceding this NodeToken
134      //
135      if ( n.numSpecials() > 0 )
136         for ( Enumeration<NodeToken> e = n.specialTokens.elements();
137               e.hasMoreElements(); ) {
138            NodeToken special = e.nextElement();
139
140            //
141            // -Place the token.
142            // -Move cursor to next line after the special token.
143            // -Don't update curColumn--want to keep current indent level.
144            //
145            placeToken(special, curLine, curColumn);
146            curLine = special.endLine + 1;
147         }
148
149      placeToken(n, curLine, curColumn);
150      curLine = n.endLine;
151      curColumn = n.endColumn;
152   }
153
154   // Inserts token location (beginLine, beginColumn, endLine, endColumn)
155   // information into the NodeToken.  Takes into account line-wrap.
156   // Does not update curLine and curColumn.
157   private void placeToken(NodeToken n, int line, int column) {
158      int length = n.tokenImage.length();
159
160      //
161      // Find beginning of token.  Only line-wrap for single-line tokens
162      //
163      if ( !lineWrap || n.tokenImage.indexOf('\n') != -1 ||
164           column + length <= wrapWidth )
165         n.beginColumn = column;
166      else {
167         ++line;
168         column = curIndent + indentAmt + 1;
169         n.beginColumn = column;
170      }
171
172      n.beginLine = line;
173
174      //
175      // Find end of token; don't count \n if it's the last character
176      //
177      for ( int i = 0; i < length; ++i ) {
178         if ( n.tokenImage.charAt(i) == '\n' && i < length - 1 ) {
179            ++line;
180            column = 1;
181         }
182         else
183            ++column;
184      }
185
186      n.endLine = line;
187      n.endColumn = column;
188   }
189
190   //
191   // User-generated visitor methods below
192   //
193
194   // Note: the member variable 'which' is used to identify
195   // which of the possibilities for a grammar rule production
196   // actually occured.  The first possibility is 'which == 0'
197   // and the values increase sequentially from left to right.
198
199   // f0 -> [ PackageDeclaration() ]
200   // f1 -> ( ImportDeclaration() )*
201   // f2 -> ( TypeDeclaration() )*
202   // f3 -> ( <"\u001a"> )?
203   // f4 -> ( <STUFF_TO_IGNORE: ~[]> )?
204   // f5 -> <EOF>
205   public void visit(CompilationUnit n) {
206      if ( n.f0.present() ) {
207         n.f0.accept(this);
208         add(force(2));
209      }
210      if ( n.f1.present() ) {
211         processList(n.f1, force());
212         add(force(2));
213      }
214      if ( n.f2.present() ) {
215         processList(n.f2, force(2));
216         add(force());
217      }
218      if ( n.f3.present() ) {
219         n.f3.accept(this);
220      }
221      if ( n.f4.present() ) {
222         n.f4.accept(this);
223      }
224      n.f5.accept(this);
225   }
226
227   // f0 -> Modifiers()
228   // f1 -> "package"
229   // f2 -> Name()
230   // f3 -> ";"
231   public void visit(PackageDeclaration n) {
232      n.f0.accept(this);
233      n.f1.accept(this);
234      add(space());
235      n.f2.accept(this);
236      n.f3.accept(this);
237   }
238
239   // f0 -> "import"
240   // f1 -> [ "static" ]
241   // f2 -> Name()
242   // f3 -> [ "." "*" ]
243   // f4 -> ";"
244   public void visit(ImportDeclaration n) {
245      n.f0.accept(this);
246      add(space());
247      if ( n.f1.present() ) {
248         n.f1.accept(this);
249         add(space());
250      }
251      n.f2.accept(this);
252      if ( n.f3.present() ) {
253         n.f3.accept(this);
254      }
255      n.f4.accept(this);
256   }
257
258   // f0 -> ( ( "public" | "static" | "protected" | "private" | "final" | "abstract" | "synchronized" | "native" | "transient" | "volatile" | "strictfp" | Annotation() ) )*
259   public void visit(Modifiers n) {
260      if ( n.f0.present() ) {
261         processList(n.f0, space());
262         add(space());
263      }
264   }
265
266   // f0 -> ";"
267   //       | Modifiers() ( ClassOrInterfaceDeclaration(modifiers) | EnumDeclaration(modifiers) | AnnotationTypeDeclaration(modifiers) )
268   public void visit(TypeDeclaration n) {
269      n.f0.accept(this);
270   }
271
272   // f0 -> ( "class" | "interface" )
273   // f1 -> <IDENTIFIER>
274   // f2 -> [ TypeParameters() ]
275   // f3 -> [ ExtendsList(isInterface) ]
276   // f4 -> [ ImplementsList(isInterface) ]
277   // f5 -> ClassOrInterfaceBody(isInterface)
278   public void visit(ClassOrInterfaceDeclaration n) {
279      n.f0.accept(this);
280      add(space());
281      n.f1.accept(this);
282      add(space());
283      if ( n.f2.present() ) {
284         n.f2.accept(this);
285         add(space());
286      }
287      if ( n.f3.present() ) {
288         n.f3.accept(this);
289         add(space());
290      }
291      if ( n.f4.present() ) {
292         n.f4.accept(this);
293         add(space());
294      }
295      add(force());
296      n.f5.accept(this);
297   }
298
299   // f0 -> "extends"
300   // f1 -> ClassOrInterfaceType()
301   // f2 -> ( "," ClassOrInterfaceType() )*
302   public void visit(ExtendsList n) {
303      n.f0.accept(this);
304      add(space());
305      n.f1.accept(this);
306      add(space());
307      if ( n.f2.present() ) {
308         processList(n.f2, space());
309      }
310   }
311
312   // f0 -> "implements"
313   // f1 -> ClassOrInterfaceType()
314   // f2 -> ( "," ClassOrInterfaceType() )*
315   public void visit(ImplementsList n) {
316      n.f0.accept(this);
317      add(space());
318      n.f1.accept(this);
319      add(space());
320      if ( n.f2.present() ) {
321         processList(n.f2, space());
322      }
323   }
324
325   // f0 -> "enum"
326   // f1 -> <IDENTIFIER>
327   // f2 -> [ ImplementsList(false) ]
328   // f3 -> EnumBody()
329   public void visit(EnumDeclaration n) {
330      n.f0.accept(this);
331      add(space());
332      n.f1.accept(this);
333      add(space());
334      if ( n.f2.present() ) {
335         n.f2.accept(this);
336         add(space());
337      }
338      n.f3.accept(this);
339      add(space());
340   }
341
342   // f0 -> "{"
343   // f1 -> [ EnumConstant() ( "," EnumConstant() )* ]
344   // f2 -> [ "," ]
345   // f3 -> [ ";" ( ClassOrInterfaceBodyDeclaration(false) )* ]
346   // f4 -> "}"
347   public void visit(EnumBody n) {
348      n.f0.accept(this);
349      add(space());
350      if ( n.f1.present() ) {
351         processList((NodeSequence)n.f1.node, space());
352         add(space());
353      }
354      if ( n.f2.present() ) {
355         n.f2.accept(this);
356         add(space());
357      }
358      if ( n.f3.present() ) {
359         processList((NodeSequence)n.f3.node, space());
360         add(space());
361      }
362      n.f4.accept(this);
363   }
364
365   // f0 -> Modifiers()
366   // f1 -> <IDENTIFIER>
367   // f2 -> [ Arguments() ]
368   // f3 -> [ ClassOrInterfaceBody(false) ]
369   public void visit(EnumConstant n) {
370      n.f0.accept(this);
371      n.f1.accept(this);
372      add(space());
373      if ( n.f2.present() ) {
374         n.f2.accept(this);
375         add(space());
376      }
377      if ( n.f3.present() ) {
378         n.f3.accept(this);
379         add(space());
380      }
381   }
382
383   // f0 -> "<"
384   // f1 -> TypeParameter()
385   // f2 -> ( "," TypeParameter() )*
386   // f3 -> ">"
387   public void visit(TypeParameters n) {
388      n.f0.accept(this);
389      n.f1.accept(this);
390      if ( n.f2.present() ) {
391         processList(n.f2, space());
392      }
393      n.f3.accept(this);
394   }
395
396   // f0 -> <IDENTIFIER>
397   // f1 -> [ TypeBound() ]
398   public void visit(TypeParameter n) {
399      n.f0.accept(this);
400      add(space());
401      if ( n.f1.present() ) {
402         n.f1.accept(this);
403      }
404   }
405
406   // f0 -> "extends"
407   // f1 -> ClassOrInterfaceType()
408   // f2 -> ( "&" ClassOrInterfaceType() )*
409   public void visit(TypeBound n) {
410      n.f0.accept(this);
411      add(space());
412      n.f1.accept(this);
413      add(space());
414      if ( n.f2.present() ) {
415         processList(n.f2, space());
416      }
417   }
418
419   // f0 -> "{"
420   // f1 -> ( ClassOrInterfaceBodyDeclaration(isInterface) )*
421   // f2 -> "}"
422   public void visit(ClassOrInterfaceBody n) {
423      n.f0.accept(this);
424      add(indent());
425      if(n.f1.present()) {
426         add(force());
427         Enumeration e = n.f1.elements();
428         do {
429            if(!e.hasMoreElements())
430               break;
431            NodeChoice choice = ((ClassOrInterfaceBodyDeclaration)e.nextElement()).f0;
432            choice.accept(this);
433            if(!e.hasMoreElements())
434               break;
435            switch(choice.which) {
436            case 4: // '\004'
437               add(force());
438               break;
439
440            default:
441               add(force(2));
442               break;
443            }
444         } while(true);
445      }
446      add(outdent());
447      add(force());
448      n.f2.accept(this);
449   }
450
451   // f0 -> Initializer()
452   //       | Modifiers() ( ClassOrInterfaceDeclaration(modifiers) | EnumDeclaration(modifiers) | ConstructorDeclaration() | FieldDeclaration(modifiers) | MethodDeclaration(modifiers) | AnnotationTypeDeclaration(modifiers) )
453   //       | ";"
454   public void visit(ClassOrInterfaceBodyDeclaration n) {
455      n.f0.accept(this);
456   }
457
458   // f0 -> Type()
459   // f1 -> VariableDeclarator()
460   // f2 -> ( "," VariableDeclarator() )*
461   // f3 -> ";"
462   public void visit(FieldDeclaration n) {
463      n.f0.accept(this);
464      add(space());
465      n.f1.accept(this);
466      add(space());
467      if ( n.f2.present() ) {
468         for(Enumeration e = n.f2.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space()));
469      }
470      n.f3.accept(this);
471   }
472
473   // f0 -> VariableDeclaratorId()
474   // f1 -> [ "=" VariableInitializer() ]
475   public void visit(VariableDeclarator n) {
476      n.f0.accept(this);
477      if ( n.f1.present() ) {
478         add(space());
479         processList((NodeSequence)n.f1.node, space());
480      }
481   }
482
483   // f0 -> <IDENTIFIER>
484   // f1 -> ( "[" "]" )*
485   public void visit(VariableDeclaratorId n) {
486      n.f0.accept(this);
487      if ( n.f1.present() ) {
488         processList(n.f1);
489      }
490   }
491
492   // f0 -> ArrayInitializer()
493   //       | Expression()
494   public void visit(VariableInitializer n) {
495      n.f0.accept(this);
496   }
497
498   // f0 -> "{"
499   // f1 -> [ VariableInitializer() ( "," VariableInitializer() )* ]
500   // f2 -> [ "," ]
501   // f3 -> "}"
502   public void visit(ArrayInitializer n) {
503      n.f0.accept(this);
504      if ( n.f1.present() ) {
505         NodeSequence seq = (NodeSequence)n.f1.node;
506         NodeListOptional nlo = (NodeListOptional)seq.elementAt(1);
507         add(space());
508         seq.elementAt(0).accept(this);
509         for(Enumeration e = nlo.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space()));
510      }
511      if ( n.f2.present() ) {
512         n.f2.accept(this);
513      }
514      add(space());
515      n.f3.accept(this);
516   }
517
518   // f0 -> [ TypeParameters() ]
519   // f1 -> ResultType()
520   // f2 -> MethodDeclarator()
521   // f3 -> [ "throws" NameList() ]
522   // f4 -> ( Block() | ";" )
523   public void visit(MethodDeclaration n) {
524      if ( n.f0.present() ) {
525         n.f0.accept(this);
526         add(space());
527      }
528      n.f1.accept(this);
529      add(space());
530      n.f2.accept(this);
531      if ( n.f3.present() ) {
532         add(space());
533         processList((NodeSequence)n.f3.node, space());
534      }
535      if(n.f4.which == 0) {
536         add(force());
537      }
538      n.f4.accept(this);
539   }
540
541   // f0 -> <IDENTIFIER>
542   // f1 -> FormalParameters()
543   // f2 -> ( "[" "]" )*
544   public void visit(MethodDeclarator n) {
545      n.f0.accept(this);
546      n.f1.accept(this);
547      if ( n.f2.present() ) {
548         processList(n.f2);
549      }
550   }
551
552   // f0 -> "("
553   // f1 -> [ FormalParameter() ( "," FormalParameter() )* ]
554   // f2 -> ")"
555   public void visit(FormalParameters n) {
556      n.f0.accept(this);
557      if ( n.f1.present() ) {
558         NodeSequence seq = (NodeSequence)n.f1.node;
559         NodeListOptional nlo = (NodeListOptional)seq.elementAt(1);
560         seq.elementAt(0).accept(this);
561         for(Enumeration e = nlo.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space()));
562      }
563      n.f2.accept(this);
564   }
565
566   // f0 -> Modifiers()
567   // f1 -> [ "final" | Annotation() ]
568   // f2 -> Type()
569   // f3 -> [ "..." ]
570   // f4 -> VariableDeclaratorId()
571   public void visit(FormalParameter n) {
572      n.f0.accept(this);
573      if ( n.f1.present() ) {
574         n.f1.accept(this);
575         add(space());
576      }
577      n.f2.accept(this);
578      add(space());
579      if ( n.f3.present() ) {
580         n.f3.accept(this);
581         add(space());
582      }
583      n.f4.accept(this);
584   }
585
586   // f0 -> [ TypeParameters() ]
587   // f1 -> <IDENTIFIER>
588   // f2 -> FormalParameters()
589   // f3 -> [ "throws" NameList() ]
590   // f4 -> "{"
591   // f5 -> [ ExplicitConstructorInvocation() ]
592   // f6 -> ( BlockStatement() )*
593   // f7 -> "}"
594   public void visit(ConstructorDeclaration n) {
595      if ( n.f0.present() ) {
596         n.f0.accept(this);
597         add(space());
598      }
599      n.f1.accept(this);
600      n.f2.accept(this);
601      if ( n.f3.present() ) {
602         add(space());
603         processList((NodeSequence)n.f3.node, space());
604      }
605      add(force());
606      n.f4.accept(this);
607      add(indent());
608      if ( n.f5.present() ) {
609         add(force());
610         n.f5.accept(this);
611      }
612      if ( n.f6.present() ) {
613         add(force());
614         processList(n.f6,force());
615      }
616      add(outdent());
617      add(force());
618      n.f7.accept(this);
619   }
620
621   // f0 -> [ TypeArguments() ] ( "this" | "super" ) Arguments() ";"
622   //       | PrimaryExpression() "." [ TypeArguments() ] "super" Arguments() ";"
623   public void visit(ExplicitConstructorInvocation n) {
624      n.f0.accept(this);
625   }
626
627   // f0 -> [ "static" ]
628   // f1 -> Block()
629   public void visit(Initializer n) {
630      if ( n.f0.present() ) {
631         n.f0.accept(this);
632         add(force());
633      }
634      n.f1.accept(this);
635   }
636
637   // f0 -> ReferenceType()
638   //       | PrimitiveType()
639   public void visit(Type n) {
640      n.f0.accept(this);
641   }
642
643   // f0 -> PrimitiveType() ( "[" "]" )+
644   //       | ( ClassOrInterfaceType() ) ( "[" "]" )*
645   public void visit(ReferenceType n) {
646      n.f0.accept(this);
647   }
648
649   // f0 -> <IDENTIFIER>
650   // f1 -> [ TypeArguments() ]
651   // f2 -> ( "." <IDENTIFIER> [ TypeArguments() ] )*
652   public void visit(ClassOrInterfaceType n) {
653      n.f0.accept(this);
654      if ( n.f1.present() ) {
655         n.f1.accept(this);
656      }
657      if ( n.f2.present() ) {
658         processList(n.f2);
659      }
660   }
661
662   // f0 -> "<"
663   // f1 -> TypeArgument()
664   // f2 -> ( "," TypeArgument() )*
665   // f3 -> ">"
666   public void visit(TypeArguments n) {
667      n.f0.accept(this);
668      n.f1.accept(this);
669      if ( n.f2.present() ) {
670         processList(n.f2);
671      }
672      n.f3.accept(this);
673   }
674
675   // f0 -> ReferenceType()
676   //       | "?" [ WildcardBounds() ]
677   public void visit(TypeArgument n) {
678      if(n.f0.which == 0)
679         n.f0.accept(this);
680      else
681         processList((NodeSequence)n.f0.choice, space());
682   }
683
684   // f0 -> "extends" ReferenceType()
685   //       | "super" ReferenceType()
686   public void visit(WildcardBounds n) {
687      processList((NodeSequence)n.f0.choice, space());
688   }
689
690   // f0 -> "boolean"
691   //       | "char"
692   //       | "byte"
693   //       | "short"
694   //       | "int"
695   //       | "long"
696   //       | "float"
697   //       | "double"
698   public void visit(PrimitiveType n) {
699      n.f0.accept(this);
700   }
701
702   // f0 -> "void"
703   //       | Type()
704   public void visit(ResultType n) {
705      n.f0.accept(this);
706   }
707
708   // f0 -> <IDENTIFIER>
709   // f1 -> ( "." <IDENTIFIER> )*
710   public void visit(Name n) {
711      n.f0.accept(this);
712      if ( n.f1.present() ) {
713         processList(n.f1);
714      }
715   }
716
717   // f0 -> Name()
718   // f1 -> ( "," Name() )*
719   public void visit(NameList n) {
720      n.f0.accept(this);
721      if ( n.f1.present() ) {
722         for(Enumeration e = n.f1.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space()));
723      }
724   }
725
726   // f0 -> ConditionalExpression()
727   // f1 -> [ AssignmentOperator() Expression() ]
728   public void visit(Expression n) {
729      n.f0.accept(this);
730      if ( n.f1.present() ) {
731         add(space());
732         processList((NodeSequence)n.f1.node, space());
733      }
734   }
735
736   // f0 -> "="
737   //       | "*="
738   //       | "/="
739   //       | "%="
740   //       | "+="
741   //       | "-="
742   //       | "<<="
743   //       | ">>="
744   //       | ">>>="
745   //       | "&="
746   //       | "^="
747   //       | "|="
748   public void visit(AssignmentOperator n) {
749      n.f0.accept(this);
750   }
751
752   // f0 -> ConditionalOrExpression()
753   // f1 -> [ "?" Expression() ":" Expression() ]
754   public void visit(ConditionalExpression n) {
755      n.f0.accept(this);
756      if ( n.f1.present() ) {
757         add(space());
758         processList((NodeSequence)n.f1.node, space());
759      }
760   }
761
762   // f0 -> ConditionalAndExpression()
763   // f1 -> ( "||" ConditionalAndExpression() )*
764   public void visit(ConditionalOrExpression n) {
765      n.f0.accept(this);
766      if ( n.f1.present() ) {
767         for(Enumeration e = n.f1.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space())) {
768            add(space());
769         }
770      }
771   }
772
773   // f0 -> InclusiveOrExpression()
774   // f1 -> ( "&&" InclusiveOrExpression() )*
775   public void visit(ConditionalAndExpression n) {
776      n.f0.accept(this);
777      if ( n.f1.present() ) {
778         for(Enumeration e = n.f1.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space())) {
779            add(space());
780         }
781      }
782   }
783
784   // f0 -> ExclusiveOrExpression()
785   // f1 -> ( "|" ExclusiveOrExpression() )*
786   public void visit(InclusiveOrExpression n) {
787      n.f0.accept(this);
788      if ( n.f1.present() ) {
789         for(Enumeration e = n.f1.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space())) {
790            add(space());
791         }
792      }
793   }
794
795   // f0 -> AndExpression()
796   // f1 -> ( "^" AndExpression() )*
797   public void visit(ExclusiveOrExpression n) {
798      n.f0.accept(this);
799      if ( n.f1.present() ) {
800         for(Enumeration e = n.f1.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space())) {
801            add(space());
802         }
803      }
804   }
805
806   // f0 -> EqualityExpression()
807   // f1 -> ( "&" EqualityExpression() )*
808   public void visit(AndExpression n) {
809      n.f0.accept(this);
810      if ( n.f1.present() ) {
811         for(Enumeration e = n.f1.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space())) {
812            add(space());
813         }
814      }
815   }
816
817   // f0 -> InstanceOfExpression()
818   // f1 -> ( ( "==" | "!=" ) InstanceOfExpression() )*
819   public void visit(EqualityExpression n) {
820      n.f0.accept(this);
821      if ( n.f1.present() ) {
822         for(Enumeration e = n.f1.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space())) {
823            add(space());
824         }
825      }
826   }
827
828   // f0 -> RelationalExpression()
829   // f1 -> [ "instanceof" Type() ]
830   public void visit(InstanceOfExpression n) {
831      n.f0.accept(this);
832      if ( n.f1.present() ) {
833         add(space());
834         processList((NodeSequence)n.f1.node, space());
835      }
836   }
837
838   // f0 -> ShiftExpression()
839   // f1 -> ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*
840   public void visit(RelationalExpression n) {
841      n.f0.accept(this);
842      if ( n.f1.present() ) {
843         for(Enumeration e = n.f1.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space())) {
844            add(space());
845         }
846      }
847   }
848
849   // f0 -> AdditiveExpression()
850   // f1 -> ( ( "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() ) AdditiveExpression() )*
851   public void visit(ShiftExpression n) {
852      n.f0.accept(this);
853      if ( n.f1.present() ) {
854         for(Enumeration e = n.f1.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space())) {
855            add(space());
856         }
857      }
858   }
859
860   // f0 -> MultiplicativeExpression()
861   // f1 -> ( ( "+" | "-" ) MultiplicativeExpression() )*
862   public void visit(AdditiveExpression n) {
863      n.f0.accept(this);
864      if ( n.f1.present() ) {
865         for(Enumeration e = n.f1.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space())) {
866            add(space());
867         }
868      }
869   }
870
871   // f0 -> UnaryExpression()
872   // f1 -> ( ( "*" | "/" | "%" ) UnaryExpression() )*
873   public void visit(MultiplicativeExpression n) {
874      n.f0.accept(this);
875      if ( n.f1.present() ) {
876         for(Enumeration e = n.f1.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space())) {
877            add(space());
878         }
879      }
880   }
881
882   // f0 -> ( "+" | "-" ) UnaryExpression()
883   //       | PreIncrementExpression()
884   //       | PreDecrementExpression()
885   //       | UnaryExpressionNotPlusMinus()
886   public void visit(UnaryExpression n) {
887      if(n.f0.which == 0)
888         processList((NodeSequence)n.f0.choice, space());
889      else
890         n.f0.accept(this);
891   }
892
893   // f0 -> "++"
894   // f1 -> PrimaryExpression()
895   public void visit(PreIncrementExpression n) {
896      n.f0.accept(this);
897      n.f1.accept(this);
898   }
899
900   // f0 -> "--"
901   // f1 -> PrimaryExpression()
902   public void visit(PreDecrementExpression n) {
903      n.f0.accept(this);
904      n.f1.accept(this);
905   }
906
907   // f0 -> ( "~" | "!" ) UnaryExpression()
908   //       | CastExpression()
909   //       | PostfixExpression()
910   public void visit(UnaryExpressionNotPlusMinus n) {
911      n.f0.accept(this);
912   }
913
914   // f0 -> "(" PrimitiveType()
915   //       | "(" Type() "[" "]"
916   //       | "(" Type() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal() )
917   public void visit(CastLookahead n) {
918      n.f0.accept(this);
919   }
920
921   // f0 -> PrimaryExpression()
922   // f1 -> [ "++" | "--" ]
923   public void visit(PostfixExpression n) {
924      n.f0.accept(this);
925      if ( n.f1.present() ) {
926         n.f1.accept(this);
927      }
928   }
929
930   // f0 -> "(" Type() ")" UnaryExpression()
931   //       | "(" Type() ")" UnaryExpressionNotPlusMinus()
932   public void visit(CastExpression n) {
933      n.f0.accept(this);
934   }
935
936   // f0 -> PrimaryPrefix()
937   // f1 -> ( PrimarySuffix() )*
938   public void visit(PrimaryExpression n) {
939      n.f0.accept(this);
940      if ( n.f1.present() ) {
941         processList(n.f1);
942      }
943   }
944
945   // f0 -> "."
946   // f1 -> TypeArguments()
947   // f2 -> <IDENTIFIER>
948   public void visit(MemberSelector n) {
949      n.f0.accept(this);
950      n.f1.accept(this);
951      n.f2.accept(this);
952   }
953
954   // f0 -> Literal()
955   //       | ( <IDENTIFIER> "." )* "this"
956   //       | "super" "." <IDENTIFIER>
957   //       | ClassOrInterfaceType() "." "super" "." <IDENTIFIER>
958   //       | "(" Expression() ")"
959   //       | AllocationExpression()
960   //       | ResultType() "." "class"
961   //       | Name()
962   public void visit(PrimaryPrefix n) {
963      n.f0.accept(this);
964   }
965
966   // f0 -> "." "super"
967   //       | "." "this"
968   //       | "." AllocationExpression()
969   //       | MemberSelector()
970   //       | "[" Expression() "]"
971   //       | "." <IDENTIFIER>
972   //       | Arguments()
973   public void visit(PrimarySuffix n) {
974      n.f0.accept(this);
975   }
976
977   // f0 -> <INTEGER_LITERAL>
978   //       | <FLOATING_POINT_LITERAL>
979   //       | <CHARACTER_LITERAL>
980   //       | <STRING_LITERAL>
981   //       | BooleanLiteral()
982   //       | NullLiteral()
983   public void visit(Literal n) {
984      n.f0.accept(this);
985   }
986
987   // f0 -> "true"
988   //       | "false"
989   public void visit(BooleanLiteral n) {
990      n.f0.accept(this);
991   }
992
993   // f0 -> "null"
994   public void visit(NullLiteral n) {
995      n.f0.accept(this);
996   }
997
998   // f0 -> "("
999   // f1 -> [ ArgumentList() ]
1000   // f2 -> ")"
1001   public void visit(Arguments n) {
1002      n.f0.accept(this);
1003      if ( n.f1.present() ) {
1004         n.f1.accept(this);
1005      }
1006      n.f2.accept(this);
1007   }
1008
1009   // f0 -> Expression()
1010   // f1 -> ( "," Expression() )*
1011   public void visit(ArgumentList n) {
1012      n.f0.accept(this);
1013      if ( n.f1.present() ) {
1014         for(Enumeration e = n.f1.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space())) {
1015         }
1016      }
1017   }
1018
1019   // f0 -> "new" PrimitiveType() ArrayDimsAndInits()
1020   //       | "new" ClassOrInterfaceType() [ TypeArguments() ] ( ArrayDimsAndInits() | Arguments() [ ClassOrInterfaceBody(false) ] )
1021   public void visit(AllocationExpression n) {
1022      NodeSequence seq = (NodeSequence)n.f0.choice;
1023      if(n.f0.which == 0) {
1024         seq.elementAt(0).accept(this);
1025         add(space());
1026         seq.elementAt(1).accept(this);
1027         seq.elementAt(2).accept(this);
1028      } else {
1029         seq.elementAt(0).accept(this);
1030         add(space());
1031         for(int i = 1; i < seq.size(); i++) {
1032            seq.elementAt(i).accept(this);
1033         }
1034      }
1035   }
1036
1037   // f0 -> ( "[" Expression() "]" )+ ( "[" "]" )*
1038   //       | ( "[" "]" )+ ArrayInitializer()
1039   public void visit(ArrayDimsAndInits n) {
1040      if(n.f0.which == 0)
1041         n.f0.accept(this);
1042      else
1043         processList((NodeSequence)n.f0.choice, space());
1044   }
1045
1046   // f0 -> LabeledStatement()
1047   //       | AssertStatement()
1048   //       | Block()
1049   //       | EmptyStatement()
1050   //       | StatementExpression() ";"
1051   //       | SwitchStatement()
1052   //       | IfStatement()
1053   //       | WhileStatement()
1054   //       | DoStatement()
1055   //       | ForStatement()
1056   //       | BreakStatement()
1057   //       | ContinueStatement()
1058   //       | ReturnStatement()
1059   //       | ThrowStatement()
1060   //       | SynchronizedStatement()
1061   //       | TryStatement()
1062   public void visit(Statement n) {
1063      n.f0.accept(this);
1064   }
1065
1066   // f0 -> "assert"
1067   // f1 -> Expression()
1068   // f2 -> [ ":" Expression() ]
1069   // f3 -> ";"
1070   public void visit(AssertStatement n) {
1071      n.f0.accept(this);
1072      add(space());
1073      n.f1.accept(this);
1074      add(space());
1075      if(n.f2.present()) {
1076         processList((NodeSequence)n.f2.node, space());
1077      }
1078      n.f3.accept(this);
1079   }
1080
1081   // f0 -> <IDENTIFIER>
1082   // f1 -> ":"
1083   // f2 -> Statement()
1084   public void visit(LabeledStatement n) {
1085      n.f0.accept(this);
1086      add(space());
1087      n.f1.accept(this);
1088      add(space());
1089      n.f2.accept(this);
1090   }
1091
1092   // f0 -> "{"
1093   // f1 -> ( BlockStatement() )*
1094   // f2 -> "}"
1095   public void visit(Block n) {
1096      n.f0.accept(this);
1097      add(indent());
1098      if(n.f1.present()) {
1099         add(force());
1100         processList(n.f1, force());
1101      }
1102      add(outdent());
1103      add(force());
1104      n.f2.accept(this);
1105   }
1106
1107   // f0 -> LocalVariableDeclaration() ";"
1108   //       | Statement()
1109   //       | ClassOrInterfaceDeclaration(0)
1110   public void visit(BlockStatement n) {
1111      n.f0.accept(this);
1112   }
1113
1114   // f0 -> Modifiers()
1115   // f1 -> Type()
1116   // f2 -> VariableDeclarator()
1117   // f3 -> ( "," VariableDeclarator() )*
1118   public void visit(LocalVariableDeclaration n) {
1119      n.f0.accept(this);
1120      n.f1.accept(this);
1121      add(space());
1122      n.f2.accept(this);
1123      if ( n.f3.present() ) {
1124            for(Enumeration e = n.f3.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space())); {
1125         }
1126      }
1127   }
1128
1129   // f0 -> ";"
1130   public void visit(EmptyStatement n) {
1131      n.f0.accept(this);
1132   }
1133
1134   // f0 -> PreIncrementExpression()
1135   //       | PreDecrementExpression()
1136   //       | PrimaryExpression() [ "++" | "--" | AssignmentOperator() Expression() ]
1137   public void visit(StatementExpression n) {
1138      if(n.f0.which == 0 || n.f0.which == 1) {
1139          n.f0.accept(this);
1140      } else {
1141         NodeSequence seq = (NodeSequence)n.f0.choice;
1142         NodeOptional opt = (NodeOptional)seq.elementAt(1);
1143         seq.elementAt(0).accept(this);
1144         if(opt.present()) {
1145            NodeChoice choice = (NodeChoice)opt.node;
1146            if(choice.which == 0 || choice.which == 1) {
1147               choice.accept(this);
1148            } else {
1149               add(space());
1150               processList((NodeSequence)choice.choice, space());
1151            }
1152         }
1153      }
1154   }
1155
1156   // f0 -> "switch"
1157   // f1 -> "("
1158   // f2 -> Expression()
1159   // f3 -> ")"
1160   // f4 -> "{"
1161   // f5 -> ( SwitchLabel() ( BlockStatement() )* )*
1162   // f6 -> "}"
1163   public void visit(SwitchStatement n) {
1164      n.f0.accept(this);
1165      add(space());
1166      n.f1.accept(this);
1167      add(space());
1168      n.f2.accept(this);
1169      add(space());
1170      n.f3.accept(this);
1171      add(force());
1172      n.f4.accept(this);
1173      add(indent());
1174      if (n.f5.present()) {
1175         for (Enumeration e = n.f5.elements(); e.hasMoreElements(); add(outdent())) {
1176            NodeSequence seq = (NodeSequence)e.nextElement();
1177            NodeListOptional nlo = (NodeListOptional)seq.elementAt(1);
1178            add(force());
1179            seq.elementAt(0).accept(this);
1180            add(indent());
1181            if (nlo.present()) {
1182               add(force());
1183               processList((NodeListOptional)seq.elementAt(1), force());
1184            }
1185         }
1186      }
1187      add(outdent());
1188      add(force());
1189      n.f6.accept(this);
1190   }
1191
1192   // f0 -> "case" Expression() ":"
1193   //       | "default" ":"
1194   public void visit(SwitchLabel n) {
1195      processList((NodeSequence)n.f0.choice, space());
1196   }
1197
1198   // f0 -> "if"
1199   // f1 -> "("
1200   // f2 -> Expression()
1201   // f3 -> ")"
1202   // f4 -> Statement()
1203   // f5 -> [ "else" Statement() ]
1204   public void visit(IfStatement n) {
1205      boolean isBlock = n.f4.f0.which == 2;
1206      n.f0.accept(this);
1207      add(space());
1208      n.f1.accept(this);
1209      add(space());
1210      n.f2.accept(this);
1211      add(space());
1212      n.f3.accept(this);
1213      if(!isBlock)
1214          add(indent());
1215      add(force());
1216      n.f4.accept(this);
1217      if(!isBlock)
1218          add(outdent());
1219      if(n.f5.present()) {
1220          NodeSequence seq = (NodeSequence)n.f5.node;
1221          isBlock = ((Statement)seq.elementAt(1)).f0.which == 2;
1222          add(force());
1223          seq.elementAt(0).accept(this);
1224          if(!isBlock)
1225              add(indent());
1226          add(force());
1227          seq.elementAt(1).accept(this);
1228          if(!isBlock)
1229              add(outdent());
1230      }
1231   }
1232
1233   // f0 -> "while"
1234   // f1 -> "("
1235   // f2 -> Expression()
1236   // f3 -> ")"
1237   // f4 -> Statement()
1238   public void visit(WhileStatement n) {
1239      boolean isBlock = n.f4.f0.which == 2;
1240      n.f0.accept(this);
1241      add(space());
1242      n.f1.accept(this);
1243      add(space());
1244      n.f2.accept(this);
1245      add(space());
1246      n.f3.accept(this);
1247      if(!isBlock)
1248         add(indent());
1249      add(force());
1250      n.f4.accept(this);
1251      if(!isBlock)
1252         add(outdent());
1253   }
1254
1255   // f0 -> "do"
1256   // f1 -> Statement()
1257   // f2 -> "while"
1258   // f3 -> "("
1259   // f4 -> Expression()
1260   // f5 -> ")"
1261   // f6 -> ";"
1262   public void visit(DoStatement n) {
1263      boolean isBlock = n.f1.f0.which == 2;
1264      n.f0.accept(this);
1265      if(!isBlock)
1266         add(indent());
1267      add(force());
1268      n.f1.accept(this);
1269      if(!isBlock)
1270         add(outdent());
1271      add(force());
1272      n.f2.accept(this);
1273      add(space());
1274      n.f3.accept(this);
1275      add(space());
1276      n.f4.accept(this);
1277      add(space());
1278      n.f5.accept(this);
1279      n.f6.accept(this);
1280   }
1281
1282   // f0 -> "for"
1283   // f1 -> "("
1284   // f2 -> ( Modifiers() Type() <IDENTIFIER> ":" Expression() | [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] )
1285   // f3 -> ")"
1286   // f4 -> Statement()
1287   public void visit(ForStatement n) {
1288      boolean isBlock = n.f4.f0.which == 2;
1289      n.f0.accept(this);
1290      add(space());
1291      n.f1.accept(this);
1292      add(space());
1293      processList((NodeSequence)n.f2.choice, space());
1294      n.f3.accept(this);
1295      if(!isBlock)
1296         add(indent());
1297      add(force());
1298      n.f4.accept(this);
1299      if(!isBlock)
1300         add(outdent());
1301   }
1302
1303   // f0 -> LocalVariableDeclaration()
1304   //       | StatementExpressionList()
1305   public void visit(ForInit n) {
1306      n.f0.accept(this);
1307   }
1308
1309   // f0 -> StatementExpression()
1310   // f1 -> ( "," StatementExpression() )*
1311   public void visit(StatementExpressionList n) {
1312      n.f0.accept(this);
1313      if ( n.f1.present() ) {
1314         for(Enumeration e = n.f1.elements(); e.hasMoreElements(); processList((NodeSequence)e.nextElement(), space())); {
1315         }
1316      }
1317   }
1318
1319   // f0 -> StatementExpressionList()
1320   public void visit(ForUpdate n) {
1321      n.f0.accept(this);
1322   }
1323
1324   // f0 -> "break"
1325   // f1 -> [ <IDENTIFIER> ]
1326   // f2 -> ";"
1327   public void visit(BreakStatement n) {
1328      n.f0.accept(this);
1329      if ( n.f1.present() ) {
1330         add(space());
1331         n.f1.accept(this);
1332      }
1333      n.f2.accept(this);
1334   }
1335
1336   // f0 -> "continue"
1337   // f1 -> [ <IDENTIFIER> ]
1338   // f2 -> ";"
1339   public void visit(ContinueStatement n) {
1340      n.f0.accept(this);
1341      if ( n.f1.present() ) {
1342         add(space());
1343         n.f1.accept(this);
1344      }
1345      n.f2.accept(this);
1346   }
1347
1348   // f0 -> "return"
1349   // f1 -> [ Expression() ]
1350   // f2 -> ";"
1351   public void visit(ReturnStatement n) {
1352      n.f0.accept(this);
1353      if ( n.f1.present() ) {
1354         add(space());
1355         n.f1.accept(this);
1356      }
1357      n.f2.accept(this);
1358   }
1359
1360   // f0 -> "throw"
1361   // f1 -> Expression()
1362   // f2 -> ";"
1363   public void visit(ThrowStatement n) {
1364      n.f0.accept(this);
1365      add(space());
1366      n.f1.accept(this);
1367      n.f2.accept(this);
1368   }
1369
1370   // f0 -> "synchronized"
1371   // f1 -> "("
1372   // f2 -> Expression()
1373   // f3 -> ")"
1374   // f4 -> Block()
1375   public void visit(SynchronizedStatement n) {
1376      n.f0.accept(this);
1377      add(space());
1378      n.f1.accept(this);
1379      add(space());
1380      n.f2.accept(this);
1381      add(space());
1382      n.f3.accept(this);
1383      add(force());
1384      n.f4.accept(this);
1385   }
1386
1387   // f0 -> "try"
1388   // f1 -> Block()
1389   // f2 -> ( "catch" "(" FormalParameter() ")" Block() )*
1390   // f3 -> [ "finally" Block() ]
1391   public void visit(TryStatement n) {
1392      n.f0.accept(this);
1393      add(force());
1394      n.f1.accept(this);
1395      if(n.f2.present()) {
1396         NodeSequence seq;
1397         for(Enumeration e = n.f2.elements(); e.hasMoreElements(); seq.elementAt(4).accept(this)) {
1398            seq = (NodeSequence)e.nextElement();
1399            add(force());
1400            seq.elementAt(0).accept(this);
1401            add(space());
1402            seq.elementAt(1).accept(this);
1403            seq.elementAt(2).accept(this);
1404            seq.elementAt(3).accept(this);
1405            add(force());
1406         }
1407      }
1408      if(n.f3.present()) {
1409          add(force());
1410          processList((NodeSequence)n.f3.node, force());
1411      }
1412   }
1413
1414   // f0 -> ( ">" ">" ">" )
1415   public void visit(RUNSIGNEDSHIFT n) {
1416      n.f0.accept(this);
1417   }
1418
1419   // f0 -> ( ">" ">" )
1420   public void visit(RSIGNEDSHIFT n) {
1421      n.f0.accept(this);
1422   }
1423
1424   // f0 -> NormalAnnotation()
1425   //       | SingleMemberAnnotation()
1426   //       | MarkerAnnotation()
1427   public void visit(Annotation n) {
1428      n.f0.accept(this);
1429   }
1430
1431   // f0 -> "@"
1432   // f1 -> Name()
1433   // f2 -> "("
1434   // f3 -> [ MemberValuePairs() ]
1435   // f4 -> ")"
1436   public void visit(NormalAnnotation n) {
1437      n.f0.accept(this);
1438      n.f1.accept(this);
1439      n.f2.accept(this);
1440      add(space());
1441      if ( n.f3.present() ) {
1442         n.f3.accept(this);
1443      }
1444      n.f4.accept(this);
1445   }
1446
1447   // f0 -> "@"
1448   // f1 -> Name()
1449   public void visit(MarkerAnnotation n) {
1450      n.f0.accept(this);
1451      n.f1.accept(this);
1452   }
1453
1454   // f0 -> "@"
1455   // f1 -> Name()
1456   // f2 -> "("
1457   // f3 -> MemberValue()
1458   // f4 -> ")"
1459   public void visit(SingleMemberAnnotation n) {
1460      n.f0.accept(this);
1461      n.f1.accept(this);
1462      n.f2.accept(this);
1463      n.f3.accept(this);
1464      n.f4.accept(this);
1465   }
1466
1467   // f0 -> MemberValuePair()
1468   // f1 -> ( "," MemberValuePair() )*
1469   public void visit(MemberValuePairs n) {
1470      n.f0.accept(this);
1471      if ( n.f1.present() ) {
1472         processList(n.f1, space());
1473      }
1474   }
1475
1476   // f0 -> <IDENTIFIER>
1477   // f1 -> "="
1478   // f2 -> MemberValue()
1479   public void visit(MemberValuePair n) {
1480      n.f0.accept(this);
1481      n.f1.accept(this);
1482      n.f2.accept(this);
1483   }
1484
1485   // f0 -> Annotation()
1486   //       | MemberValueArrayInitializer()
1487   //       | ConditionalExpression()
1488   public void visit(MemberValue n) {
1489      n.f0.accept(this);
1490   }
1491
1492   // f0 -> "{"
1493   // f1 -> ( MemberValue() ( "," MemberValue() )* [ "," ] )?
1494   // f2 -> "}"
1495   public void visit(MemberValueArrayInitializer n) {
1496      n.f0.accept(this);
1497      add(space());
1498      if(n.f1.present()) {
1499         n.f1.accept(this);
1500         add(space());
1501      }
1502      n.f2.accept(this);
1503   }
1504
1505   // f0 -> "@"
1506   // f1 -> "interface"
1507   // f2 -> <IDENTIFIER>
1508   // f3 -> AnnotationTypeBody()
1509   public void visit(AnnotationTypeDeclaration n) {
1510      n.f0.accept(this);
1511      n.f1.accept(this);
1512      add(space());
1513      n.f2.accept(this);
1514      add(space());
1515      n.f3.accept(this);
1516   }
1517
1518   // f0 -> "{"
1519   // f1 -> ( AnnotationTypeMemberDeclaration() )*
1520   // f2 -> "}"
1521   public void visit(AnnotationTypeBody n) {
1522      n.f0.accept(this);
1523      add(space());
1524      if ( n.f1.present() ) {
1525         processList(n.f1, space());
1526      }
1527      n.f2.accept(this);
1528   }
1529
1530   // f0 -> Modifiers() ( Type() <IDENTIFIER> "(" ")" [ DefaultValue() ] ";" | ClassOrInterfaceDeclaration(modifiers) | EnumDeclaration(modifiers) | AnnotationTypeDeclaration(modifiers) | FieldDeclaration(modifiers) )
1531   //       | ( ";" )
1532   public void visit(AnnotationTypeMemberDeclaration n) {
1533      n.f0.accept(this);
1534   }
1535
1536   // f0 -> "default"
1537   // f1 -> MemberValue()
1538   public void visit(DefaultValue n) {
1539      n.f0.accept(this);
1540      add(space());
1541      n.f1.accept(this);
1542   }
1543
1544}
1545
1546class FormatCommand {
1547   public static final int FORCE = 0;
1548   public static final int INDENT = 1;
1549   public static final int OUTDENT = 2;
1550   public static final int SPACE = 3;
1551
1552   private int command;
1553   private int numCommands;
1554
1555   FormatCommand(int command, int numCommands) {
1556      this.command = command;
1557      this.numCommands = numCommands;
1558   }
1559
1560   public int getCommand()             { return command; }
1561   public int getNumCommands()         { return numCommands; }
1562   public void setCommand(int i)       { command = i; }
1563   public void setNumCommands(int i)   { numCommands = i; }
1564}
1565
1566class TreeFormatterException extends RuntimeException {
1567   // Added by hand to remove serialize warning.  (markro)
1568   static final long serialVersionUID = 20150406L;
1569
1570   TreeFormatterException()         { super(); }
1571   TreeFormatterException(String s) { super(s); }
1572}