コード例 #1
0
 /**
  * This function takes a string script, and returns an equivalent, optimized script.
  *
  * @param script
  * @return
  * @throws ConfigCompileException
  */
 public static String optimize(String script, File source) throws ConfigCompileException {
   ParseTree tree = MethodScriptCompiler.compile(MethodScriptCompiler.lex(script, source, true));
   StringBuilder b = new StringBuilder();
   // The root always contains null.
   for (ParseTree child : tree.getChildren()) {
     b.append(optimize0(child));
   }
   return b.toString();
 }
コード例 #2
0
 /**
  * Compiles the script, converting it into mid level object code, or in the case of a language
  * compiler, the other language's source code.
  *
  * @param script
  * @param platform
  * @return
  */
 public static String compile(String script, api.Platforms platform, File file)
     throws ConfigCompileException {
   // First, we optimize. The "core" functions are always run through
   // the native interpreter's compiler for optimization.
   ParseTree tree = MethodScriptCompiler.compile(MethodScriptCompiler.lex(script, file, true));
   StringBuilder b = new StringBuilder();
   for (ParseTree node : tree.getChildren()) {
     go(node, b, platform);
   }
   return b.toString();
 }