!747 m { p { S input = loadSnippet("#1001519"); L 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); } }