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

44
LINES

< > TinyBrain | #1008918 - ctxProcessAction

JavaX fragment (include)

static void ctxProcessAction(S body) {
  ctxProcessAction(javaTok(body));
}

static void ctxProcessAction(L<S> tok) {
  if (l(tok) == 1) ret;
  tok = ctxStringProcessing(tok);
  ctxSimplifyIfs(tok);
  if (empty(tok)) ret;
  
  if (jfind(tok, "<id> = true;") == 1) {
    ctxSetVar(tok.get(1), "true");
    ctxProcessAction(subList(tok, 8));
    ret;
  }
  
  if (jfind(tok, "<id> = ") == 1) {
    int semicolon = tok.indexOf(";");
    CtxExpr e = ctxParseExpression(join(subList(tok, 5, semicolon-1)));
    ctxSetVar(tok.get(1), e.str());
    ctxProcessAction(subList(tok, semicolon+1));
    ret;
  }
  
  if (jfind(tok, "agent.say(*);") == 1 && isQuoted(tok.get(9))) {
    ctxAppendOutput(unquoteCtx(tok.get(9)));
    ctxProcessAction(subList(tok, 14));
    ret;
  }
  
  if (jmatch("jumpaway();", tok)) {
    ctxContext().jumpaway = true;
    ret;
  }
  
  if (jfind(tok, "agent.openUrl(*);") == 1) {
    S url = ctxGetVar(tok.get(9));
    ctxContext().urlsToOpen.add(url);
    ctxProcessAction(subList(tok, 14));
    ret;
  }
  
  print("ctxProcessAction unknown: " + structForUser(join(tok)));
}

Author comment

Began life as a copy of #1008896

download  show line numbers  debug dex   

Travelled to 2 computer(s): cfunsshuasjs, tvejysmllsmz

No comments. add comment

Snippet ID: #1008918
Snippet name: ctxProcessAction
Eternal ID of this version: #1008918/16
Text MD5: d5ceae09659aacb10629fb50c8bc49a7
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-25 19:11:20
Source code size: 1141 bytes / 44 lines
Pitched / IR pitched: No / No
Views / Downloads: 34 / 38
Version history: 15 change(s)
Referenced in: [show]