orangeduck / mpc

A Parser Combinator library for C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

mgood7123 opened this issue · comments

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);
}

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.

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.

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

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

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

ughhhhhh this is imposible ;-;