William Coleda wrote:
So... how does one use AST?

The by far simplest way (currently) is to create a textual representation (foo.past). Parrot/ast switches to AST parsing, if an extension .past is seen.


Run "ast2past some.py" in languages/python to see how it looks like.

There's a list of functions in `perldoc ast/node.c`, but that seems to be it. (nothing in docs or t). I don't see that it's used anywhere outside of ast/* ...

Yep, but that's (AFAIK) all what's needed to create the AST. Its usage is shown in ast/ast.y - the parser that reads .past files.


$ ./parrot ast/hello.past
Hello PAST

The exp_*() functions have a brief comment about the node contents that gets parsed.

Is this a C-only interface? If so, any plans to make PMC or opcode wrappers?

We'll have PMCs finally. An NCI-wrapper should also work fine already.

Please note that only a few AST nodes are handled currently in ast/node.c, see the list node_names ast_list[ ] and some of these are Python-specific.

leo



Reply via email to