Grammar for parsing simple mathematical expression mexp ::= (&lt; mexp >) | &lt; mexp >&lt; mathlowop >&lt; mexp > | &lt; mulexp > | &lt; float > | &lt; var >

mulexp ::= &lt; mexp >&lt; mathhighop >&lt; mexp >

mathlowop ::= + | -

mathhighop ::= / | *

That's the BNF I've come up with for parsing simple mathematical expressions where the operands can only be floats or variables. I've looked at a number of resources in books and on the web and for the same type of problem, they usually have a slightly longer, more complex bnf. Is my BNF incorrect in some way? Or is it correct but there is a significant advantage in doing it another way?
Your grammar will generate mathematical expressions, but you haven't captured the notion of operator precedence. For instance, there are two different ways your grammar can generate the expression $a+a*a$, one having the interpretation we'd write as $a+[a*a]$ and the other having $[a+a]*a$. Using the jargon, we'd say your grammar is ambiguous.

A grammar that avoids this problem is

&lt; expression > ::= &lt; term > + &lt; expression > | &lt; term > - &lt; expression > | &lt; term >

&lt; term > ::= &lt; factor > * &lt; term > | &lt; factor > / &lt; term > | &lt; factor >

&lt; factor > ::= (&lt; expression >) | &lt; float > | &lt; var >

See if you can generate $a+a*a$ in two different ways using your grammar and then try the same thing with this grammar. That should give you an idea of what's going on here.