Hello. I use standard module Compiler to build ASTs of Python code.
Given AST subtree I want to restore coordinates of substring in the input, which is covered by the subtree. Example: Suppose, the input is 'a+(b+c)'. It is parsed to the tree ADD(a, ADD(b,c)) by module Compiler. I want to have a function, which given ADD(b,c) will return the coordinates of the substring '(b+c)'. Module Compiler provides only line numbers for each node. But even this information is incorrect: only the first line of multi-lined statements is stored. What is the easiest way of doing what I want? As I understand, module Compiler is automatically generated by some parser generator. Maybe I can modify it? -- Best regards, Peter Bulychev.
-- http://mail.python.org/mailman/listinfo/python-list