Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AST

0 views
Skip to first unread message

William Coleda

unread,
Oct 7, 2004, 7:35:45 PM10/7/04
to Perl 6 Internals
So... how does one use AST?

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/* ...

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

Leopold Toetsch

unread,
Oct 8, 2004, 4:03:07 AM10/8/04
to William Coleda, Perl 6 Internals
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

0 new messages