we then restore the parser' state to its start state ready to parse another song' details at the end (not shown)we return the songs list to the caller and thanks to the use of named tupleseach song' attributes can be conveniently accessed by namefor examplesongs[ title keeping track of state using variable as we have done here works well in many simple cases but in general this approach is insufficient for dealing with data or dsls that can contain nested expressions in the next subsection we will see how to maintain state in the face of nesting parsing the blocks domain-specific language |the blocks py program is provided as one of the book' examples it reads one or more blk files that use custom text format--blocks formata made-up language--that are specified on the command lineand for each one creates an svg (scalable vector graphicsfile with the same namebut with its suffix changed to svg while the rendered svg files could not be accused of being prettythey provide good visual representation that makes it easy to see mistakes in the blk filesas well as showing the potentiality that even simple dsl can make possible [[lightbluedirector/[[lightgreensecretary/[minion # [[minion # figure the hierarchy blk file figure shows the complete hierarchy blk fileand figure shows how the hierarchy svg file that the blocks py program produces is rendered the blocks format has essentially two elementsblocks and new row markers blocks are enclosed in brackets blocks may be emptyin which case they are used as spacers occupying one cell of notional grid blocks may also contain text and optionally color new row markers are forward slashes and they indicate where new row should begin in figure two new row markers are used each time and this is what creates the two blank rows that are visible in figure the blocks format also allows blocks to be nested inside one anothersimply by including blocks and new row markers inside block' bracketsafter the block' text pyparsing blocks parser ply blocks parser