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

35
LINES

< > BotCompany Repo | #1002056 // C# to JavaX Translator (googleMe function) - WORKS

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1540L/11K/34K).

1  
!752
2  
3  
p {
4  
  L<S> tok = javaTok(loadSnippet("#1002054")); // googleMe
5  
  
6  
  // classes are UPPER case!
7  
  
8  
  replaceToken(tok, "string", "String");
9  
  
10  
  // ...while methods are LOWER case.
11  
  
12  
  replaceToken(tok, "Split", "split");
13  
  replaceToken(tok, "Equals", "equals");
14  
  replaceToken(tok, "Add", "add");
15  
  replaceToken(tok, "ToLower", "toLowerCase");
16  
17  
  // some syntax
18  
  replaceToken(tok, "in", ":");
19  
  replaceToken(tok, "foreach", "for");
20  
  
21  
  // split function takes a string in Java
22  
  for (int i = 1; i+6 < l(tok); i += 2)
23  
    if (eq(tok.get(i), "split") && eq(tok.get(i+2), "(") && tok.get(i+4).startsWith("'") && eq(tok.get(i+6), ")"))
24  
      tok.set(i+4, charToStringLiteral(tok.get(i+4)));
25  
26  
  jreplace(tok, "new List", "new ArrayList");
27  
  jreplace(tok, ".Count", ".size()");
28  
  jreplace(tok, "[*]", ".get($2)");
29  
  jreplace(tok, "Uri.EscapeDataString", "urlencode");
30  
  print(join(tok));
31  
}
32  
33  
static S charToStringLiteral(S s) {
34  
  ret "\"" + s.charAt(1) + "\""; // todo: special cases
35  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002056
Snippet name: C# to JavaX Translator (googleMe function) - WORKS
Eternal ID of this version: #1002056/1
Text MD5: 04804ac9a12ffc8dccaaf6e857b61eb0
Transpilation MD5: d125be56b90419e5c0f8179024c80515
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-23 00:22:14
Source code size: 1021 bytes / 35 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 689 / 701
Referenced in: [show references]