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

36
LINES

< > BotCompany Repo | #1024261 - agiBlue_parseQueryLine

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3213L/20K).

static ALQLLine agiBlue_parseQueryLine(S s) {
  LS tok = javaTokWithBrackets(s);
  
  // TODO: improve jmatch and use here
  if (eqGet(tok, 1, "return") && isIdentifier(get(tok, 3))) {
    LS l = tok_splitAtComma(subList(tok, 2));
    if (l(l) == 1)
      ret ALQLReturn(first(l));
    else
      ret ALQLReturnTuple(l);
  }
    
  T3S t = agiBlue_parseTriple(tok);
  if (t != null)
    ret ALQLTriple(t);
    
  if (lCodeTokens(tok) == 2 && eqGet(tok, 1, "lock")) {
    t = agiBlue_parseTriple(uncurly(tok.get(3)));
    if (t == null) fail("Bad lock statement: " + s);
    ret ALQLLockStatement(t);
  }
    
  if (lCodeTokens(tok) == 2 && eqGet(tok, 1, "page")) {
    S page = uncurly(tok.get(3));
    S method = containsDollarVars(page) ? "flexMatchDollarVarsIC_first" : "eqic";
    ret ALQLPage(page, method);
  }
    
  if (lCodeTokens(tok) == 3 && eqGet(tok, 1, "slice")) {
    S slice = unquote(tok.get(3));
    S contents = uncurly(tok.get(5));
    ret ALQLSlice(slice, agiBlue_parseQueryScript(print(+contents)));
  }
  
  fail("Can't parse ALQL line: " + s);
}

Author comment

Began life as a copy of #1024260

download  show line numbers  debug dex   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pzhvpgtvlbxg, tvejysmllsmz

No comments. add comment

Snippet ID: #1024261
Snippet name: agiBlue_parseQueryLine
Eternal ID of this version: #1024261/12
Text MD5: 89f875274312bd5231fb0a97d080fa6a
Transpilation MD5: 855db322ced48ceb9c4d41e3eaf0f070
Author: stefan
Category: javax / agi.blue
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-03 17:00:34
Source code size: 1104 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 69 / 141
Version history: 11 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1024261 & http://1024261.tinybrain.de