Hello,
I have just committed a major rewriting of the Python to JS translation engine.
In script py2js.js, there was a signle function called tokenize() that parsed the source code, identified the tokens (strings, names, operators etc.) and built the syntax tree. It was probably the most obscure part of the whole Brython code...
The new version delegates the parsing to a new script, python_tokenizer.js. It provides a Javascript generator that yields tokens with the same format as those produced by the CPython module tokenize.
In py2js.js, tokenize() is replaced by a function dispatch_tokens() that, as its name says, dispatches the tokens and builds the syntax tree.
The change makes the code hopefully easier to understand and to maintain. But, although I spent time testing the new version, it is so different from the previous one that it may have introduced regressions here and there...