This content has been marked as final. Show 3 replies
Easiest way is to fix your grammar:
This is also more correct as it allows multiple not's.
searchTerm ::= ( (stringLiteral)+ | phrase) | not searchTerm
Don't try to 'optimize' your grammar. Keep it clean.
Thank you very much, I totally didn't think of that but you're absolutely right, it makes the grammar much cleaner. I got it working the way it's supposed to, thanks again.
You've made a similar mistake with 'and' and 'or', so you don't have any operator precedence between them. It should go something like this:
expression: term | expression or term term: factor | term and factor factor : primary | not factor primary: whatever | ( expression )