one important but subtle point to note is that we used the operator rather than the operator in the definition of the node parser element we could just as easily have used +since both (parserelement __add__()and (parserelement __sub__()do the same job--they return parser element that represents the concatenation of the two parser elements that are the operator' operands the reason we chose to use rather than is due to subtle but important difference between them the operator will stop parsing and raise parsesyntaxexception as soon as an error is encounteredsomething that the operator doesn' do if we had used all errors would have line number of and column of but by using -any errors have the correct line and column numbers in generalusing is the right approachbut if our tests show that we are getting incorrect error locationsthen we can start to change + into - as we have done here--and in this case only single change was necessary def add_block(tokens)return block block(tokens nametokens color if tokens color else "white"whenever node_data is parsed instead of the text being returned and added to the parser' results listwe create and return block we also always set the color to white unless color is explicitly specified in the previous examples we parsed file and an open file handle (an opened io textiowrapper)here we will parse string it makes no difference to pyparsing whether we give it string or fileso long as we use parserelement parsefile(or parserelement parsestring(as appropriate in factpyparsing offers other parsing methodsincluding parserelement scanstring(which searches string for matchesand parserelement transformstring(which returns copy of the string it is givenbut with matched texts transformed into new texts by returning new text from parse actions stack [block get_root_block()tryresults nodes parsestring(textparseall=trueassert len(results= items results aslist()[ populate_children(itemsstackexcept (parseexceptionparsesyntaxexceptionas errraise valueerror("error {{ }}syntax errorline "{ }format(err lineno)return stack[ this is the first pyparsing parser where we have used the parser' results rather than created the data structures ourselves during the parsing process we expect the results to be returned as list containing single parseresults