Libraryless. Click here for Pure Java version (94L/2K/4K).
// A JavaX extension for multi-line strings, modelled after Lua [[ ]] quotes. !592 1000265 // auto-importer, standard function adder public class main { public static void main(String[] args) throws Exception { String s = loadMainJava(); StringBuffer out = new StringBuffer(); // [\s\S] is a clever trick to match all characters including newlines. Pattern regex = Pattern.compile("\\[\\[([\\s\\S]*?)\\]\\]"); Matcher matcher = regex.matcher(s); //print "Matching source code" while (matcher.find()) { //print "double brackets found" String string = matcher.group(1); string = string.replaceAll("^[\t ]*\r?\n", ""); // first newline is ignored in Lua too //System.out.println("String: " + string); String replacement = makeJavaStringLiteral(string); //stem.out.println("Replacement: " + replacement); matcher.appendReplacement(out, matcher.quoteReplacement(replacement)); // quoting is important... } matcher.appendTail(out); s = out.toString(); //System.out.println("Translated source:\n" + s); saveMainJava(s); } }
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
2 comment(s) hidden. show
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: | 2121 / 1561 |
Referenced in: | [show references] |