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

26
LINES

< > BotCompany Repo | #1031769 // tok_numberFunctionNames (e.g. "1to" => "oneTo", LIVE)

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

Transpiled version (4158L) is out of date.

1  
svoid tok_numberFunctionNames(LS tok) {
2  
  int n = l(tok);
3  
  new L<IntRange> reToks;
4  
  for (int i = 1; i < n-2; i += 2) {
5  
    S number, id;
6  
    if (isInteger(number = tok.get(i))
7  
      && empty(tok.get(i+1))
8  
      && isIdentifier(id = tok.get(i+2))) pcall {
9  
    
10  
      continue if eq(number, "0") && swicOneOf(id, "x", "b"); // skip hex/binary constants
11  
      continue if eqic(id, "f"); // skip float constants
12  
      
13  
      // skip exponential floating-point constants (e.g. 1e6)
14  
      if (swic(id, "e") && (l(id) == 1 && empty(get(tok, i+3)) && eqGet(tok, i+4, "-")
15  
        || startsWithInteger(substring(id, 1))))
16  
        continue;
17  
18  
      // skip numbers with underscores like 1_000
19  
      if (startsWith(id, "_"))
20  
        continue;
21  
        
22  
      replaceTokens_reTokLater(tok, reToks, i, i+3, camelCase(numberToEnglish(parseLong(number))) + firstToUpper(id));
23  
    }
24  
  }
25  
  reTok_multi(tok, reToks);
26  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031769
Snippet name: tok_numberFunctionNames (e.g. "1to" => "oneTo", LIVE)
Eternal ID of this version: #1031769/21
Text MD5: 75d6c6e723df077996660e09da61cccd
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-21 18:31:24
Source code size: 925 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 127 / 243
Version history: 20 change(s)
Referenced in: [show references]