I'm studying programming language design, and I've been taught the grammar below which lets you write basic math expressions.
Exp ::= Num | Exp Op Exp Op ::= + | - | * | Div Num ::= Digit | Digit Num Digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
According to the lecturer things like 1 - (2 -3) are not valid as it can't generate expressions with brackets and it can't do -1 because it can't start with -1.
While I understand the first one, the second is a little harder to understand.
Also could you show me how I could modify the above grammar to add the ability to group operations, and start with a -1?
Finally, I'm told that a grammar is a set of symbols, rules, and an initial symbol? But I'm struggling to find more info on what an initial symbol is/should be.