Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

161
LINES

< > BotCompany Repo | #636 // Resolve symbolic translator invocations

JavaX translator [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (8708L/51K).

1  
!7
2  
3  
static Object androidContext;
4  
5  
public static void main(S[] args) ctex {
6  
  if (mainJava == null && readTextFile("input/main.java", null) == null) {
7  
    // invoked not as a translator, but as a main program
8  
    
9  
    // check our favorite scripts
10  
    if (args.length == 0) return;
11  
    
12  
    String id = args[0].intern(), id2 = args.length > 1 ? args[0] + " " + args[1] : "";
13  
    if (id == "learner") id = "#745";
14  
    else if (id == "search") id = "#1000718";
15  
    else if (id == "search-runnables") id = "#1000758";
16  
    else if (id == "zipsplit") id = "#1000728";
17  
    else if (id == "latest") id = "#1000778";
18  
    else if (id == "runnables") id = "#1000778";
19  
    else if (id == "num" && args.length > 1 && args[1].equals("widget")) { id = "#1000655"; args = drop(1, args); }
20  
    else if (id == "swing-top") id = "#1000795";
21  
    else if (id == "console-top") id = "#1001772";
22  
    else if (id == "swing-start") id = "#1000825";
23  
    else if (id == "set") id = "#1000797";
24  
    else if (id2 == "brain on") id = "#1000953";
25  
    else if (id2 == "brain off") id = "#1000954";
26  
    else if (id == "talk") id = isAndroid() ? "#1001081" : "#1001085";
27  
    else if (id2 == "hello world") id = "#1000414";
28  
    else if (id == "upload-data") id = "#1000755";
29  
    else if (id == "speech") id = "#1001131";
30  
    else if (id == "tel" || id == "telbot" || id2 == "tel bot") id = "#1001146";
31  
    else if (id == "leo") id = "#1001297";
32  
    else if (id == "restart") id = "#1001353";
33  
    else if (id == "kill") id = "#1001354";
34  
    else if (id == "uploadImage") id = #1034134;
35  
    else if (id == "uploadFile") id = #1033518;
36  
    
37  
    if (!isSnippetID(id))
38  
      callMain(hotwire("#1000758"), args); // perform search for runnables
39  
    else
40  
      callMain(hotwire(id), drop(1, args));
41  
    return;
42  
  }
43  
  
44  
  // invoked as a translator
45  
  
46  
  String s = loadMainJava();
47  
  
48  
  String _args = join(" ", args);
49  
  //System.err.println("Args: " + _args);
50  
  
51  
  // super-short syntax ("!636 (modern)" in first line)
52  
  if (_args.indexOf("modern") >= 0)
53  
    s = "!modern\n" + s;
54  
  
55  
  boolean modern = false;
56  
  if (("\n" + s).indexOf("\n!modern") >= 0) {
57  
    modern = true;
58  
    s = s.replace("\n!class _javax 19", "");
59  
    String replacement = "\n" +
60  
      "!sf\n" +
61  
      "!cast\n" +
62  
      "!L<S>\n" +
63  
      "!* ctr\n" +
64  
      "!strings ==\n" +
65  
      "!multi-line strings\n" +
66  
      "!runnable {\n";
67  
68  
    replacement += "\n!thread {";
69  
    
70  
    s = ("\n" + s).replace("\n!modern", replacement).substring(1) 
71  
      + "\n!1000703"; // add class _javax if necessary
72  
  }
73  
  
74  
  boolean nostd = false;
75  
  
76  
  if (s.indexOf("!quicktranslator") >= 0) {
77  
    s = s.replace("!quicktranslator",
78  
      "!1000347\n" +
79  
      "!standard functions\n" +
80  
      "!636");
81  
  } else if (s.indexOf("!translator") >= 0) {
82  
    s = s.replace("!translator",
83  
      "!main\n" +
84  
      "!standard functions\n" +
85  
      "!596 628");
86  
  } else {
87  
    // standard main program (not a translator)
88  
    // auto-import and quickmain are now enabled by default.
89  
    // new: quicknew and ctex too.
90  
    s = s.replace("!auto-import", "");
91  
    s = s.replace("!quickmain", "");
92  
    s = s.replace("!quicknew", "");
93  
    s = s.replace("!ctex", "");
94  
    
95  
    if (s.indexOf("\n!nostd") >= 0) {
96  
      s = s.replace("\n!nostd", "");
97  
      nostd = true;
98  
    } else {
99  
      s = s + "\n!628"; // hope this doesn't break anything
100  
      s = "!596\n" + s; // auto-import
101  
      s = s + "\n!680\n!700"; // quicknew, ctex
102  
    }
103  
  }
104  
  
105  
  s = (("\n" + s).replace("\n!simplejava", "\n!1000368\n")).substring(1); // \n is important here
106  
  
107  
  s = s.replace("!main", "!609");
108  
  s = s.replace("!class _x14", "!641");
109  
  s = s.replace("!class _x18", "!include #1000571");
110  
  s = s.replace("!class _javax 19", "!include #1000572");
111  
  s = s.replace("!multi-line strings", "!699");
112  
  s = s.replace("!class JavaTok", "!686");
113  
  s = s.replace("\n!JavaTok", "\n!include #1000353");
114  
  s = s.replace("!* constructors", "!697");
115  
  s = s.replace("\n!L<S>", "\n!723"); // L, S, O, ret and so on
116  
  s = s.replace("!quickandroid", "!713");
117  
  s = s.replaceAll("!\\* (constructor|ctr)s?", "!697");
118  
  s = s.replace("!FrameWithImages", "!include #1000539");
119  
  s = s.replace("!image classes", "!include #1001447");
120  
  s = s.replace("!standard functions", "!629");
121  
  s = s.replace("!snipcom", "!1000607"); // snippet commenter
122  
  s = s.replace("\n!_case", "\n!1000346"); // "case" as a variable name
123  
  s = s.replace("\n!sf", "\n!629"); // standard functions
124  
  s = s.replaceAll("\n!strings? ==", "\n!1000636"); // compare strings with "==" (selected cases only)
125  
  s = s.replace("\n!cast", "\n!1000482"); // S s = cast in;
126  
  s = s.replace("!actionListener {", "!614");
127  
  s = s.replace("!awt {", "!1000805");
128  
  s = s.replace("!thread {", "!721");
129  
  s = s.replace("!stringfunc {", "!1000635");
130  
  s = s.replace("!runnable {", "!711");
131  
  s = s.replace("\n!pcall {", "\n!1001188");
132  
  s = s.replace("\n!pcall", "\n!1001188");
133  
  s = s.replaceAll("!named threads?", "!1001362");
134  
  s = s.replace("!getCurrentCodeLine", "!1001487");
135  
   
136  
  // process include statements
137  
138  
  for (int n = 0; n < 1000; n++) {   
139  
    Matcher m = Pattern.compile("!include (#\\d+)").matcher(s);
140  
    StringBuffer buf = new StringBuffer();
141  
    if (!m.find())
142  
      break;
143  
    else do {
144  
      String includedSrc = loadSnippet(m.group(1));
145  
      m.appendReplacement(buf, m.quoteReplacement(includedSrc));
146  
    } while (m.find());
147  
    m.appendTail(buf);
148  
    s = buf.toString();
149  
  }
150  
  
151  
  // !x123 translator syntax
152  
  s = ("\n"+s).replaceAll("\n!x(\\d+)", "\n!$1").substring(1);
153  
  
154  
  //s = moveImportsUp(s);
155  
  if (!nostd)
156  
    s = s + "\n!1000691"; // move imports up
157  
  if (modern)
158  
    s = s + "\n!1001045"; // double variable remover
159  
  
160  
  saveMainJava(s);
161  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 248 computer(s): aaaozbpfwjtg, adtiomwmedle, aflirysandid, ajlfxifxfcul, anooyockkxlp, aoiabmzegqzx, asxxtyozwoqd, avbpxltnosnb, bahniawxbcqn, bdgavtshraed, bhatertpkbcr, bhjedvfzfefa, bmpajyrcbdmy, bohwhuwtvtqa, bpcvmhnhpnwl, bpdahkofjiqu, bqzkeqnoefrm, bsevpdnawsof, bvpoyihotdib, bwuateqqdfmn, bzsirmaerhyh, cahelewubzku, cbybwowwnfue, ccgoxamnydpc, cfunsshuasjs, ciqjbxgaxmmu, cmhtpxxajurv, cqrjhgyzfjlt, cszwuvalptpv, cumzdlevxjhb, dajmadmolbsg, dcpmmjrsyaef, dcuamxduqbwz, ddnzoavkxhuk, dfeuitffkosc, dfpktomomgiy, dhtckqrhrkuh, dhtvkmknsjym, dlutczvngstc, dlyzodsxvbls, dvxvdlhqlwwc, dxbeedkbfnhl, ecqjixtmvxlp, elcqnltbtlmw, engnoommhqqg, eozaicwrnmri, exkalrxbqyxc, ezoomgjfwvrt, fbkgdwxxdfsr, fkrfqjixqhbh, flwlchajcels, fumpprspadck, fvctnogetyww, fwsfnrxjlvle, fxcunjhekivx, fxxhkfmtwnmu, gbdqvketdppm, gjtlkbvenryc, gjwhesigvbjt, gkwdfizivqfm, gmamsftpcggf, grraasralroa, gsoxhkmxfcgg, gwrvuhgaqvyk, gysdlqwixlqa, gzronoodcfmh, hgdtlmarmcyu, hgzdogfqphdj, hkhosrvqzeir, hkknpzsgoixq, hvbppbdwfhjy, hxnwyiuffukg, idcfvzviszxn, ieogsxgfxkhr, ihhfaimhzfdu, ikwzpdonmerm, inzdgbwbursp, ipcmaqahdjtn, irtolqhebopo, ishqpsrjomds, ivboptktitbi, izjkhafotetg, jaezsmbrhigw, jafadovzdlvp, jbantpgoyebk, jbarrfjkhowm, jhnqykpxgsbl, jkdanpwwcrwj, jlatgrcjtklg, jlclqeenhjie, jllmwaswmyou, jrjfgvlejbol, jrjpqrqxafhk, jthveqkxsgoj, jtubtzbbkimh, jubvyydqgymk, juoogxzczvcr, jwlibnwemntm, jydjsjoljrpx, kbnhuuvuiiwn, kiawvgutsbre, kkwybtkpyotm, kmhbujppghqa, knlrzzeudezv, kvdnxqgweqgy, kyaxnulraeza, lcawhpckrzve, ledgnsvlgdlr, lfjgsyhgiptj, lgdvxdgcpgrv, lijxzhtxxnix, liwcxgsjrgqn, lldtbxzncybz, lnjhkqwteiwi, lpdgvwnxivlt, lrrquycdonpu, lsgdidgppwqq, lwfphbruhgtm, lwljqdntcrta, mdbqpbajgrux, mdefezkwdeup, meaqxkopohqc, mghvpyimvrpd, mmaxggujatqf, mmmwsgafmleu, mmndgowhgarm, mowyntqkapby, mqqgnosmbjvj, mqwiqbqrcsnt, mrjhfnjfopze, mymsicwluabb, ndavzgiapdkk, nmhwwpuvbanc, nnqwlkwkdqrv, nrtiiiyxqhmw, nrvadtjxpxwv, nvdyqkgcyptl, odccbeesmgrc, oehwoqaiphln, ohyedqndxorl, olawzmuysxfx, oludmslcwfhg, omrbxrqoiqeh, omzkqqnokwlv, ondhtgnbmnbl, onfqjnomoxuw, onxytkatvevr, opsabzhijxss, owufzeapjptr, pbkneffjskob, pdduqrfjxjtl, pekvfmzvrlzt, poqwhsagaigq, ppjhyzlbdabe, ppwwtnwhztze, projrnnbjcax, ptzpezxzmhea, pvxaxjkaklcz, pyentgdyhuwx, pzhvpgtvlbxg, qbewclceftql, qbtsjoyahagl, qhcvkqotyiga, qmupjbhcwcol, qrfquskgykqk, qyyafgaqqzjz, recxuykagbtt, refujxkmkgkh, rmuapfwsxktw, rrdbpurifunk, rszzmtjvwwfb, rtwyroatpxyl, rvtnhsczqyoo, rxxefipihrnz, rzosbdjbglvz, sawdedvomwva, sbdalojjsgih, sckioomnqqko, sksrqysvpwbz, skttnvmfkzhq, srccdhnepxlu, stxcqlnwktct, syuwsgrxoawq, teubizvjbppd, tguojfckhoqc, tjdudtkuyojd, tjlxajtkkewf, tslmcundralx, tsuzdeebumli, tucydzhuhpyp, tvejysmllsmz, tvkpfieynkqz, txvdafyrfdei, tzrwvcudwore, ucpxxyxryupy, ufhdzwgrioxs, ugaerffjihbu, ugbnzuvxksoj, uialujfrwieb, ujpjaavpgwsl, unkrhppcbqnk, upqqmsmdrdxy, uzkajkufykfo, vfpptpbvmian, vouqrxazstgt, vppfrpggqali, vqblocesogdc, vrxkinkxrkvc, vtntixosrifj, vxfwvcicswgz, vzikmbzhlvqi, vzowvpawymmi, wgfiezpoeofi, whxojlpjdney, wjnlxokkmhjo, wnkzkyplbubb, wnqxbhiqleia, wtjtybwyqdag, wtqryiryparv, wwghvftpbobq, wxtevkmfedqj, wymohzkgoolp, xcaxdvrpbipu, xckeyhbjespe, xinetxnxrdbb, xrpafgyirdlv, xvodveaekgke, xvpvmqffgdug, yjprkgrpedlo, ykmfcrgviggk, ylpvoglplpco, ymspyzcyocto, yssmtaczvqko, yvztqpnzifpf, ywixcsqzavbw, yycttscsajwm, yzkscireclhe, zbiehklritnd, zdzzvoocysbf, zfxpbznyxnpx, zkfuzcttwjma, znullqslnikg, zqbbvcbiwejd, zqldwrcgpshj, ztgjuucfqghy, ztkioozjwxcy, zudvenktlakg, zykkvsbksimh

Comments [hide]

ID Author/Program Comment Date
196 #1000604 (pitcher) 2015-08-19 18:17:35

add comment

Snippet ID: #636
Snippet name: Resolve symbolic translator invocations
Eternal ID of this version: #636/6
Text MD5: 9fa79279a30cef9543fe65504e900ccb
Transpilation MD5: 5d0ee74fb89ea976b251c4defa71bc39
Author: stefan
Category:
Type: JavaX translator
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-16 14:24:23
Source code size: 5834 bytes / 161 lines
Pitched / IR pitched: No / No
Views / Downloads: 1972 / 41021
Version history: 5 change(s)
Referenced in: [show references]