orangeduck / mpc

A Parser Combinator library for C
Other
2.67k stars 292 forks source link

mpc_re does not support lookahead (?!...) #89

Closed mgood7123 closed 5 years ago

mgood7123 commented 5 years ago
mpc_parser_t * re = mpc_new("re");
mpc_define(re, mpc_re("(?!l)."));
mpc_result_t r;
if (mpc_parse("test", "k", re, &r)) {
    puts("passed");
} else {
    puts("failed");
    mpc_err_print(r.error);
    mpc_err_delete(r.error);
}
orangeduck commented 5 years ago

What is the expected behavior here? I don't even think your regex has valid syntax because the ? character is a special character...

Next time you open an issue you should add a description of exactly what the issue is - what you expected, what you got, and what you think the bug is.

orangeduck commented 5 years ago

Okay so you want to use a regex lookahead feature. No mpc doesn't support this and probably wont because it is too complicated to support and mpc doesn't have a complete regex engine.

mgood7123 commented 5 years ago

in mpc_re_mode how are the parens processed, as

  mpc_define(Base, mpc_or(4,
    mpc_parens(Regex, (mpc_dtor_t)mpc_delete),
    mpc_squares(Range, (mpc_dtor_t)mpc_delete),
    mpc_apply_to(mpc_escape(), mpcf_re_escape, &mode),
    mpc_apply_to(mpc_noneof(")|"), mpcf_re_escape, &mode)
  ));

is confusing

mgood7123 commented 5 years ago

nvm, it applies the parser Regex to whatever is inbetween the result of parens

mgood7123 commented 5 years ago

i cant figure out how to obtain the text captured by the parser Regex

mgood7123 commented 5 years ago

ughhhhhh this is imposible ;-;