data stack append(blockparse(datadata stack pop(this function begins by advancing by one character (to skip the start-of-block open bracketit then looks for the next start of block and the next end of block if there is no following block or if the next end of block is before the start of another block then this block does not have any nested blocksso we can simply call parse_block_data(and give it an end position of the end of this block if this block does have one or more nested blocks inside it we parse this block' data up to where its first nested block begins we then push this block onto the stack of blocks and recursively call the parse(function to parse the nested block (or blocks--and their nested blocksetc and at the end we pop this block off the stack since all the nesting has been handled by the recursive calls def parse_block_data(dataend)color none colon data text find(":"data posif - colon endcolor data text[data pos:colondata advance_to_position(colon name data text[data pos:endstrip(data advance_to_position(endif not name and color is noneblock block get_empty_block(elseblock block block(namecolordata stack[- children append(blockreturn block this function is used to parse one block' data--up to the given end point in the text--and to add corresponding block object to the stack of blocks we start by trying to find colorand if we find onewe advance over it next we try to find the block' text (its name)although this can legitimately be empty if we have block with no name or color we create an empty blockotherwise we create block with the given name and color once the block has been created we add it as the last child of the stack of block' top block (initially the top block is the root blockbut if we have nested blocks it could be some other block that has been pushed on top at the end we return the block so that it can be pushed onto the stack of blocks--something we do only if the block has other blocks nested inside it def parse_new_row(data)data stack[- children append(block get_new_row()data advance_by(