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

26
LINES

< > BotCompany Repo | #1008924 // ctxCase

JavaX fragment (include)

1  
// returns: (CtxCase, closing line number)
2  
// or null
3  
static Pair<CtxCase, Int> ctxCase(L<S> lines, int i) {
4  
  new Matches m;
5  
  new CtxCase c;
6  
  while (i <= l(lines) && emptyAfterTrim(get(lines, i))) ++i;
7  
  S l = get(lines, i);
8  
  
9  
  if (startsWith(trim(get(lines, i+1)), ")")) {
10  
    lines.set(i, l += get(lines, i+1));
11  
    lines.remove(i+1);
12  
  }
13  
  
14  
  if (jmatch("DEFAULT ACTION", l) || jmatch("ACTION", l)) {}
15  
  else if (flexMatch("CASE (*) ACTION", l, m, false))
16  
    c.condition = m.get(0);
17  
  else null;
18  
  
19  
  Pair<SS, Int> p = ctxParseProperties(lines, i+1);
20  
  c.properties = p.a;
21  
22  
  int opening = p.b;
23  
  int closing = indexOfClosingCurlyBracket(lines, p.b);
24  
  c.action = tok_unCurlyBracket(lines(subList(lines, p.b, closing+1)));
25  
  ret pair(c, closing);
26  
}

Author comment

Began life as a copy of #1008883

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: #1008924
Snippet name: ctxCase
Eternal ID of this version: #1008924/6
Text MD5: 337c9b1c32f58c44a1117859ef002d3f
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-07-14 18:37:17
Source code size: 782 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 388 / 452
Version history: 5 change(s)
Referenced in: [show references]