introduction to parsing parse action is so simple that we have used lambda the combine(ensures that there is always precisely one token in the tokens tupleand we use int(to convert this to an integer if parse action returns valuethat value becomes the value associated with the token rather than the text that was matched we have also given name to the token for convenience of access later on the info parse action consists of the literal string that indicates an entryfollowed by the secondsfollowed by commafollowed by the title--and all this is defined very simply and naturally in way that matches the bnf notice also that we use suppress(for the literal string and for the comma since although both are essential for the grammarthey are of no interest to us in terms of the data itself the entry parser element is very easy to definesimply an info followed by newlinethen filename followed by newline--the lineend(is predefined pyparsing parser element to match newline and since we are populating our list of songs as we parse rather than at the endwe give the entry parser element parse action that will be called whenever an entry is matched the parser itself is parser element that matches the literal string that indicates filefollowed by one or more entrys def add_song(tokens)songs append(song(tokens titletokens secondstokens filename)mapping unpacking the add_song(function is simpleespecially since we named the parser elements we are interested in and are therefore able to access them as attributes of the tokens object and of coursewe could have written the function even more compactly by converting the tokens to dictionary and using mapping unpacking--for examplesongs append(song(**tokens asdict())tryparser parsefile(fhexcept parseexception as errprint("parse error{ }format(err)return [return songs the code for calling parserelement parsefile(is almost identical to the code we used for the pls parseralthough in this case instead of passing filename we opened file in text mode and passed in the io textiowrapper returned by the built-in open(function as the fh ("file handle"variable we have now finished reviewing two simple pyparsing parsersand seen many of the most commonly used parts of the pyparsing api in the following two subsections we will look at more complex parsersboth of which are recursivethat isthey have nonterminals whose definition includes themselvesand in