def init_parser(self):
        """
        Initializes the parser
        """

        #self.token_list = None
        #self.prev_token_lists = None

        self.valid_children = dict()
        self.valid_children['lems'] = ['component', 'componenttype',
                                       'target', 'include',
                                       'dimension', 'unit', 'assertion']
                                       
        #TODO: make this generic for any domain specific language based on LEMS
        self.valid_children['neuroml'] = ['include', 'componenttype']
                                       
        self.valid_children['componenttype'] = ['dynamics',
                                                'child', 'children',
                                                'componentreference',
                                                'exposure', 'eventport',
                                                'fixed', 'link', 'parameter',
                                                'property',
                                                'indexparameter',
                                                'path', 'requirement',
                                                'componentrequirement',
                                                'instancerequirement',
                                                'simulation', 'structure',
                                                'text', 'attachments',
                                                'constant', 'derivedparameter']
                                                
        self.valid_children['dynamics'] = ['derivedvariable',
                                           'conditionalderivedvariable',
                                           'oncondition',
                                           'onevent', 'onstart',
                                           'statevariable', 'timederivative',
                                           'kineticscheme', 'regime']
                                           
        self.valid_children['component'] = ['component']
                                           
        self.valid_children['conditionalderivedvariable'] = ['case']
        
        self.valid_children['regime'] = ['oncondition', 'onentry', 'timederivative']
        self.valid_children['oncondition'] = ['eventout', 'stateassignment', 'transition']
        self.valid_children['onentry'] = ['eventout', 'stateassignment', 'transition']
        self.valid_children['onevent'] = ['eventout', 'stateassignment', 'transition']
        self.valid_children['onstart'] = ['eventout', 'stateassignment', 'transition']
        self.valid_children['structure'] = ['childinstance',
                                            'eventconnection',
                                            'foreach',
                                            'multiinstantiate',
                                            'with',
                                            'tunnel']
                                       
        self.valid_children['foreach'] = ['foreach', 'eventconnection']     
                                            
        self.valid_children['simulation'] = ['record', 'eventrecord', 'run',
                                             'datadisplay', 'datawriter', 'eventwriter']

        self.tag_parse_table = dict()
        #self.tag_parse_table['assertion'] = self.parse_assertion
        self.tag_parse_table['attachments'] = self.parse_attachments
        self.tag_parse_table['child'] = self.parse_child
        self.tag_parse_table['childinstance'] = self.parse_child_instance
        self.tag_parse_table['children'] = self.parse_children
        self.tag_parse_table['component'] = self.parse_component
        self.tag_parse_table['componentreference'] = self.parse_component_reference   
        self.tag_parse_table['componentrequirement'] = self.parse_component_requirement
        self.tag_parse_table['componenttype'] = self.parse_component_type
        self.tag_parse_table['constant'] = self.parse_constant
        self.tag_parse_table['datadisplay'] = self.parse_data_display
        self.tag_parse_table['datawriter'] = self.parse_data_writer
        self.tag_parse_table['eventwriter'] = self.parse_event_writer
        self.tag_parse_table['derivedparameter'] = self.parse_derived_parameter
        self.tag_parse_table['derivedvariable'] = self.parse_derived_variable
        self.tag_parse_table['conditionalderivedvariable'] = self.parse_conditional_derived_variable
        self.tag_parse_table['case'] = self.parse_case
        self.tag_parse_table['dimension'] = self.parse_dimension
        self.tag_parse_table['dynamics'] = self.parse_dynamics
        self.tag_parse_table['eventconnection'] = self.parse_event_connection
        self.tag_parse_table['eventout'] = self.parse_event_out
        self.tag_parse_table['eventport'] = self.parse_event_port
        self.tag_parse_table['exposure'] = self.parse_exposure
        self.tag_parse_table['fixed'] = self.parse_fixed
        self.tag_parse_table['foreach'] = self.parse_for_each
        self.tag_parse_table['include'] = self.parse_include
        self.tag_parse_table['indexparameter'] = self.parse_index_parameter
        self.tag_parse_table['kineticscheme'] = self.parse_kinetic_scheme
        self.tag_parse_table['link'] = self.parse_link
        self.tag_parse_table['multiinstantiate'] = self.parse_multi_instantiate
        self.tag_parse_table['oncondition'] = self.parse_on_condition
        self.tag_parse_table['onentry'] = self.parse_on_entry
        self.tag_parse_table['onevent'] = self.parse_on_event
        self.tag_parse_table['onstart'] = self.parse_on_start
        self.tag_parse_table['parameter'] = self.parse_parameter
        self.tag_parse_table['property'] = self.parse_property
        self.tag_parse_table['path'] = self.parse_path
        self.tag_parse_table['record'] = self.parse_record
        self.tag_parse_table['eventrecord'] = self.parse_event_record
        self.tag_parse_table['regime'] = self.parse_regime
        self.tag_parse_table['requirement'] = self.parse_requirement
        self.tag_parse_table['instancerequirement'] = self.parse_instance_requirement     
        self.tag_parse_table['run'] = self.parse_run
        #self.tag_parse_table['show'] = self.parse_show
        self.tag_parse_table['simulation'] = self.parse_simulation
        self.tag_parse_table['stateassignment'] = self.parse_state_assignment
        self.tag_parse_table['statevariable'] = self.parse_state_variable
        self.tag_parse_table['structure'] = self.parse_structure
        self.tag_parse_table['target'] = self.parse_target
        self.tag_parse_table['text'] = self.parse_text
        self.tag_parse_table['timederivative'] = self.parse_time_derivative
        self.tag_parse_table['transition'] = self.parse_transition
        self.tag_parse_table['tunnel'] = self.parse_tunnel
        self.tag_parse_table['unit'] = self.parse_unit
        self.tag_parse_table['with'] = self.parse_with

        self.xml_node_stack = []

        self.current_component_type = None
        self.current_dynamics = None
        self.current_regime = None
        self.current_event_handler = None
        self.current_structure = None
        self.current_simulation = None
        self.current_component = None
        
        def counter():
            count = 1
            while True:
                yield count
                count = count + 1

        self.id_counter = counter()
