com.ph.pr.parser.vbs2java
Class VBSVisitor

java.lang.Object
  extended by com.ph.pr.parser.ReflectiveVisitor
      extended by com.ph.pr.parser.vbs2java.VBSVisitor
All Implemented Interfaces:
Visitor

public class VBSVisitor
extends ReflectiveVisitor

Translates a VBScript script into a Java class.

Notice that this was generated with the first draft of ASTBuilder, which had a little issue due to the silliness of the author. As a result, getters and setters for non-terminals in each implementation of ASTNodeare still used (whereas the fix is to use ASTNode.getNodes()). The ambiguous cases here have been fixed manually (such as visit(expr_7_AST)and similar ones).

A given VBScript script is translated into a Java class. Sample usage is: ASTNode start = ASTBuilder.singleton().parse(null, "com.sun.foo", "XXX.vbs");
VBSVisitor visitor = new VBSVisitor();
start.accept(visitor);
String code = visitor.getCode();

After which the code variable will contain the body of the class, without the class signature, package statements or imports. It currently the job of the caller (in our case, com.ph.pr.parser.vb2java.achapps.VBS2Java) to fill that out. However, the resulting class must import everything in this package, and extend com.ph.pr.parser.vb2java.VBS2JavaBase(or a subclass thereof).

Also, since we're only concerned with cases that appear in our VBScript files, some functionality of VBScript is not handled; the corresponding branches of its visit() methods throw UnsupportedOperationException.

Author:
ASTBuilder-- auto-generation, Greg Golberg -- post-processing
See Also:
ASTBuilder, ASTNode

Field Summary
private  java.util.Map ast2Comments
           
private  boolean caseFirst
           
private  java.lang.String code
           
private  java.util.Stack downUse
           
private static java.lang.String EOL
           
private  java.lang.String funcName
           
static java.lang.String INDENT
           
private  int indentLevel
          Current indent level.
private  java.util.Map methods
           
private  int pass
           
 
Fields inherited from class com.ph.pr.parser.ReflectiveVisitor
VISIT_METHOD_NAME, VISIT_METHOD_NAME_BRITISH
 
Constructor Summary
VBSVisitor(java.util.Map ast2Comments, java.util.Collection allAsts)
           
 
Method Summary
 void defaultVisit(java.lang.Object o)
          If all else fails...
private  java.lang.String endStatement()
          Ends a statement.
private  void finishBlock()
          Calls undoNewline(), and then appends a EOL, a result of indent(), a }, another two EOLs, and another result of indent()to code
 java.lang.String getCode()
           
private  java.lang.String indent()
          Indent.
private  java.lang.String openBrace()
          Opens a brace (such as one after an if, etc.).
