Libraryless. Click here for Pure Java version (2767L/18K).
static CharacterClassIterator characterClassIteratorFromMiniRegexp_v1(S regexp, int i default 0) { int l = l(regexp); if (i >= l) ret new CCI_End; char c = regexp.charAt(i); // backslash (escaped character) if (c == '\\' && i+1 < l) ret CCI_SingleChar(regexp.charAt(i+1), characterClassIteratorFromMiniRegexp_v1(regexp, i+2)); // optional character if (i+1 < l && regexp.charAt(i+1) == '?') { CharacterClassIterator rest = characterClassIteratorFromMiniRegexp_v1(regexp, i+2); // TODO: coalesce choice objects when rest is already a choice? new HashMap<Char, CharacterClassIterator> map; // TODO: optional comparator fOr (char cc : rest.acceptedChars()) map.put(cc, rest); // may override an assignment made above map.put(c, new CCI_SingleChar(c, rest)); ret CCI_Choice(rest.canEndHere(), map); } // normal character ret CCI_SingleChar(regexp.charAt(i), characterClassIteratorFromMiniRegexp_v1(regexp, i+1)); }
Began life as a copy of #1029557
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1029559 |
Snippet name: | characterClassIteratorFromMiniRegexp_v1 - only supports optional characters ("ab?c", dev.) |
Eternal ID of this version: | #1029559/7 |
Text MD5: | 485acf71783a39ce6a13945b51bbb4a1 |
Transpilation MD5: | a0cabbbc47485a40727788a245ed9b24 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-08-23 12:58:48 |
Source code size: | 1016 bytes / 26 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 211 / 306 |
Version history: | 6 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |