Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

30
LINES

< > BotCompany Repo | #1004829 // Show Tokens [pre-experiment]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Compilation Failed (3761L/25K).

!752

!include #1004828 // Java Analysis

p {
  loadConceptsFrom("#1004820");
  JavaTok j = conceptOfType(JavaTok.class);
  L<Token> tokens = sortedByField(findBackRefs(j, Token.class), "index");
  new StringBuilder buf;
  int i = 0;
  for (Token t : tokens) {
    buf.append(htmlencode(substring(j.text, i, t.charIndex)));
    S col = odd(t.index/2) 
      //? "#b8d1f3" : "#dae5f4";
      ? "#CC0000" : "#0000CC"; // Coder Colors!
    buf.append(span(b(href(str(t.index), htmlencode(t.token()))), "style", "color: " + col));
    i = t.charIndex + l(t.token());
  }
  buf.append(htmlencode(substring(j.text, i)));
  
  S html = hhtml(pre(buf));
  JEditorPane editorPane = new JEditorPane("text/html", html);
  editorPane.setEditable(false);
  editorPane.addHyperlinkListener(new HyperlinkListener {
    public void hyperlinkUpdate(HyperlinkEvent e) {
      print("Event! " + e.getEventType() + " " + e.getDescription() + " " + e.getURL());
    }
  });
  showFrame(new JScrollPane(editorPane));
}

Author comment

Began life as a copy of #1004827

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004829
Snippet name: Show Tokens [pre-experiment]
Eternal ID of this version: #1004829/1
Text MD5: 687bd0f6034e2a68bfff2310154dd5e9
Transpilation MD5: 7373483c2022ce78b11dbf5f3c9ccad3
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-09-05 15:27:56
Source code size: 1025 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 462 / 587
Referenced in: [show references]