~ubuntu-branches/ubuntu/raring/babel/raring-proposed

« back to all changes in this revision

Viewing changes to compiler/gov/llnl/babel/parsers/sidl2/SIDLDumpVisitor.java

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV
  • Date: 2008-08-01 07:56:58 UTC
  • mfrom: (3.1.2 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080801075658-9ezcrbh8dcs8lg70
Tags: 1.2.0.dfsg-6
Added libparsifal-dev as dependency to libsidl-dev (closes: #483324).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
  //
 
2
  // File:        SIDLDumpVisitor.java
 
3
  // Package:     
 
4
  // Copyright:   (c) 2005 The Lawrence Livermore National Security, LLC
 
5
  // Release:     $Name$
 
6
  // Revision:     @(#) $Id: SIDLDumpVisitor.java 6171 2007-10-08 23:39:28Z epperly $
 
7
  // Description: 
 
8
 
 
9
package gov.llnl.babel.parsers.sidl2;
 
10
 
 
11
import java.io.PrintStream;
 
12
 
 
13
public class SIDLDumpVisitor implements SIDLParserVisitor { 
 
14
  
 
15
    protected PrintStream out;
 
16
 
 
17
    private int indent = 0;
 
18
    
 
19
    public SIDLDumpVisitor ( PrintStream o ) { 
 
20
        out = o;
 
21
    }
 
22
 
 
23
    private String indentString() {
 
24
        StringBuffer sb = new StringBuffer();
 
25
        for (int i = 0; i < indent; ++i) {
 
26
            sb.append(" ");
 
27
        }
 
28
        return sb.toString();
 
29
    }
 
30
 
 
31
    public Object visit( ParseTreeNode node, Object data) { 
 
32
      String doc_com = "";
 
33
      if(node.doc == null) {
 
34
        doc_com = "";
 
35
      } else if(node.doc != null && node.doc.length() != 0) {
 
36
        doc_com = " /**" + node.doc + "*/";
 
37
      } 
 
38
      if ( node.name.equals("") ) { 
 
39
        out.println(indentString() + node + doc_com );
 
40
      } else { 
 
41
        out.println(indentString() + node + "  (" + node.name + ")" + doc_com);
 
42
      }
 
43
      ++indent;
 
44
      data = node.childrenAccept(this, data);
 
45
      --indent;
 
46
      return data;
 
47
    }
 
48
}