예제 #1
0
  public Object visit(SimpleNode node, Object data) {
    int id = node.getId();
    Object retVal = null;

    switch (id) {
      case JJTPROGRAM:
        handleProgram((ASTProgram) node);
        break;
      case JJTDECLARATIONLIST:
        handleDeclarationList((ASTDeclarationList) node);
        break;
      case JJTDECLARATION:
        retVal = handleDeclaration((ASTDeclaration) node);
        break;
      case JJTVARDECL:
        handleVarDecl((ASTVarDecl) node);
        break;
      case JJTARRAYDECLARATION:
        retVal = handleArrayDeclaration((ASTArrayDeclaration) node);
        break;
      case JJTSTATEMENTLIST:
        handleStatementList((ASTStatementList) node);
        break;
      case JJTSTATEMENT:
        handleStatement((ASTStatement) node);
        break;
      case JJTCALL:
        retVal = handleCall((ASTCall) node);
        break;
      case JJTVAR:
        retVal = handleVar((ASTVar) node);
        break;
      case JJTASSIGNMENT:
        handleAssignment((ASTAssignment) node);
        break;
      case JJTEXPRESSION:
        retVal = handleExpression((ASTExpression) node);
        break;
      case JJTARGS:
        retVal = handleArgs((ASTArgs) node);
        break;
      case JJTOP:
        retVal = handleOp((ASTOp) node);
        break;
      case JJTNUM:
        retVal = handleNum((ASTNum) node);
        break;
      case JJTFUNCTION:
        handleFunction((ASTFunction) node);
        break;
      default:
        if (XAALScripter.debug) {
          System.out.println("Unimplemented");
        }
    }
    return retVal;
  }
예제 #2
0
  // returning false means we're done executing now.
  public Boolean handleDeclaration(ASTDeclaration node) {

    // System.out.println("Visiting decl");
    SimpleNode child = (SimpleNode) node.jjtGetChild(0);
    if (child.getId() == JJTFUNCTION) {
      System.out.println("Found a function");

      startQuestion = questionFactory.getStartQuestion();
      connector.endPar(); // ENDPAR
      connector.endSnap();
      ASTFunction main = Global.getFunction("main");
      connector.addScope(main.getSymbolTable(), "main", "Global");

      main.jjtAccept(this, null);

      return false;
    } else {
      node.jjtGetChild(0).jjtAccept(this, null);
      // update();
      return true;
    }
  }