How Pyrtugues Translates Portuguese Code to Python Without Breaking Strings
Pyrtugues is a programming language that allows developers to write code in Portuguese, which is then translated into valid Python. The core challenge is avoiding naive keyword substitution, which can corrupt string contents, comments, and variable names. The translator first shields all strings and comments from modification, then applies context-aware regex patterns to translate only genuine keywords in the correct positions. For example, 'se' is converted to 'if' only at the start of a conditional line, and 'e' becomes 'and' only when used between expressions rather than inside text. The project is open source and available on GitHub, with a web editor hosted at pyrtugues-editor.pages.dev.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in