private  void undoNewline()
          Modifies codeby truncating everything after the last EOL.
 void visit(as_opt_AST node)
           
 void visit(as_type_AST node)
           
 void visit(assign_opt_AST node)
           
 void visit(assignment_AST node)
           
 void visit(ASTNode node)
           
 void visit(by_opt_AST node)
           
 void visit(case_item_AST node)
           
 void visit(case_list_AST node)
           
 void visit(caseelse_opt_AST node)
           
 void visit(comment_list_AST node)
           
 void visit(condition_opt_AST node)
           
 void visit(const_AST node)
           
 void visit(const_decl_AST node)
           
 void visit(const_decl_list_2_AST node)
           
 void visit(const_decl_list_AST node)
           
 void visit(dim_AST node)
           
 void visit(dim_decl_AST node)
           
 void visit(dim_decl_list_2_AST node)
           
 void visit(dim_decl_list_AST node)
           
 void visit(else_opt_AST node)
           
 void visit(elseif_item_AST node)
           
 void visit(elseif_list_AST node)
           
 void visit(exit_kind_AST node)
           
 void visit(expr_10_AST node)
           
 void visit(expr_11_AST node)
           
 void visit(expr_12_AST node)
           
 void visit(expr_13_AST node)
           
 void visit(expr_14_AST node)
           
 void visit(expr_15_AST node)
           
 void visit(expr_16_AST node)
           
 void visit(expr_17_AST node)
           
 void visit(expr_2_AST node)
           
 void visit(expr_3_AST node)
           
 void visit(expr_4_AST node)
           
 void visit(expr_5_AST node)
           
 void visit(expr_6_AST node)
           
 void visit(expr_7_AST node)
           
 void visit(expr_8_AST node)
           
 void visit(expr_9_AST node)
           
 void visit(expr_AST node)
           
 void visit(expr_list_2_AST node)
           
 void visit(expr_list_AST node)
           
 void visit(expr_opt_AST node)
           
 void visit(ext_statement_AST node)
           
 void visit(ext_statement_list_AST node)
           
 void visit(for_AST node)
           
 void visit(formal_declarator_AST node)
           
 void visit(formal_list_2_AST node)
           
 void visit(formal_list_AST node)
           
 void visit(formal_list_opt_AST node)
           
 void visit(formal_list_opt2_AST node)
           
 void visit(func_AST node)
           
 void visit(func_call_AST node)
           
 void visit(if_then_AST node)
           
 void visit(if_then_else_AST node)
           
 void visit(name_opt_AST node)
           
 void visit(no_paren_call_AST node)
           
 void visit(on_error_AST node)
           
 void visit(on_target_AST node)
           
 void visit(option_explicit_AST node)
           
 void visit(parens_opt_AST node)
           
 void visit(postfix_expr_AST node)
           
 void visit(preserve_opt_AST node)
           
 void visit(primary_expr_AST node)
           
 void visit(redim_AST node)
           
 void visit(redim_decl_AST node)
           
 void visit(redim_decl_list_2_AST node)
           
 void visit(redim_decl_list_AST node)
           
 void visit(select_AST node)
           
 void visit(set_AST node)
           
 void visit(set_expr_AST node)
           
 void visit(simple_statement_AST node)
           
 void visit(simple_statement_list_AST node)
           
 void visit(start_AST node)
           
 void visit(statement_AST node)
           
 void visit(statement_list_AST node)
           
 void visit(step_opt_AST node)
           
 void visit(sub_AST node)
           
 void visit(sub_list2_2_AST node)
           
 void visit(sub_list2_AST node)
           
 void visit(tkNameList_AST node)
           
 void visit(type_decl_list_AST node)
           
 void visit(while_AST node)
           
 
Methods inherited from class com.ph.pr.parser.ReflectiveVisitor
visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

methods

private java.util.Map methods

pass

private int pass

INDENT

public static final java.lang.String INDENT
See Also:
Constant Field Values

ast2Comments

private java.util.Map ast2Comments

indentLevel

private int indentLevel
Current indent level.


code

private java.lang.String code

caseFirst

private boolean caseFirst

downUse

private java.util.Stack downUse

funcName

private java.lang.String funcName

EOL

private static final java.lang.String EOL
See Also:
Constant Field Values
Constructor Detail

VBSVisitor

public VBSVisitor(java.util.Map ast2Comments,
                  java.util.Collection allAsts)
Method Detail

endStatement

private java.lang.String endStatement()
Ends a statement.

Returns:
effectively, a ;, followed by EOL, followed by a result of indent().

openBrace

private java.lang.String openBrace()
Opens a brace (such as one after an if, etc.).

