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

27
LINES

< > BotCompany Repo | #1004872 // Test Lua Tokenizer [WORKS]

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

Uses 5262K of libraries. Click here for Pure Java version (605L/4K/15K).

!752

lib 1004739 // (latest?) aibo

import org.luaj.vm2.parser.LuaParserTokenManager;
import org.luaj.vm2.parser.LuaParserConstants;
import org.luaj.vm2.parser.Token;
import org.luaj.vm2.parser.SimpleCharStream;

p {
  S lua = [[
    function entry0 (o)
      N=N + 1
      local title = o.title or '(no title)'
      fwrite('<LI><A HREF="#%d">%s</A>\n', N, title)
    end
  ]];
  
  SimpleCharStream scs = new SimpleCharStream(new StringReader(lua));
  LuaParserTokenManager tm = new LuaParserTokenManager(scs);
  
  Token t;
  while (licensed() && (t = tm.getNextToken()).kind != LuaParserConstants.EOF) {
    S kindName = get(LuaParserConstants.tokenImage, t.kind);
    print("Token: " + quote(t.image) + " (kind: " + t.kind + " / " + kindName + ")");
  }
}

Author comment

Began life as a copy of #1004741

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: #1004872
Snippet name: Test Lua Tokenizer [WORKS]
Eternal ID of this version: #1004872/1
Text MD5: 297f717b78ce37972665abaed197eab3
Transpilation MD5: 86d34cf6d4b2b0330583957d882dc95c
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-09-11 18:18:21
Source code size: 787 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 470 / 529
Referenced in: [show references]