Example #1
0
  /** @see org.mulgara.store.tuples.AbstractTuples#next() */
  @Override
  public boolean next() throws TuplesException {
    try {
      currentRow = source.getTriple();
    } catch (TuplesException ex) {
      source.terminate();
      throw ex;
    }
    assert currentRow != null;

    if (currentRow == StatementParser.TERMINATOR) rowCount = source.getStatementCount();
    return currentRow != StatementParser.TERMINATOR;
  }
Example #2
0
  protected String parseStatement(InputReader reader)
      throws InvalidSyntaxException, EnvironmentException, ParserException {
    if (!reader.hasNextWord()) {
      return reader.getCurrentStatement();
    }

    Word word = reader.nextWord();
    String keyword = word.asName();
    WordTail tail = reader.getWordTail();

    if (tail.isCompilerCommand()) {
      String command = reader.nextWord().asName();
      if (command.equals("include")) {
        return parseInclude(reader);
      } else if (command.equals("macro")) {
        insideMacro = true;
        return reader.getCurrentStatement();
      } else if (command.equals("macroend")) {
        insideMacro = false;
        return reader.getCurrentStatement();
      }
    }

    if (insideMacro) {
      return reader.getCurrentStatement();
    } else if (tail.isAssignment()) {
      return statementParser.parseVarAssign(word, reader);
    } else if (tail.isFunctionArgsOpen()) {
      return statementParser.parseCall(word, null, reader);
    } else if (keyword.equals("var")) {
      return statementParser.parseVarDeclare(reader);
    } else if (keyword.equals("function")) {
      return statementParser.parseFunctionBegin(reader);
    } else if (keyword.equals("return")) {
      return statementParser.parseFunctionReturn(reader);
    } else if (keyword.equals("functionend")) {
      return statementParser.parseFunctionEnd(reader);
    } else if (keyword.equals("if") || keyword.equals("elseif")) {
      return statementParser.parseIf(word, reader);
    } else if (keyword.equals("else")) {
      return NSISStatements.logicLibDefine(reader.getIndent(), "Else");
    } else if (keyword.equals("endif")) {
      return NSISStatements.logicLibDefine(reader.getIndent(), "EndIf");
    } else if (keyword.equals("do")) {
      return statementParser.parseDoLoop("Do", reader);
    } else if (keyword.equals("continue")) {
      return NSISStatements.logicLibDefine(reader.getIndent(), "Continue");
    } else if (keyword.equals("break")) {
      return NSISStatements.logicLibDefine(reader.getIndent(), "Break");
    } else if (keyword.equals("loop")) {
      return statementParser.parseDoLoop("Loop", reader);
    }

    return reader.getCurrentStatement();
  }
 private void check(Statement expected, String... ins) {
   for (String in : ins) {
     final Statement statement = parser.parse(in);
     assertEquals(in, expected.type(), statement.type());
     assertEquals(in, expected.isPrintStatement(), statement.isPrintStatement());
   }
 }
Example #4
0
 /** @see org.mulgara.store.tuples.AbstractTuples#close() */
 @Override
 public void close() throws TuplesException {
   source.terminate();
 }
Example #5
0
 /** @see org.mulgara.store.tuples.AbstractTuples#getRowExpectedCount() */
 public long getRowExpectedCount() throws TuplesException {
   return source.isFinished() ? source.getStatementCount() : Short.MAX_VALUE;
 }
Example #6
0
 /** @see org.mulgara.store.tuples.AbstractTuples#getRowUpperBound() */
 public long getRowUpperBound() throws TuplesException {
   // go for the max number of integers, not longs, since this is more reasonable
   return source.isFinished() ? source.getStatementCount() : Integer.MAX_VALUE;
 }