Libraryless. Click here for Pure Java version (1554L/11K/36K).
!747 m { p { S input = loadSnippet("#1001519"); L<S> tok = javaTok(input); new L out; int count = 0; for (int i = 0; i < tok.size(); i++) { S t = tok.get(i); if ((i & 1) == 1 && isOpening(t)) { ++count; out.addAll(litlist(Color.green, t, Color.white)); } else if ((i & 1) == 1 && isClosing(t)) { --count; out.addAll(litlist(Color.blue, t, Color.white)); } else out.add(t); } JTextPane textPane = showColoredText(out); S comment = count == 0 ? "Brackets match." : "Bracket match error " + count; addCommentToWindow(textPane, comment); addSaveButton(textPane, "Marked opening and closing tokens", out); } static boolean isOpening(S s) { ret litlist("<", "(", "{", "[").contains(s); } static boolean isClosing(S s) { ret litlist(">", ")", "}", "]").contains(s); } }
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: | #1001525 |
| Snippet name: | Mark opening and closing tokens in JavaX source |
| Eternal ID of this version: | #1001525/1 |
| Text MD5: | 84a30db9ee2c0d8ed1d74b71185510db |
| Transpilation MD5: | 8ab05a186a7114ef68eda68b76946fad |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-10-22 18:06:48 |
| Source code size: | 937 bytes / 35 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 857 / 960 |
| Referenced in: | [show references] |