rule matches its corresponding function is called with parameter (called pfollowing the ply documentation' examples)this parameter can be indexed with [ corresponding to the nonterminal that the rule definesand [ and so oncorresponding to the parts on the right-hand side of the bnf precedence and associativity can be set by creating variable called precedence and giving it tuple of tuples--in precedence order--that indicate the tokensassociativities similarly to the lexerif there is parsing error and we have created function called p_error()it will be called we will make use of all the conventions described hereand morewhen we review the examples to avoid duplicating information from earlier in the the examples and explanations given here focus purely on parsing with ply it is assumed that you are familiar with the formats to be parsed and their contexts of use this means that either you have read at least this second section and the first-order logic parser from the third section' last subsectionor that you skip back using the backreferences provided when necessary simple key-value data parsing handcrafted keyvalue parser pyparsing keyvalue parser pls bnf |ply' lexer is sufficient to handle the key-value data held in pls files every ply lexer (and parserhas list of tokens which must be stored in the tokens variable ply makes extensive use of introspectionso the names of variables and functionsand even the contents of docstringsmust follow ply' conventions here are the tokens and their regexes and functions for the ply pls parsertokens ("ini_header""comment""key""value"t_ignore_ini_header "\[[^]]+\]t_ignore_comment "\*def t_key( ) "\ +if lowercase_keyst value value lower(return def t_value( ) "* value value[ :strip(return