I'm trying to add 2 things to my grammar:
Unary minus sign, i.e. '-', and
Parentheses
Here's my grammar so far:
<comp> ::= <expr> | <comp> <op0> <expr>
<expr> ::= <term> | <expr> <op1> <term>
<term> ::= <darg> | <term> <op2> <darg>
<darg> ::= <digit> | <darg> <digit>
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<op0> ::= > | < | =< | => | =
<op1> ::= + | -
<op2> ::= * | /
I've tried everything and can't figure this out. How can I make the unary minus sign be at the highest level of precedence, followed by parentheses next and then the remaining operators as they are described?