Returns:
effectively, increments indentLevel, and returns {, followed by EOL, followed by result of a call to indent(), then decrements indentLevel.

defaultVisit

public void defaultVisit(java.lang.Object o)
Description copied from class: ReflectiveVisitor
If all else fails...

Specified by:
defaultVisit in class ReflectiveVisitor
Parameters:
o - say, can you see?

indent

private final java.lang.String indent()
Indent.

Returns:
indentLevelnumber of INDENTs.

getCode

public java.lang.String getCode()

visit

public void visit(expr_16_AST node)

visit

public void visit(formal_list_opt2_AST node)

visit

public void visit(start_AST node)

visit

public void visit(dim_decl_list_AST node)

visit

public void visit(ext_statement_AST node)

visit

public void visit(expr_17_AST node)

visit

public void visit(sub_list2_AST node)

visit

public void visit(redim_decl_AST node)

visit

public void visit(const_decl_list_AST node)

visit

public void visit(statement_AST node)

visit

public void visit(formal_list_opt_AST node)

visit

public void visit(expr_9_AST node)

visit

public void visit(by_opt_AST node)

visit

public void visit(exit_kind_AST node)

visit

public void visit(on_error_AST node)

visit

public void visit(on_target_AST node)

visit

public void visit(case_list_AST node)

visit

public void visit(formal_declarator_AST node)

visit

public void visit(for_AST node)

visit

public void visit(as_type_AST node)

visit

public void visit(expr_list_2_AST node)

visit

public void visit(expr_opt_AST node)

visit

public void visit(expr_6_AST node)

visit

public void visit(formal_list_AST node)

visit

public void visit(case_item_AST node)

visit

public void visit(no_paren_call_AST node)

visit

public void visit(expr_5_AST node)

visit

public void visit(const_AST node)

visit

public void visit(postfix_expr_AST node)

visit

public void visit(select_AST node)

visit

public void visit(tkNameList_AST node)

visit

public void visit(expr_AST node)

visit

public void visit(ext_statement_list_AST node)

visit

public void visit(ASTNode node)

visit

public void visit(expr_14_AST node)

visit

public void visit(set_expr_AST node)

visit

public void visit(if_then_AST node)

visit

public void visit(simple_statement_list_AST node)

visit

public void visit(formal_list_2_AST node)

visit

public void visit(dim_decl_list_2_AST node)

visit

public void visit(dim_AST node)

visit

public void visit(sub_AST node)

visit

public void visit(dim_decl_AST node)

undoNewline

private void undoNewline()
Modifies codeby truncating everything after the last EOL.


finishBlock

private void finishBlock()
Calls undoNewline(), and then appends a EOL, a result of indent(), a }, another two EOLs, and another result of indent()to code


visit

public void visit(func_AST node)

visit

public void visit(expr_2_AST node)

visit

public void visit(redim_decl_list_2_AST node)

visit

public void visit(statement_list_AST node)

visit

public void visit(expr_10_AST node)

visit

public void visit(const_decl_AST node)

visit

public void visit(assign_opt_AST node)

visit

public void visit(option_explicit_AST node)

visit

public void visit(name_opt_AST node)

visit

public void visit(redim_AST node)

visit

public void visit(parens_opt_AST node)

visit

public void visit(redim_decl_list_AST node)

visit

public void visit(expr_15_AST node)

visit

public void visit(condition_opt_AST node)

visit

public void visit(comment_list_AST node)

visit

public void visit(expr_3_AST node)

visit

public void visit(if_then_else_AST node)

visit

public void visit(expr_list_AST node)

visit

public void visit(simple_statement_AST node)

visit

public void visit(elseif_list_AST node)

visit

public void visit(assignment_AST node)

visit

public void visit(expr_12_AST node)

visit

public void visit(while_AST node)

visit

public void visit(as_opt_AST node)

visit

public void visit(else_opt_AST node)

visit

public void visit(expr_8_AST node)

visit

public void visit(expr_13_AST node)

visit

public void visit(const_decl_list_2_AST node)

visit

public void visit(expr_7_AST node)

visit

public void visit(set_AST node)

visit

public void visit(expr_4_AST node)

visit

public void visit(sub_list2_2_AST node)

visit

public void visit(primary_expr_AST node)

visit

public void visit(caseelse_opt_AST node)

visit

public void visit(step_opt_AST node)

visit

public void visit(preserve_opt_AST node)

visit

public void visit(type_decl_list_AST node)

visit

public void visit(elseif_item_AST node)

visit

public void visit(func_call_AST node)

visit

public void visit(expr_11_AST node)