now that we have seen couple of blocks fileswe will look at the blocks bnf to more formally understand what constitutes valid blocks file and as preparation for parsing this recursive format the bnf is shown in figure blocks ::nodesnodes ::new_row\snodenode ::'[\ (color ':')\sname\snodes\ ']color ::'#[\da-fa- ]{ [ -za- ]\wname ::[^][/]new_row ::'/figure bnf for the blk format the bnf defines blocks file as having one or more nodes nodes consists of zero or more new_rows followed by one or more nodes node is left bracket followed by an optional color followed by an optional name followed by zero or more nodes followed by right square bracket the color is simply hash (poundsymbol followed by six hexadecimal digits and colonor sequence of one or more alphanumeric characters that begins with an alphabetic characterand followed by colon the name is sequence of any characters but excluding brackets or forward slashes new_row is literal forward slash as the many occurrences of \ssuggestwhitespace is allowed anywhere between terminals and nonterminals and is of no significance the definition of the node nonterminal is recursive because it contains the nodes nonterminal which itself is defined in terms of the node nonterminal recursive definitions like this are easy to get wrong and can lead to parsers that loop endlesslyso it might be worthwhile doing some paper-based testing to make sure the grammar does terminatethat isthat given valid input the grammar will reach all terminals rather than endlessly looping from one nonterminal to another previouslyonce we had bnfwe have dived straight into creating parser and doing the processing as we parse this isn' practical for recursive grammars because of the potential for elements to be nested what we will need to do is to create class to represent each block (or new rowand that can hold list of nested child blockswhich themselves might contain childrenand so on we can then retrieve the parser' results as list (which will contain lists within lists as necessary to represent nested blocks)and we can convert this list into tree with an "emptyroot block and all the other blocks as its children in the case of the hierarchy blk examplethe root block has list of new rows and of child blocks (including empty blocks)none of which have any children this is illustrated in figure --the hierarchy blk file was shown earlier ( the messagebox blk example has root block that has one child block (the "messagebox window")which itself has one child block (the "frame")