Libraryless. Click here for Pure Java version (3561L/21K).
svoid tok_questionDot(LS tok) { jreplace(tok, "if (<id> ?. <id)", "if ($3 != null && $3.$6)"); jreplace_dyn(tok, "<id> ?.", func(L<S> tok, int i) -> S { S var = tok.get(i); bool isExpression = eqGetOneOf(tok, i-2, "ret", "return", ",", "=", "(", "?"); // too few if (!isExpression) ret "if (\*var*/ != null) \*var*/."; // TODO: brackets ret "\*var*/ == null ? null : \*var*/."; }); }
download show line numbers debug dex
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1024937 |
Snippet name: | tok_questionDot |
Eternal ID of this version: | #1024937/8 |
Text MD5: | d1142026ab119b1171d6a3ce238b851c |
Transpilation MD5: | 98fa272fbc8e8d5f1c4dfffd76b4ee0c |
Author: | stefan |
Category: | javax / transpiling |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-01-18 00:46:19 |
Source code size: | 439 bytes / 12 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 103 / 177 |
Version history: | 7 change(s) |
Referenced in: | [show references] |
Formerly at http://tinybrain.de/1024937 & http://1024937.tinybrain.de