public void compileMS(MCPlayer player, Environment env) { for (FileInfo fi : ms) { boolean exception = false; try { env.getEnv(CommandHelperEnvironment.class) .SetCommandSender(Static.getServer().getConsole()); MethodScriptCompiler.registerAutoIncludes(env, null); MethodScriptCompiler.execute( MethodScriptCompiler.compile(MethodScriptCompiler.lex(fi.contents, fi.file, true)), env, null, null); } catch (ConfigCompileException e) { exception = true; ConfigRuntimeException.React( e, fi.file.getAbsolutePath() + " could not be compiled, due to a compile error.", player); } catch (ConfigRuntimeException e) { exception = true; ConfigRuntimeException.React(e, env); } catch (CancelCommandException e) { if (e.getMessage() != null && !"".equals(e.getMessage().trim())) { logger.log(Level.INFO, e.getMessage()); } } catch (ProgramFlowManipulationException e) { exception = true; ConfigRuntimeException.React( ConfigRuntimeException.CreateUncatchableException( "Cannot break program flow in main files.", e.getTarget()), env); } finally { env.getEnv(CommandHelperEnvironment.class).SetCommandSender(null); } if (exception) { if (Prefs.HaltOnFailure()) { logger.log( Level.SEVERE, TermColors.RED + "[CommandHelper]: Compilation halted due to unrecoverable failure." + TermColors.reset()); return; } } } logger.log( Level.INFO, TermColors.YELLOW + "[CommandHelper]: MethodScript files processed" + TermColors.reset()); if (player != null) { player.sendMessage(MCChatColor.YELLOW + "[CommandHelper]: MethodScript files processed"); } }
public void compileRight() throws ConfigCompileException { List<Token> temp = new ArrayList<Token>(); right = new ArrayList<List<Token>>(); for (Token t : fullRight) { if (t.type == TType.SEPERATOR) { right.add(temp); temp = new ArrayList<Token>(); } else { if (t.type == TType.WHITESPACE) { continue; // Whitespace is ignored on the right side } temp.add(t); } } right.add(temp); cright = new ArrayList<ParseTree>(); for (List<Token> l : right) { cright.add(MethodScriptCompiler.compile(l)); } }