introduction to parsing the untar py example program that comes with this book' examples for instanceassuming the book' examples are located in :\py egthe command to execute in the console is :\python \python exe :\py eg\untar py ply tar gz once the tarball is unpackedchange directory to ply' directory--this directory should contain file called setup py and subdirectory called ply ply can be installed automatically or manually to do it automaticallyin the console execute python setup py installor on windows execute :\python \python exe setup py install alternativelyjust copy or move the ply directory and its contents to python' site-packages directory (or to your local site-packages directoryonce installedply' modules are available as ply lex and ply yacc ply makes clear distinction between lexing (tokenizingand parsing and in factply' lexer is so powerful that it is sufficient on its own to handle all the examples shown in this except for the first-order logic parser for which we use both the ply lex and ply yacc modules when we discussed the pyparsing module we began by first reviewing various pyparsing-specific conceptsand in particular how to convert certain bnf constructs into pyparsing syntax this isn' necessary with ply since it is designed to work directly with regexes and bnfsso rather than give any conceptual overviewwe will summarize few key ply conventions and then dive straight into the examples and explain the details as we go along ply makes extensive use of naming conventions and introspectionso it is important to be aware of these when we create lexers and parsers using ply every ply lexer and parser depends on variable called tokens this variable must hold tuple or list of token names--they are usually uppercase strings corresponding to nonterminals in the bnf every token must have corresponding variable or function whose name is of the form t_token_name if variable is defined it must be set to string containing regex--so normally raw string is used for convenienceif function is defined it must have docstring that contains regexagain usually using raw string in either case the regex specifies pattern that matches the corresponding token one name that is special to ply is t_error()if lexing error occurs and function with this name is definedit will be called if we want the lexer to match token but discard it from the results ( comment in programming language)we can do this in one of two ways if we are using variable then we make its name t_ignore_token_nameif we are using function then we use the normal name t_token_namebut ensure that it returns none the ply parser follows similar convention to the lexer in that for each bnf rule we create function with the prefix p_and whose docstring contains the bnf rule we're matching (only with ::replaced with :whenever