We declare plus to be left
associative and we declare times to be left associative and then the precedence
between plus and times is given by the order. So the fact here that times appears
after. Plus means that times has a higher precedence than plus. Just one word of
caution, These declarations are called associativity and precedence declarations
but that's not what's quite what's going on inside the parser. The parser doesn't
really understand about associativity and precedence. Instead, these declarations
tell it to make certain kinds of moves in certain situations.
We won't really be
able to explain this until we get much further into parsing technology, but just
be aware that we have to be a little bit cautious in using these declarations.
Usually they behave like associativity and precedence in the way you expect but there
are some situations in which they will cause Rising behavior And is important
that you check the behavior of your grammar after you add these declarations.
我们想要第二个,办法是调整 CFG
但是并没有自动化的方法可以调整 CFG ,必须手动调整(相当于人主观指定规则)