def parse_value(val, parsebool=False):
try:<EOL><INDENT>return int(val)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>return float(val)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>if parsebool:<EOL><INDENT>if re.match('<STR_LIT>', str(val), re.IGNORECASE):<EOL><INDENT>return True<EOL><DEDENT>elif re.match('<STR_LIT>', str(val), re.IGNORECASE):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return val<EOL>
Parse input string and return int, float or str depending on format.

    @param val:       Input string.
    @param parsebool: If True parse yes / no, on / off as boolean.
    @return:          Value of type int, float or str.