here we have moved the newline to the end of the attribute nonterminalthus simplifying the definition of attribute_file we have also reused the name nonterminal in the value--although this is dubious change since it is mere coincidence that they can both match the same regex this version of the bnf should match exactly the same text as the first one once we have bnf we can "testit mentally or on paper for examplegiven the text "depth \ "we can work through the bnf to see if the text matchesstarting with the first nonterminalattribute_file this nonterminal begins by matching another nonterminalattribute and the attribute nonterminal begins by matching yet another nonterminalnamewhich in turn must match the terminal regex[ -za- ]\wthe regex does indeed match the beginning of the textmatching "depththe next thing that attribute must match is terminalthe literal and here the match fails because "depthis followed by space at this point the parser should report that the given text does not match the grammar in this particular case we must either fix the data by eliminating the space before and after the =or opt to change the grammar--for examplechanging the (firstdefinition of attribute to name \ \svalue after doing few paper tests and refining the grammar like this we should have much clearer idea of what our bnf will and won' match bnf must be complete to be validbut valid bnf is not necessarily correct one one problem is with ambiguity--in the example shown here the literal value true matches the value nonterminal' first alternative ('true')and also its last alternative ([ -za- ]\ *this doesn' stop the bnf from being validbut it is something that parser implementing the bnf must account for and as we will see later in this bnfs can become quite tricky since sometimes we define things in terms of themselves this can be another source of ambiguity--and can result in unparseable grammars precedence and associativity are used to decide the order in which operators should be applied in expressions that don' have parentheses precedence is used when there are different operatorsand associativity is used when the operators are the same for an example of precedencethe python expression evaluates to this means that has higher precedence in python than because the expression behaved as if it were written ( another way of saying this is "in pythonbinds more tightly than +for an example of associativitythe expression evaluates to this means that is left-associativethat iswhen an expression contains two or more / they will be evaluated from left to right here was evaluated first to produce and then to produce by contrastthe operator is right-associativewhich is why we can write when there are two or more = they are evaluated from right to leftso is evaluated firstgiving valueand then giving value if was not right-associative the