Libraryless. Click here for Pure Java version (94L/2K/4K).
1 | // A JavaX extension for multi-line strings, modelled after Lua [[ ]] quotes. |
2 | |
3 | !592 1000265 // auto-importer, standard function adder |
4 | |
5 | public class main { |
6 | public static void main(String[] args) throws Exception { |
7 | String s = loadMainJava(); |
8 | |
9 | StringBuffer out = new StringBuffer(); |
10 | |
11 | // [\s\S] is a clever trick to match all characters including newlines. |
12 | Pattern regex = Pattern.compile("\\[\\[([\\s\\S]*?)\\]\\]"); |
13 | |
14 | Matcher matcher = regex.matcher(s); |
15 | //print "Matching source code" |
16 | while (matcher.find()) { |
17 | //print "double brackets found" |
18 | String string = matcher.group(1); |
19 | string = string.replaceAll("^[\t ]*\r?\n", ""); // first newline is ignored in Lua too |
20 | //System.out.println("String: " + string); |
21 | String replacement = makeJavaStringLiteral(string); |
22 | //stem.out.println("Replacement: " + replacement); |
23 | matcher.appendReplacement(out, matcher.quoteReplacement(replacement)); // quoting is important... |
24 | } |
25 | matcher.appendTail(out); |
26 | |
27 | s = out.toString(); |
28 | //System.out.println("Translated source:\n" + s); |
29 | saveMainJava(s); |
30 | } |
31 | } |
download show line numbers debug dex old transpilations
Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, hxnwyiuffukg, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, qbtsjoyahagl, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
ID | Author/Program | Comment | Date |
---|---|---|---|
465 | #1000610 (pitcher) | 2015-08-18 00:07:07 | |
464 | #1000604 (pitcher) | 2015-08-18 00:07:22 |
Snippet ID: | #605 |
Snippet name: | JavaX multi-line-strings (JavaX translator, replaced by #699) |
Eternal ID of this version: | #605/1 |
Text MD5: | 6b6e2f0df1f89a0e5efe1fa49c8752eb |
Transpilation MD5: | 3cb4ab095df0bb819f213634a2ee8eeb |
Author: | stefan |
Category: | |
Type: | JavaX translator |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-10-20 22:59:11 |
Source code size: | 1163 bytes / 31 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 2120 / 1561 |
Referenced in: | [show references] |