Esempio n. 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
Esempio n. 2
0
  /**
   * The constructor <code>E2001</code> constructs the message.
   *
   * @param projectSpace - the current project space.
   * @param token - the unexpected token.
   */
  public E1002(Projectspace projectSpace, Token<TOKs> token) {

    super(
        MessageFormat.format(
            "{0}({1}) : error {2}: unexpected ''{3}''.",
            new Object[] {
              projectSpace.projectCaption(),
              token.line(),
              E1002.class.getSimpleName(),
              token.expression()
            }));
  } // E1002
Esempio n. 3
0
  /**
   * The constructor <code>E2104</code> constructs the message.
   *
   * @param projectSpace - the current project space.
   * @param token - the identifier.
   */
  public E2104(Projectspace projectSpace, Token<TOKs> token) {

    super(
        MessageFormat.format(
            "{0}({1}) : error {2}: unknown java model identifier ''{3}''.",
            new Object[] {
              projectSpace.projectCaption(),
              token.line(),
              E2104.class.getSimpleName(),
              token.expression()
            }));
  } // E2104
Esempio n. 4
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
Esempio n. 5
0
  /*
   * (non-Javadoc)
   * @see eu.hydrologis.jgrass.console.core.internal.compiler.Preprocessor#intermediate()
   */
  public final APT<APTs> intermediate(Symtable<SYMs> symtable, Reader sourceCode, int line) {

    APT<APTs> retval = null;
    try {

      Lexer<TOKs> scanner = new NativeMLScanner(projectSpace(), sourceCode, line);
      Parser<APTs, TOKs, SYMs> parser = new NativeMLParser(projectSpace(), scanner);
      retval = parser.parse(symtable, new APT_root());
    } catch (Exception e) {

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

      e.printStackTrace();
    }

    return retval;
  } // intermediate