!596 !629 !1000706 // string == !1000693 // resolve includes public class main { static Object androidContext; static String programID; !include #1001496 // Matches public static void main(String[] args) throws Exception { if (mainJava == null && readTextFile("input/main.java", null) == null) { // invoked not as a translator, but as a main program // check our favorite scripts if (args.length == 0) return; String id = args[0], id2 = args.length > 1 ? args[0] + " " + args[1] : ""; if (id == "learner") id = "#745"; else if (id == "search") id = "#1000718"; else if (id == "search-runnables") id = "#1000758"; else if (id == "zipsplit") id = "#1000728"; else if (id == "latest") id = "#1000778"; else if (id == "runnables") id = "#1000778"; else if (id == "num" && args.length > 1 && args[1].equals("widget")) { id = "#1000655"; args = drop(1, args); } else if (id == "swing-top") id = "#1000795"; else if (id == "console-top") id = "#1001772"; else if (id == "swing-start") id = "#1000825"; else if (id == "set") id = "#1000797"; else if (id2 == "brain on") id = "#1000953"; else if (id2 == "brain off") id = "#1000954"; else if (id == "talk") id = isAndroid() ? "#1001081" : "#1001085"; else if (id2 == "hello world") id = "#1000414"; else if (id == "upload-data") id = "#1000755"; else if (id == "speech") id = "#1001131"; else if (id == "tel" || id == "telbot" || id2 == "tel bot") id = "#1001146"; else if (id == "leo") id = "#1001297"; else if (id == "restart") id = "#1001353"; else if (id == "kill") id = "#1001354"; if (!isSnippetID(id)) callMain(hotwire("#1000758"), args); // perform search for runnables else callMain(hotwire(id), drop(1, args)); return; } // invoked as a translator String s = loadMainJava(); String _args = join(" ", args); //System.err.println("Args: " + _args); // process include statements for (int n = 0; n < 1000; n++) { Matcher m = Pattern.compile("!include (#\\d+)").matcher(s); StringBuffer buf = new StringBuffer(); if (!m.find()) break; else do { String includedSrc = loadSnippet(m.group(1)); m.appendReplacement(buf, m.quoteReplacement(includedSrc)); } while (m.find()); m.appendTail(buf); s = buf.toString(); } saveMainJava(s); } }