示例#1
0
 /*
  * Interprets the Print rule.
  */
 private ASTNode interpretPrint(Interpreter interpreter, PrintRuleNode pos)
     throws InterpreterException {
   if (!pos.getMessage().isEvaluated()) {
     return pos.getMessage();
   } else {
     pos.setNode(
         null,
         new UpdateMultiset(
             new Update(
                 PRINT_OUTPUT_FUNC_LOC,
                 new StringElement(pos.getMessage().getValue().toString()),
                 PRINT_ACTION,
                 interpreter.getSelf(),
                 pos.getScannerInfo())),
         null);
   }
   return pos;
 }
示例#2
0
 /*
  * Interprets the Write rule.
  */
 private ASTNode interpretPrintToFile(Interpreter interpreter, PrintToFileRuleNode pos)
     throws InterpreterException {
   if (!pos.getMessage().isEvaluated()) {
     return pos.getMessage();
   }
   if (!pos.getFileName().isEvaluated()) {
     return pos.getFileName();
   } else {
     pos.setNode(
         null,
         new UpdateMultiset(
             new Update(
                 new Location(
                     FILE_OUTPUT_FUNC_NAME,
                     ElementList.create(Arrays.asList(pos.getFileName().getValue()))),
                 new StringElement(pos.getMessage().getValue().toString()),
                 (pos.isAppend() ? APPEND_ACTION : WRITE_ACTION),
                 interpreter.getSelf(),
                 pos.getScannerInfo())),
         null);
   }
   return pos;
 }