def init_parser ( self ) : self . valid_children = dict ( ) self . valid_children [ 'lems' ] = [ 'component' , 'componenttype' , 'target' , 'include' , 'dimension' , 'unit' , 'assertion' ] self . valid_children [ 'neuroml' ] = [ 'include' , 'componenttype' ] self . valid_children [ 'componenttype' ] = [ 'dynamics' , 'child' , 'children' , 'componentreference' , 'exposure' , 'eventport' , 'fixed' , 'link' , 'parameter' , 'property' , 'indexparameter' , 'path' , 'requirement' , 'componentrequirement' , 'instancerequirement' , 'simulation' , 'structure' , 'text' , 'attachments' , 'constant' , 'derivedparameter' ] self . valid_children [ 'dynamics' ] = [ 'derivedvariable' , 'conditionalderivedvariable' , 'oncondition' , 'onevent' , 'onstart' , 'statevariable' , 'timederivative' , 'kineticscheme' , 'regime' ] self . valid_children [ 'component' ] = [ 'component' ] self . valid_children [ 'conditionalderivedvariable' ] = [ 'case' ] self . valid_children [ 'regime' ] = [ 'oncondition' , 'onentry' , 'timederivative' ] self . valid_children [ 'oncondition' ] = [ 'eventout' , 'stateassignment' , 'transition' ] self . valid_children [ 'onentry' ] = [ 'eventout' , 'stateassignment' , 'transition' ] self . valid_children [ 'onevent' ] = [ 'eventout' , 'stateassignment' , 'transition' ] self . valid_children [ 'onstart' ] = [ 'eventout' , 'stateassignment' , 'transition' ] self . valid_children [ 'structure' ] = [ 'childinstance' , 'eventconnection' , 'foreach' , 'multiinstantiate' , 'with' , 'tunnel' ] self . valid_children [ 'foreach' ] = [ 'foreach' , 'eventconnection' ] self . valid_children [ 'simulation' ] = [ 'record' , 'eventrecord' , 'run' , 'datadisplay' , 'datawriter' , 'eventwriter' ] self . tag_parse_table = dict ( ) self . tag_parse_table [ 'attachments' ] = self . parse_attachments self . tag_parse_table [ 'child' ] = self . parse_child self . tag_parse_table [ 'childinstance' ] = self . parse_child_instance self . tag_parse_table [ 'children' ] = self . parse_children self . tag_parse_table [ 'component' ] = self . parse_component self . tag_parse_table [ 'componentreference' ] = self . parse_component_reference self . tag_parse_table [ 'componentrequirement' ] = self . parse_component_requirement self . tag_parse_table [ 'componenttype' ] = self . parse_component_type self . tag_parse_table [ 'constant' ] = self . parse_constant self . tag_parse_table [ 'datadisplay' ] = self . parse_data_display self . tag_parse_table [ 'datawriter' ] = self . parse_data_writer self . tag_parse_table [ 'eventwriter' ] = self . parse_event_writer self . tag_parse_table [ 'derivedparameter' ] = self . parse_derived_parameter self . tag_parse_table [ 'derivedvariable' ] = self . parse_derived_variable self . tag_parse_table [ 'conditionalderivedvariable' ] = self . parse_conditional_derived_variable self . tag_parse_table [ 'case' ] = self . parse_case self . tag_parse_table [ 'dimension' ] = self . parse_dimension self . tag_parse_table [ 'dynamics' ] = self . parse_dynamics self . tag_parse_table [ 'eventconnection' ] = self . parse_event_connection self . tag_parse_table [ 'eventout' ] = self . parse_event_out self . tag_parse_table [ 'eventport' ] = self . parse_event_port self . tag_parse_table [ 'exposure' ] = self . parse_exposure self . tag_parse_table [ 'fixed' ] = self . parse_fixed self . tag_parse_table [ 'foreach' ] = self . parse_for_each self . tag_parse_table [ 'include' ] = self . parse_include self . tag_parse_table [ 'indexparameter' ] = self . parse_index_parameter self . tag_parse_table [ 'kineticscheme' ] = self . parse_kinetic_scheme self . tag_parse_table [ 'link' ] = self . parse_link self . tag_parse_table [ 'multiinstantiate' ] = self . parse_multi_instantiate self . tag_parse_table [ 'oncondition' ] = self . parse_on_condition self . tag_parse_table [ 'onentry' ] = self . parse_on_entry self . tag_parse_table [ 'onevent' ] = self . parse_on_event self . tag_parse_table [ 'onstart' ] = self . parse_on_start self . tag_parse_table [ 'parameter' ] = self . parse_parameter self . tag_parse_table [ 'property' ] = self . parse_property self . tag_parse_table [ 'path' ] = self . parse_path self . tag_parse_table [ 'record' ] = self . parse_record self . tag_parse_table [ 'eventrecord' ] = self . parse_event_record self . tag_parse_table [ 'regime' ] = self . parse_regime self . tag_parse_table [ 'requirement' ] = self . parse_requirement self . tag_parse_table [ 'instancerequirement' ] = self . parse_instance_requirement self . tag_parse_table [ 'run' ] = self . parse_run self . tag_parse_table [ 'simulation' ] = self . parse_simulation self . tag_parse_table [ 'stateassignment' ] = self . parse_state_assignment self . tag_parse_table [ 'statevariable' ] = self . parse_state_variable self . tag_parse_table [ 'structure' ] = self . parse_structure self . tag_parse_table [ 'target' ] = self . parse_target self . tag_parse_table [ 'text' ] = self . parse_text self . tag_parse_table [ 'timederivative' ] = self . parse_time_derivative self . tag_parse_table [ 'transition' ] = self . parse_transition self . tag_parse_table [ 'tunnel' ] = self . parse_tunnel self . tag_parse_table [ 'unit' ] = self . parse_unit self . tag_parse_table [ 'with' ] = self . parse_with self . xml_node_stack = [ ] self . current_component_type = None self . current_dynamics = None self . current_regime = None self . current_event_handler = None self . current_structure = None self . current_simulation = None self . current_component = None def counter ( ) : count = 1 while True : yield count count = count + 1 self . id_counter = counter ( )
Initializes the parser