Transpiled version (3604L) is out of date.
please include function testBracketHygiene. static Pair<Int, S> testBracketHygiene2(S s) { ret testBracketHygiene2(s, testBracketHygiene_op, testBracketHygiene_close); } static Pair<Int, S> testBracketHygiene2(S s, S op, S close) { LS tok = javaTok(s); new Map<Int> map; L<int> stack = getBracketMap2(tok, map, op, close); for (int i = 1; i < l(tok); i += 2) if (isUnproperlyQuoted(tok.get(i))) { int lineNr = tokenIndexToUserLandLineNr(tok, i); ret pair(tokenToCharIndex(tok, i), "Unclosed string literal at line " + lineNr); } for (int i : keys(map)) { int j = map.get(i); S a = tok.get(i), b = tok.get(j); int ai = op.indexOf(a), bi = close.indexOf(b); if (ai != bi) { int lineNr1 = tokenIndexToUserLandLineNr(tok, i); int lineNr2 = tokenIndexToUserLandLineNr(tok, j); S msg; if (empty(a)) msg = "superfluous closing bracket (" + quote(b) + ") at line " + lineNr2; else msg = "brackets don't match (" + quote(a) + " vs " + quote(b) + ") at lines " + lineNr1 + " and " + lineNr2; ret pair(tokenToCharIndex(tok, /*tossCoin() ?*/ i /*: j*/), "Bad hygiene - " + msg); } } if (nempty(stack)) { int lineNr = tokenIndexToUserLandLineNr(tok, last(stack)); ret pair(tokenIndexToCharIndex(tok, last(stack)), "Line " + lineNr + ": " + "Bad hygiene - " + n(l(stack), "bracket") + " not closed"); } if (map.containsKey(0)) { int lineNr = tokenIndexToUserLandLineNr(tok, map.get(0)); ret pair(tokenToCharIndex(tok, map.get(0)), "Bad hygiene - bracket not opened (" + quote(tok.get(map.get(0))) + ") at line " + lineNr); } null; }
Began life as a copy of #1003922
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1009426 | 
| Snippet name: | testBracketHygiene2 - shows where the bad bracket is | 
| Eternal ID of this version: | #1009426/19 | 
| Text MD5: | e366eba96ef58efaa1e01f2add558498 | 
| Author: | stefan | 
| Category: | javax | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2021-08-31 18:12:24 | 
| Source code size: | 1734 bytes / 48 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 651 / 842 | 
| Version history: | 18 change(s) | 
| Referenced in: | [show references] |