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

14
LINES

< > BotCompany Repo | #1018199 // ai_groupUsingProductions

JavaX fragment (include)

sS ai_groupUsingProductions(S s, AI_BottomUpParser1 p) {
  p.splitSplittables = false;
  p.parse(javaTokNPunctuation(s));
  for (AI_BottomUpParser1.Word g : p.groups()) {
    int i = g.wordFrom*2+1, j = g.wordTo*2-1;
    S pre = get(p.cnc, i-1), post = get(p.cnc, j+1);
    //print("pre=" + pre + ", post=" + post);
    if (endsWith(pre, "{") && startsWith(post, "}"))
      continue;
    tokPrepend(p.cnc, i, "{");
    tokAppend(p.cnc, j, "}");
  }
  ret join(p.cnc);
}

Author comment

Began life as a copy of #1018198

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018199
Snippet name: ai_groupUsingProductions
Eternal ID of this version: #1018199/10
Text MD5: 3a7f127fd354cc8e4ff0c13b5563fea9
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-06 16:04:43
Source code size: 483 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 342 / 374
Version history: 9 change(s)
Referenced in: [show references]