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).

!7

static Object androidContext;

public static void main(S[] args) ctex {
  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].intern(), 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";
    else if (id == "uploadImage") id = #1034134;
    else if (id == "uploadFile") id = #1033518;
    
    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);
  
  // super-short syntax ("!636 (modern)" in first line)
  if (_args.indexOf("modern") >= 0)
    s = "!modern\n" + s;
  
  boolean modern = false;
  if (("\n" + s).indexOf("\n!modern") >= 0) {
    modern = true;
    s = s.replace("\n!class _javax 19", "");
    String replacement = "\n" +
      "!sf\n" +
      "!cast\n" +
      "!L<S>\n" +
      "!* ctr\n" +
      "!strings ==\n" +
      "!multi-line strings\n" +
      "!runnable {\n";

    replacement += "\n!thread {";
    
    s = ("\n" + s).replace("\n!modern", replacement).substring(1) 
      + "\n!1000703"; // add class _javax if necessary
  }
  
  boolean nostd = false;
  
  if (s.indexOf("!quicktranslator") >= 0) {
    s = s.replace("!quicktranslator",
      "!1000347\n" +
      "!standard functions\n" +
      "!636");
  } else if (s.indexOf("!translator") >= 0) {
    s = s.replace("!translator",
      "!main\n" +
      "!standard functions\n" +
      "!596 628");
  } else {
    // standard main program (not a translator)
    // auto-import and quickmain are now enabled by default.
    // new: quicknew and ctex too.
    s = s.replace("!auto-import", "");
    s = s.replace("!quickmain", "");
    s = s.replace("!quicknew", "");
    s = s.replace("!ctex", "");
    
    if (s.indexOf("\n!nostd") >= 0) {
      s = s.replace("\n!nostd", "");
      nostd = true;
    } else {
      s = s + "\n!628"; // hope this doesn't break anything
      s = "!596\n" + s; // auto-import
      s = s + "\n!680\n!700"; // quicknew, ctex
    }
  }
  
  s = (("\n" + s).replace("\n!simplejava", "\n!1000368\n")).substring(1); // \n is important here
  
  s = s.replace("!main", "!609");
  s = s.replace("!class _x14", "!641");
  s = s.replace("!class _x18", "!include #1000571");
  s = s.replace("!class _javax 19", "!include #1000572");
  s = s.replace("!multi-line strings", "!699");
  s = s.replace("!class JavaTok", "!686");
  s = s.replace("\n!JavaTok", "\n!include #1000353");
  s = s.replace("!* constructors", "!697");
  s = s.replace("\n!L<S>", "\n!723"); // L, S, O, ret and so on
  s = s.replace("!quickandroid", "!713");
  s = s.replaceAll("!\\* (constructor|ctr)s?", "!697");
  s = s.replace("!FrameWithImages", "!include #1000539");
  s = s.replace("!image classes", "!include #1001447");
  s = s.replace("!standard functions", "!629");
  s = s.replace("!snipcom", "!1000607"); // snippet commenter
  s = s.replace("\n!_case", "\n!1000346"); // "case" as a variable name
  s = s.replace("\n!sf", "\n!629"); // standard functions
  s = s.replaceAll("\n!strings? ==", "\n!1000636"); // compare strings with "==" (selected cases only)
  s = s.replace("\n!cast", "\n!1000482"); // S s = cast in;
  s = s.replace("!actionListener {", "!614");
  s = s.replace("!awt {", "!1000805");
  s = s.replace("!thread {", "!721");
  s = s.replace("!stringfunc {", "!1000635");
  s = s.replace("!runnable {", "!711");
  s = s.replace("\n!pcall {", "\n!1001188");
  s = s.replace("\n!pcall", "\n!1001188");
  s = s.replaceAll("!named threads?", "!1001362");
  s = s.replace("!getCurrentCodeLine", "!1001487");
   
  // 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();
  }
  
  // !x123 translator syntax
  s = ("\n"+s).replaceAll("\n!x(\\d+)", "\n!$1").substring(1);
  
  //s = moveImportsUp(s);
  if (!nostd)
    s = s + "\n!1000691"; // move imports up
  if (modern)
    s = s + "\n!1001045"; // double variable remover
  
  saveMainJava(s);
}

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: 1971 / 41020
Version history: 5 change(s)
Referenced in: [show references]