!636 !class JavaTok main { psvm { String out = "[[import]] java.*; [[import]] javax.*;"; Set<Integer> markers = new HashSet<Integer>(getFindMarkers(out)); String in = out.replace("[[", "").replace("]]", ""); List<String> l = JavaTok.split(in); int i = 0; for (String t : l) { if (t.length() != 0 && markers.contains(i) && markers.contains(i+t.length())) System.out.println("Marked token found: " + t + " at " + i); i += t.length(); } } static List<Integer> getFindMarkers(String s) { List<Integer> l = new ArrayList<Integer>(); int i = 0, ofs = 0; while (i < s.length()) { int j = s.indexOf("[[", i); if (j < 0) break; int k = s.indexOf("]]", j+2); if (k < 0) break; l.add(j-ofs); ofs += 2; l.add(k-ofs); ofs += 2; i = k+2; } /*int[] result = new int[l.size()]; for (i = 0; i < result.length; i++) result[i] = l.get(i); return result;*/ return l; } }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1000466 |
Snippet name: | JavaTok + finding test |
Eternal ID of this version: | #1000466/1 |
Text MD5: | 3adfdb8c3a8debd85ef550533b68bd3d |
Author: | stefan |
Category: | |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-08-08 16:14:56 |
Source code size: | 1039 bytes / 38 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 641 / 541 |
Referenced in: | [show references] |