def _parse_string(self, s):
scanner = re.compile(r'''<STR_LIT>''', re.DOTALL | re.VERBOSE)<EOL>variables = defaultdict(int)<EOL>offset = <NUM_LIT:0><EOL>state = <NUM_LIT:0><EOL>state_number = <NUM_LIT:1><EOL>for match in re.finditer(scanner, s):<EOL><INDENT>whitespace, variable, number, sign, end, error = match.groups()<EOL>if error is not None:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'.format(<EOL>match.group(<NUM_LIT:0>)))<EOL><DEDENT>elif whitespace is not None:<EOL><INDENT>continue<EOL><DEDENT>elif variable is not None and state in (<NUM_LIT:0>, <NUM_LIT:2>, <NUM_LIT:3>):<EOL><INDENT>variables[Variable(variable)] += state_number<EOL>state = <NUM_LIT:1><EOL><DEDENT>elif sign is not None and state in (<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:3>):<EOL><INDENT>if state == <NUM_LIT:3>:<EOL><INDENT>offset += state_number<EOL><DEDENT>state_number = <NUM_LIT:1> if sign == '<STR_LIT:+>' else -<NUM_LIT:1><EOL>state = <NUM_LIT:2><EOL><DEDENT>elif number is not None and state in (<NUM_LIT:0>, <NUM_LIT:2>):<EOL><INDENT>state_number = state_number * int(number)<EOL>state = <NUM_LIT:3><EOL><DEDENT>elif end is not None and state in (<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:3>):<EOL><INDENT>if state == <NUM_LIT:3>:<EOL><INDENT>offset += state_number<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'.format(<EOL>match.group(<NUM_LIT:0>)))<EOL><DEDENT><DEDENT>variables = {var: value for var, value in iteritems(variables)<EOL>if value != <NUM_LIT:0>}<EOL>return variables, offset<EOL>
Parse expression string

        Variables must be valid variable symbols and
        coefficients must be integers.