weggli icon indicating copy to clipboard operation
weggli copied to clipboard

Using regular expressions to match boolean operators.

Open mvanotti opened this issue 4 years ago • 1 comments

I am having some trouble getting my query to work the way I intend to.

I want to match:

if (_ X _($atomic.fetch_sub())) {
}

where X is either && or ||, however, I cannot get the query right.

-l -R 'op=$\|\|^' -X '{
if (_ $op; _($atomic.fetch_sub())) { _; }
}'

Doesn't return anything, and

weggli/target/release/weggli -l -R 'op=$\|\|^' -X '{
if (_ $op _($atomic.fetch_sub())) { _; }
}'

Fails with:

Error! Query parsing failed: {
if (_ $op [MISSING ; ]  _($atomic.fetch_sub())) { _; }
}

I don't know if this is a bug or if I am not writing the query correctly.

mvanotti avatar Oct 01 '21 18:10 mvanotti

Using variables in place of operators is not supported (and it would be pretty hard to implement as it requires significant changes to the used C and C++ grammars).

I have to think about the best way to implement something like this. For now you need to write and run two queries unfortunately.

felixwilhelm avatar Oct 04 '21 15:10 felixwilhelm