introduction to parsing expression would fail (assuming that didn' exist beforesince it would start by trying to assign the value of nonexistent variable to precedence and associativity can sometimes work together for exampleif two different operators have the same precedence (this is commonly the case with and -)without the use of parenthesestheir associativities are all that can be used to determine the evaluation order expressing precedence and associativity in bnf can be done by composing factors into terms and terms into expressions for examplethe bnf in figure defines the four basic arithmetic operations over integersas well as parenthesized subexpressionsand all with the correct precedences and (left to rightassociativities integer ::\dadd_operator ::'+'-scale_operator ::'*'/expression ::term (add_operator term)term ::factor (scale_operator factor)factor ::'-'(integer '(expression ')'figure bnf for arithmetic operations the precedence relationships are set up by the way we combine expressionstermsand factorswhile the associativities are set up by the structure of each of the expressiontermand factor' nonterminalsdefinitions if we need right to left associativitywe can use the following structurepower_expression ::factor ('**power_expression)the recursive use of power_expression forces the parser to work right to left dealing with precedence and associativity can be avoided altogetherwe can simply insist that the data or dsl uses parentheses to make all the relationships explicit although this is easy to doit isn' doing any favors for the users of our data format or of our dslso we prefer to incorporate precedence and associativity where they are appropriate there is lot more to parsing than we have mentioned here--seefor examplethe book parsing techniquesa practical guidementioned in the bibliography nonethelessthis should be sufficient to get startedalthough additional reading is recommended for those planning to create complex and sophisticated parsers another way to avoid precedence and associativity--and which doesn' require parentheses--is to use polish or reverse polish notationsee wikipedia org/wiki/polish_notation bnf