<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_cnf(s, varname='x'):
 """ Parse an input string in DIMACS CNF format, and return an expression abstract syntax tree. Parameters s : str String containing a DIMACS CNF. varname : str, optional The variable name used for creating literals. Defaults to 'x'. Returns ------- An ast tuple, defined recursively: ast := ('var', names, indices) | ('not', ast) """

    lexer = iter(CNFLexer(s))
    try:
        ast = _cnf(lexer, varname)
    except lex.RunError as exc:
        fstr = ("{0.args[0]}: "
                "(line: {0.lineno}, offset: {0.offset}, text: {0.text})")
        raise Error(fstr.format(exc))

    # Check for end of buffer
    _expect_token(lexer, {EndToken})

    return ast