-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implementing regex lookahead #95
Comments
I think it is going to be too difficult to add lookahead because I make lots of assumptions when parsing the regex that there will be no lookahead (for example I disable backtracking). If I was you, for this I would just go with a standard regex library such as pcre (https://www.pcre.org/). |
True but isnt that unportable? mpc is meant to be fully portable right? |
Depends what platforms you are interested in. I imagine it will work okay on most platforms but you'd just have to test. |
Hyperscan and Re/flex (C++) are much faster than pcre1/2 without rarely-used features. pcre2-jit is quite fast. |
to implement regex lookahead i need to
obtain the text captured in
mpc_parens
andRegex
look for the following at the start of the text:
?!
(negate assertion, eg [^a])?:
(assertion, eg [a])save a copy of the current active
mpc_input_t
structure ( can be done via) as using
mpc_input_rewind
will segmentation fault or probably fail in the case of a multi-step parser due to one needing to executempc_input_rewind
for each parser succession where the input is modified4. if it is a lookahead shift the string by 2 otherwise leave as is
5. execute it as
mpc_re_mode
with the parser asRegex
and mode asmode
, retaining the original mode and regex parser, in order to work recursively6. if lookahead, restore the current active
mpc_input_t
structure with the one that was saved in step 37. fail or succeed depending on the lookahead mode (
?!
or?:
)the problem i am having is trying to obtain the text captured from the
Regex
parser needed in order to look for?!
or?:
at the start of the text inside the parenthesisfor example, given
(?:abc(?!e)d)
The text was updated successfully, but these errors were encountered: