#NEWLINE# def add_block( self , name ) : #NEWLINE# #INDENT# ' Adds a new block to the AST.\n\n            `name`\n                Block name.\n\n            * Raises a ``ValueError`` exception if `name` is invalid or\n              an existing block name matches value provided for `name`.\n            ' #NEWLINE# if ( not self . RE_NAME . match ( name ) ) : #NEWLINE# #INDENT# raise ValueError ( "Invalid block name '{0}'" . format ( common . from_utf8 ( name ) ) ) #NEWLINE# #UNINDENT# if ( name in self . _block_map ) : #NEWLINE# #INDENT# raise ValueError ( "Block '{0}' already exists" . format ( common . from_utf8 ( name ) ) ) #NEWLINE# #UNINDENT# self . _block_map [ name ] = len ( self . _ast [ 2 ] ) #NEWLINE# option_list = [ ] #NEWLINE# block = [ name , option_list ] #NEWLINE# self . _ast [ 2 ] . append ( block )