Respuesta :

The BNF description, or BNF Grammar, of the precedence and associativity rules are

[tex]<identifier>\text{ }::=a|b|c|d|e[/tex]

[tex]<operand>\text{ }::=\text{ }NUMBER\text{ }|\text{ }<Identifier>[/tex]

[tex]<factor>\text{ }::=\text{ }<operand>|\text{ }-<operand>|\text{ }(<expression>)[/tex]

[tex]<power>\text{ }:=\text{ }<factor>\text{ }|\text{ }<factor>\text{**} <power>[/tex]

[tex]<term>\text{ }::=\text{ }<power>\text{ }\\|\text{ }<term>*<power>\text{ }\\|\text{ }<term>/<power>\\\\<expression>\text{ }::=\text{ }<term>\text{ }\\|\text{ }<expression>+<term>\text{ }\\|\text{ }<expression>-<term>[/tex]

BNF, or Backus-Naur Form, is a notation for expressing the syntax of languages. It is made up of a set of derivation rules. For each rule, the Left-Hand-Side specifies a nonterminal symbol, while the Right-Hand-side consists of a sequence of either terminal, or nonterminal symbols.

To define precedence in BNF, note that the rules have to be defined so that:

  • A negation or bracket matches first, as seen in the nonterminal rule for factor
  • A power matches next, as seen in the rule defining a factor
  • A multiplication, or division expression matches next, as seen in the rule defining a term
  • Finally, addition, or subtraction match, as seen in the rule defining an expression.

To make sure that the expression is properly grouped, or associativity is taken into account,

  • Since powers associate to the right (that is, [tex]x \text{**} y\text{**}z=x \text{**} (y\text{**}z)\text{ and not }(x \text{**} y)\text{**}z[/tex]), the rule defining power does this

        [tex]<power>\text{ }:=\text{ }<factor>\text{ }|\text{ }<factor>\text{**} <power>[/tex]

        and not

        [tex]<power>\text{ }:=\text{ }<factor>\text{ }|\text{ }<power>\text{**}<factor>[/tex]

  • Since multiplication/division are left associative (that is, [tex]x \text{*} y\text{*}z=(x \text{*} y)\text{*}z[/tex]), the rule defining a term takes this into account by specifying its recursion on the right of the operators like so;  

        [tex]<term>\text{ }::=\text{ }<power>\text{ }\\|\text{ }<term>*<power>\text{ }\\|\text{ }<term>/<power>[/tex]

  • Also, addition and subtraction are left associative (that is, [tex]x \text{+} y\text{+}z=(x \text{+} y)\text{+}z[/tex]), the rule defining an expression takes this into account as seen below

        [tex]<expression>\text{ }::=\text{ }<term>\text{ }\\|\text{ }<expression>+<term>\text{ }\\|\text{ }<expression>-<term>[/tex]

Learn more about BNF grammars here: https://brainly.com/question/13668912