Uses 911K of libraries. Click here for Pure Java version (11416L/62K).
1 | !7 |
2 | |
3 | set flag DynModule. |
4 | |
5 | cmodule InputTokenizer > DynBigInputAndSections { |
6 | S functions = functions_default; |
7 | sS functions_default = joinWithComma( |
8 | f javaTok, |
9 | f javaTokWithBrackets, |
10 | f javaTokNPunct, |
11 | f javaTokWithAngleBrackets); |
12 | |
13 | JComponent wrapTextArea(JTextArea textArea) { |
14 | ret centerAndSouthWithMargins(textArea, |
15 | centerAndEastWithMargin( |
16 | withLabel("Tokenization functions:", dm_textField('functions)), jbutton("Restore default", r { setField(functions := functions_default) }))); |
17 | } |
18 | |
19 | void makeSections_impl() { |
20 | S text = this.text; |
21 | JTextPane tp = fontSizePlus(5, setFont(typeWriterFont(), jTextPane())); |
22 | bool first = true; |
23 | LPair<S, LS> toks = map_pcall(functions(), fn -> pair(fn, (LS) callAndMake(fn, text))); |
24 | |
25 | // find out max width |
26 | int maxWidth = 0; |
27 | for (LS tok : pairsB(toks)) { |
28 | ai_tokenizationToTextPane(jTextPane(), tok); |
29 | maxWidth = max(maxWidth, ai_tokenizationToTextPane_charsWritten!); |
30 | } |
31 | |
32 | for (Pair<S, LS> fAndTok : toks) pcall { |
33 | if (!first) appendToTextPane(tp, "\n"); else first = false; |
34 | ai_tokenizationToTextPane(tp, fAndTok.b); |
35 | appendToTextPane(tp, spaces(maxWidth-ai_tokenizationToTextPane_charsWritten!+1) + "[" + fAndTok.a + "]"); |
36 | } |
37 | |
38 | addSection("Tokenizations", tp); |
39 | } |
40 | |
41 | Collection<S> functions() { ret tok_allIdentifiers(functions); } |
42 | } |
Began life as a copy of #1022887
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1022891 |
Snippet name: | Input Tokenizer v2 [with colored display, OK] |
Eternal ID of this version: | #1022891/13 |
Text MD5: | b5b19e1789c11117c18dc5f2bee2d47b |
Transpilation MD5: | e2455c0e3e35ae88153e29d667f35326 |
Author: | stefan |
Category: | javax / stefan's os / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-04-14 19:14:51 |
Source code size: | 1434 bytes / 42 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 319 / 1361 |
Version history: | 12 change(s) |
Referenced in: | [show references] |