Transpiled version (2957L) is out of date.
scope tok_hashLocalIdentifiers // process #abc local identifier declaration // => scope + "abc" static LS tok_hashLocalIdentifiers(LS tok, S scope) { ret Obj(tok, scope)!; } srecord #Obj(LS tok, S scope) { bool verbose; selfType verbose(bool verbose) { this.verbose = verbose; this; } LS get() { tok = cloneList(tok); scope = unnull(scope); if (endsWithLetterOrDigit(scope)) scope += "_"; new HashSet<S> names; // first pass (find # declarations) for (int k = 1; k < l(tok); k += 2) { S t = _get(tok, k+2); if (eqGet(tok, k, "#") && isIdentifier(t)) { if (verbose) print("Local name found: " + t); names.add(t); replaceTokens(tok, k, k+3, scope + t); } } // early exit if nothing to do if (empty(names)) ret tok; // second pass (references to scoped variables) for (int k = 1; k < l(tok); k += 2) { S t = _get(tok, k); if (isIdentifier(t) && names.contains(t)) tok.set(k, scope + t); } ret tok; } } end scope
Began life as a copy of #1015648
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031426 |
Snippet name: | tok_hashLocalIdentifiers |
Eternal ID of this version: | #1031426/9 |
Text MD5: | 4ef05b6126c89f378acdc29e5ef8a05b |
Author: | stefan |
Category: | javax / transpiling |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-12 07:52:55 |
Source code size: | 1112 bytes / 44 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 253 / 431 |
Version history: | 8 change(s) |
Referenced in: | [show references] |