def transpile(src): """Convert a Pytuguês (Pytuguese?) source to Python.""" # Avoid problems with empty token streams if not src or src.isspace(): return src # Convert and process... else: tokens = lexer.fromstring(src) transpiled_tokens = lexer.transpile_tk(tokens) result = lexer.tostring(transpiled_tokens) return result
def transpile(src): """ Convert a Pytuguês/Pytuguese source to Python. """ # Avoid problems with empty token streams if not src or src.isspace(): return src # Convert and process... else: src_formatted = src if not src_formatted.endswith('\n'): src_formatted += '\n' tokens = lexer.fromstring(src_formatted) transpiled_tokens = lexer.transpile_tk(tokens) result = lexer.tostring(transpiled_tokens) return keep_spaces(result, src)
def py(src): return [repr(x) for x in fromstring(src)]
def pytg(src): return [repr(x) for x in fromstring(transpile(src))]
def py(src): return [repr(x) for x in fromstring(src)]
def pytg(src): return [repr(x) for x in fromstring(transpile(src))]