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.

1  
svoid tok_replaceColonEqualsSyntax(LS tok) {
2  
  int i;
3  
  
4  
  // "field := value" for defining fields e.g. in "uniq"
5  
  while ((i = jfind_check(":", tok, "<id> :=")) >= 0) {
6  
    S id = tok.get(i);
7  
    
8  
    // special case for null := which we interpret as actually null,
9  
    // not "null"
10  
    
11  
    S string = eq(id, "null") ? id : quote(id);
12  
    tok.set(i, string);
13  
    tok.set(i+2, ",");
14  
    tok.set(i+4, "");
15  
    reTok(tok, i, i+5);
16  
  }
17  
  
18  
  // "quoted" := value
19  
  while ((i = jfind_check(":", tok, "<quoted> :=")) >= 0) {
20  
    tok.set(i+2, ",");
21  
    tok.set(i+4, "");
22  
    reTok(tok, i, i+5);
23  
  }
24  
  
25  
  // <int> := value
26  
  while ((i = jfind_check(":", tok, "<int> :=")) >= 0) {
27  
    tok.set(i+2, ",");
28  
    tok.set(i+4, "");
29  
    reTok(tok, i, i+5);
30  
  }
31  
  
32  
  // all other cases: just replace with comma
33  
  jreplace(tok, ":=", ",");
34  
}

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: 242 / 329
Version history: 4 change(s)
Referenced in: [show references]