Example #1
0
  /*
   * (non-Javadoc)
   * @see eu.hydrologis.jgrass.console.core.internal.compiler.AbstractPreprocessor#translate()
   */
  @SuppressWarnings("unchecked")
  protected void translate(Symtable<SYMs> symtable, APT<APTs> parseTree, AST<ASTs> syntaxTree) {

    try {

      AST_root __astroot = (AST_root) syntaxTree;
      switch (parseTree.identifier()) {
        case APT_NATIVE_MODEL:
          __native_model(symtable, __astroot, (APT_native_model) parseTree);
          break;

        case APT_STATEMENT:
          final APT_statement __model_def;
          __model_def = (APT_statement) parseTree;
          for (int i = 0; i < __model_def.size(); ++i)
            translate(symtable, __model_def.getChild(i), __astroot);
          break;

        case APT_ROOT:
          final APT_root __aptroot = (APT_root) parseTree;
          for (int i = 0; i < __aptroot.size(); ++i)
            translate(symtable, __aptroot.getChild(i), __astroot);
          break;
      }
    } catch (Exception e) {

      if (true == Projectspace.isErrorEnabled()) projectSpace().err.println(e);

      e.printStackTrace();
    }
  } // translate
Example #2
0
  /**
   * Creates as output the tree-like intermediate representation of the target code for the command
   * line arguments.
   *
   * @param operator - a "parameter definition" operator.
   * @return Returns the produced tree-like intermediate representation of the target code.
   */
  @SuppressWarnings("unchecked")
  private AST<ASTs> __parameter_definition(Symtable<SYMs> symtable, APT_native_model operator) {

    final AST<ASTs> retval = new AST_comma();
    try {

      APT_parameter_definition definition = operator.parameter_defs();
      if (null != definition) {

        for (int i = 0; i < definition.size(); ++i) {

          APT_parameter parameter;
          AST<ASTs> tree;
          parameter = (APT_parameter) definition.getChild(i);
          tree = (1 >= parameter.size()) ? retval : retval.addChild(new AST_plus());
          for (int n = 0; n < parameter.size(); ++n) {

            APT<APTs> operand = parameter.getChild(n);
            switch (operand.identifier()) {
              case APT_VARIABLE:
                APT_variable __variable = (APT_variable) operand;
                tree.addChild(new AST_identifier(__variable.variable_name()));
                break;

              case APT_LITERAL:
              default:
                tree.addChild(new AST_literal(operand.expression()));
            }
          }
        }
      }

      retval.addChild(
          0,
          new AST_plus(
              new AST_literal(
                  projectSpace().getArgVerbValue(Projectspace.ARG_VERB_BINARY_PATH)
                      + File.separator),
              new AST_literal(operator.token().expression())));
    } catch (Exception e) {

      if (true == Projectspace.isErrorEnabled()) projectSpace().err.println(e);

      e.printStackTrace();
    }

    return retval;
  } // __parameter_definition