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

46
LINES

< > BotCompany Repo | #1014245 // tok_p_new - replace p-... {} (new version, dev.)

JavaX fragment (include)

1  
static tok_p_new(L<S> tok) {
2  
  bigbigloop: do {
3  
    bool changes = false;
4  
    bigloop: for (int i : jfindAll(tok, "p-")) {
5  
      int j = i+4;
6  
      new L<S> clauses;
7  
      while (isIdentifier(get(tok, j))) {
8  
        clauses.add(get(tok, j));
9  
        S t = get(tok, j+2);
10  
        if (eq(t, "-")) { j += 4; continue; }
11  
        if (eq(t, "{")) { j += 2; break; }
12  
        continue bigloop; // not a match
13  
      }
14  
      
15  
      // i points to "p", j points to "{"
16  
      
17  
      clearTokens(tok, i+1, j-1); // drop clauses
18  
      
19  
      for (S c : clauses) {
20  
        if (eqOneOf(c, "autorestart", "autoupdate"))
21  
          tokAppend(tok, j, " autoUpdate();");
22  
        if (eqOneOf(c, "noconsole"))
23  
    jreplace(tok, "p-noconsole-autoupdate {", "p-noconsole { autoUpdate();");
24  
    jreplace(tok, "p-pretty {", "p-noconsole {");
25  
    replaceKeywordBlock(tok, "p-awt-noconsole", "p-awt {", ";\nhideConsole(); }");
26  
    replaceKeywordBlock(tok, "p-substance-noconsole", "p-substance {", ";\nhideConsole(); }");
27  
    replaceKeywordBlock(tok, "p-nimbus-noconsole", "p-nimbus {", ";\nhideConsole(); }");
28  
    replaceKeywordBlock(tok, "p-subst-noconsole", "p-subst {", ";\nhideConsole(); }");
29  
    replaceKeywordBlock(tok, "p-noconsole", "p-subst {", ";\nhideConsole(); }");
30  
    replaceKeywordBlock(tok, "p-subst", "p-substance-thread {", "}");
31  
    replaceKeywordBlock(tok, "p-substance-thread", "p { substance();", "}");
32  
    replaceKeywordBlock(tok, "p-magellan-thread", "p { magellan();", "}");
33  
    replaceKeywordBlock(tok, "p-substance", "p-awt { substance();", "}");
34  
    replaceKeywordBlock(tok, "p-nimbus", "p-awt { nimbus();", "}");
35  
    replaceKeywordBlock(tok, "p-center", "p { centerConsole(); ", "}");
36  
    jreplace(tok, "p-type {", "p-typewriter {");
37  
    jreplace(tok, "p-tt {", "p-typewriter {");
38  
    replaceKeywordBlock(tok, "p-awt", "p { swing {", "}}");
39  
    replaceKeywordBlock(tok, "p-typewriter", "p { typeWriterConsole();", "}");
40  
    replaceKeywordBlock(tok, "p-lowprio", "p { lowPriorityThread(r " + "{", "}); }");
41  
      changes = true; reTok(tok, i, j+1); continue bigbigloop;
42  
    }
43  
  } while (changes);
44  
  
45  
  tok_p_old(tok);
46  
}

Author comment

Began life as a copy of #1014244

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1014245
Snippet name: tok_p_new - replace p-... {} (new version, dev.)
Eternal ID of this version: #1014245/1
Text MD5: 62f3bb95b374a7fa5244e38da4681681
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-04-17 16:09:35
Source code size: 2164 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 354 / 392
Referenced in: [show references]