sbool checkNTokenHygiene(L<S> tok) { ret l(tok) == 1 || checkNTokenHygiene_forward(tok) && checkNTokenHygiene_backward(tok); } sbool checkNTokenHygiene_forward(L<S> tok) { int level = 0; for (int i = 0; i < l(tok)-1; i += 2) { S t = tok.get(i); for (char c : characters(t)) if (c == '{') ++level; else if (c == '}') level = max(0, level-1); } if (level == 0) true; for (char c : characters(last(tok))) if (c == '}') if (--level == 0) true; false; } sbool checkNTokenHygiene_backward(L<S> tok) { int level = 0; for (int i = l(tok)-1; i > 0; i -= 2) { S t = tok.get(i); for (char c : reversedCharacters(t)) if (c == '}') ++level; else if (c == '{') level = max(0, level-1); } if (level == 0) true; for (char c : reversedCharacters(first(tok))) if (c == '{') if (--level == 0) true; false; }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017481 |
Snippet name: | checkNTokenHygiene - probably broken |
Eternal ID of this version: | #1017481/5 |
Text MD5: | f53848e7b04af6e6007a554949b22319 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-09-30 19:31:13 |
Source code size: | 894 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 378 / 384 |
Version history: | 4 change(s) |
Referenced in: | [show references] |