// properly post-parse angle bracket things like "<quoted>" // now also allows a space, like "<exp e1>" or "<exp 1>" static L<S> mergeBracketThingies(L<S> tok) { tok = cloneList(tok); for (int i = 1; i+4 < l(tok); i += 2) { // short case if (eq(get(tok, i), "<") && eq(get(tok, i+1), "") && isIdentifier(get(tok, i+2)) && eq(get(tok, i+3), "") && eq(get(tok, i+4), ">")) { tok.set(i, "<" + tok.get(i+2) + ">"); tok.remove(i+4); tok.remove(i+3); tok.remove(i+2); tok.remove(i+1); } // longer case if (eq(get(tok, i), "<") && eq(get(tok, i+1), "") && isIdentifier(get(tok, i+2)) && (isIdentifier(get(tok, i+4)) || isInteger(get(tok, i+4))) && eq(get(tok, i+5), "") && eq(get(tok, i+6), ">")) { tok.set(i, "<" + tok.get(i+2) + " " + tok.get(i+4) + ">"); tok.remove(i+6); tok.remove(i+5); tok.remove(i+4); tok.remove(i+3); tok.remove(i+2); tok.remove(i+1); } } ret tok; }
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: | #1002292 |
Snippet name: | mergeBracketThingies |
Eternal ID of this version: | #1002292/1 |
Text MD5: | e2d1e1bfa388180b16ce51786f905efd |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-01-28 21:50:09 |
Source code size: | 1041 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 780 / 1160 |
Referenced in: | #1002427 - Accellerating 629 (SPIKE) #1006654 - Standard functions list 2 (LIVE, continuation of #761) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |