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

20
LINES

< > TinyBrain | #1008924 - ctxCase

JavaX fragment (include)

// returns: (CtxCase, closing line number)
// or null
static Pair<CtxCase, Int> ctxCase(L<S> lines, int i) {
  new Matches m;
  new CtxCase c;
  while (i <= l(lines) && emptyAfterTrim(get(lines, i))) ++i;
  S l = get(lines, i);
  if (jmatch("DEFAULT ACTION", l) || jmatch("ACTION", l)) {}
  else if (flexMatch("CASE (*) ACTION", l, m, false))
    c.condition = m.get(0);
  else null;
  
  Pair<SS, Int> p = ctxParseProperties(lines, i+1);
  c.properties = p.a;

  int opening = p.b;
  int closing = indexOfClosingCurlyBracket(lines, p.b);
  c.action = tok_unCurlyBracket(lines(subList(lines, p.b, closing+1)));
  ret pair(c, closing);
}

Author comment

Began life as a copy of #1008883

download  show line numbers  debug dex   

Travelled to 2 computer(s): cfunsshuasjs, tvejysmllsmz

No comments. add comment

Snippet ID: #1008924
Snippet name: ctxCase
Eternal ID of this version: #1008924/5
Text MD5: 0147d2f96b86232fa0e3411d9253587b
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-06-22 19:55:24
Source code size: 655 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 23 / 27
Version history: 4 change(s)
Referenced in: [show]