[Python-Dev] AST branch is in?
Guido van Rossum
guido at python.org
Fri Oct 21 21:13:36 CEST 2005
On 10/21/05, Neil Schemenauer <nas at arctrix.com> wrote:
> Also, the concrete syntax tree (CST) generated by Python's parser is
> not a convenient data structure to deal with. Anyone who's used the
> 'parser' module probably experienced the pain:
>
> >>> parser.ast2list(parser.suite('a = 1'))
> [257, [266, [267, [268, [269, [320, [298, [299, [300, [301,
> [303, [304, [305, [306, [307, [308, [309, [310, [311, [1,
> 'a']]]]]]]]]]]]]]], [22, '='], [320, [298, [299, [300, [301, [303,
> [304, [305, [306, [307, [308, [309, [310, [311, [2,
> '1']]]]]]]]]]]]]]]]], [4, '']]], [0, '']]
That's the fault of the 'parser' extension module though, and this
affects tools using the parser module, not the bytecode compiler
itself. The CST exposed to C programmers is slightly higher level.
(But the new AST is higher level still, of course.)
BTW, Elemental is letting me open-source a reimplementation of pgen in
Python. This also includes a nifty way to generate ASTs. This should
become available within a few weeks.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list