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

34
LINES

< > BotCompany Repo | #1023741 // tok_replaceColonEqualsSyntax

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

Transpiled version (3659L) is out of date.

svoid tok_replaceColonEqualsSyntax(LS tok) {
  int i;
  
  // "field := value" for defining fields e.g. in "uniq"
  while ((i = jfind_check(":", tok, "<id> :=")) >= 0) {
    S id = tok.get(i);
    
    // special case for null := which we interpret as actually null,
    // not "null"
    
    S string = eq(id, "null") ? id : quote(id);
    tok.set(i, string);
    tok.set(i+2, ",");
    tok.set(i+4, "");
    reTok(tok, i, i+5);
  }
  
  // "quoted" := value
  while ((i = jfind_check(":", tok, "<quoted> :=")) >= 0) {
    tok.set(i+2, ",");
    tok.set(i+4, "");
    reTok(tok, i, i+5);
  }
  
  // <int> := value
  while ((i = jfind_check(":", tok, "<int> :=")) >= 0) {
    tok.set(i+2, ",");
    tok.set(i+4, "");
    reTok(tok, i, i+5);
  }
  
  // all other cases: just replace with comma
  jreplace(tok, ":=", ",");
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1023741
Snippet name: tok_replaceColonEqualsSyntax
Eternal ID of this version: #1023741/5
Text MD5: 73d757508c4781f454a8b5658efd18cf
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-10 18:34:33
Source code size: 858 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 233 / 317
Version history: 4 change(s)
Referenced in: [show references]