simplified Python parsing question
gandalf at shopzeus.com
Mon Jul 30 11:25:28 CEST 2012
> I appreciate the help because I believe that once this is working,
> it'll make a significant difference in the ability for disabled
> programmers to write code again as well as be able to integrate within
> existing development team and their naming conventions.
Did you try to use pygments?
It already contains a lexer for Python source code. You can create a
Lexer (pygments.lexer.Lexer) then call its get_tokens method.
Then you can use this to identify statements:
Fortunately, almost all statements begin with a keyword. There are some
I would first tokenize the code, then divide it by statement keywords.
Finally, you just need to find expression/assignment statements in the
remaining sections. (Maybe there is a better way to do it.)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list