def do_lex(filename, unused_args): """Dump the lexer output for a Beancount syntax file. Args: filename: A string, the Beancount input filename. """ for token, lineno, text, obj in lexer.lex_iter(filename): sys.stdout.write('{:12} {:6d} {}\n'.format( '(None)' if token is None else token, lineno, repr(text)))
def lex(filename): """Dump the lexer output for a Beancount syntax file.""" for token, lineno, text, obj in lexer.lex_iter(filename): sys.stdout.write('{:12} {:6d} {}\n'.format( '(None)' if token is None else token, lineno, repr(text)))