private void compile(RegexpNode prog, Regcomp comp) { _ignoreCase = (comp._flags & Regcomp.IGNORE_CASE) != 0; _isGlobal = (comp._flags & Regcomp.GLOBAL) != 0; _isAnchorBegin = (comp._flags & Regcomp.ANCHORED) != 0; _isUtf8 = (comp._flags & Regcomp.UTF8) != 0; if (prog.isAnchorBegin()) { _isAnchorBegin = true; } /* * if (_ignoreCase) * RegOptim.ignoreCase(prog); * * if (! _ignoreCase) * RegOptim.eliminateBacktrack(prog, null); */ _minLength = prog.minLength(); _firstChar = prog.firstChar(); _firstSet = prog.firstSet(new boolean[256]); _prefix = new CharBuffer(prog.prefix()); //this._prog = RegOptim.linkLoops(prog); _nGroup = comp._maxGroup; _nLoop = comp._nLoop; _groupNames = new StringValue[_nGroup + 1]; for (Map.Entry <Integer, StringValue> entry : comp._groupNameMap.entrySet()) { StringValue groupName = entry.getValue(); if (_isUnicode) { } else if (isUTF8()) { groupName.toBinaryValue("UTF-8"); } _groupNames[entry.getKey().intValue()] = groupName; } }
public Regexp(StringValue rawRegexp) { _rawRegexp = rawRegexp; _pattern = rawRegexp; try { init(); Regcomp comp = new Regcomp(_flags); PeekStream peekString = new PeekString(_pattern); _prog = comp.parse(peekString); compile(_prog, comp); } catch (IllegalRegexpException e) { _exception = e; } }