Some interesting ideas! This work is something I’d like to revisit, because at the time we just hacked together something quick for the project.
We actually do use Python’s AST to pull out the various tokens (and reject comments and other code cruft), but not much beyond that!