def parse(self, dictionary=None, end_token=None):
self.level += <NUM_LIT:1><EOL>name = []<EOL>if dictionary is None:<EOL><INDENT>dictionary = self.config<EOL><DEDENT>while True:<EOL><INDENT>token = self.next()<EOL>if token is None:<EOL><INDENT>break<EOL><DEDENT>t_type = token["<STR_LIT:type>"]<EOL>t_value = token["<STR_LIT:value>"]<EOL>if t_type == "<STR_LIT>":<EOL><INDENT>continue<EOL><DEDENT>elif t_value == end_token:<EOL><INDENT>self.level -= <NUM_LIT:1><EOL>return<EOL><DEDENT>elif t_type == "<STR_LIT>":<EOL><INDENT>value = self.remove_quotes(t_value)<EOL>if not name and not re.match("<STR_LIT>", value):<EOL><INDENT>self.error("<STR_LIT>")<EOL><DEDENT>name.append(value)<EOL><DEDENT>elif t_type == "<STR_LIT>":<EOL><INDENT>self.error("<STR_LIT>")<EOL><DEDENT>elif t_type == "<STR_LIT>":<EOL><INDENT>name = "<STR_LIT:U+0020>".join(name)<EOL>if not name:<EOL><INDENT>self.error("<STR_LIT>")<EOL><DEDENT>elif t_value == "<STR_LIT>" and name not in dictionary:<EOL><INDENT>if name.split("<STR_LIT::>")[<NUM_LIT:0>] not in dictionary:<EOL><INDENT>if not (self.level == <NUM_LIT:1> and name == "<STR_LIT>"):<EOL><INDENT>self.error("<STR_LIT>".format(name))<EOL><DEDENT><DEDENT><DEDENT>if t_value in ["<STR_LIT:{>"]:<EOL><INDENT>if self.current_module:<EOL><INDENT>self.check_child_friendly(self.current_module[-<NUM_LIT:1>])<EOL><DEDENT>self.check_module_name(name)<EOL>self.current_module.append(name)<EOL><DEDENT>value = self.assignment(token)<EOL>if self.level == <NUM_LIT:1> and name == "<STR_LIT>":<EOL><INDENT>if not value:<EOL><INDENT>self.error("<STR_LIT>")<EOL><DEDENT>self.check_module_name(value, offset=<NUM_LIT:1>)<EOL>dictionary.setdefault(name, []).append(value)<EOL><DEDENT>elif t_value == "<STR_LIT:{>":<EOL><INDENT>if (<EOL>self.level > <NUM_LIT:1><EOL>and "<STR_LIT:U+0020>" not in name<EOL>and name not in I3S_MODULE_NAMES<EOL>):<EOL><INDENT>name = "<STR_LIT>".format(name, self.anon_count)<EOL>self.anon_count += <NUM_LIT:1><EOL><DEDENT>dictionary[name] = value<EOL><DEDENT>elif t_value == "<STR_LIT:=>":<EOL><INDENT>try:<EOL><INDENT>name, value = self.process_value(<EOL>name, value, self.current_module[-<NUM_LIT:1>]<EOL>)<EOL><DEDENT>except IndexError:<EOL><INDENT>self.error("<STR_LIT>", previous=True)<EOL><DEDENT>dictionary[name] = value<EOL><DEDENT>elif t_value == "<STR_LIT>":<EOL><INDENT>dictionary[name] += value<EOL><DEDENT>else:<EOL><INDENT>self.error("<STR_LIT>")<EOL><DEDENT>name = []<EOL><DEDENT><DEDENT>
Parse through the tokens. Finding names and values.
This is called at the start of parsing the config but is
also called to parse module definitions.