Thread overview
I want a tree
Sep 15, 2005
Georg Wrede
Nov 03, 2005
Larry Evans
Nov 04, 2005
Georg Wrede
September 15, 2005
I know there are several directions to go to if I want to end up with a  tree structure that represents a program file's lexed and parsed contents. Some of them better than the other, in some aspect.

What I'm looking for is to be able to read D source as input, parse it to a tree, then output it as (almost) the same source.

Why??? Well, I need to do this to "first get it right". Then I want to try out a few ideas on how to define details of (the now infamous and almost entirely forgotten) meta language that I raved about last winter.

If it works, then we can start thinking of how (or why) it should be incorporated into D or DMD, or neither.

(If given a choice, I'd slightly prefer DMD over GDC, even though I'll be working both in Linux and Windows.)
November 03, 2005
On 09/15/2005 04:02 PM, Georg Wrede wrote:
> I know there are several directions to go to if I want to end up with a  tree structure that represents a program file's lexed and parsed contents. Some of them better than the other, in some aspect.
> 
> What I'm looking for is to be able to read D source as input, parse it to a tree, then output it as (almost) the same source.

What about emulating boost's spirit library?

  http://www.boost.org/libs/spirit/index.html

There's also a prototype in the same "spirit" at:

  http://boost-consulting.com/vault/

in

  /Template Metaprogramming/proto_static_disp.zip

it's much simpler than spirit; so, it may be easier
to start transformation from there.
November 04, 2005
Larry Evans wrote:
> On 09/15/2005 04:02 PM, Georg Wrede wrote:
> 
>> I know there are several directions to go to if I want to end up
>> with a  tree structure that represents a program file's lexed and
>> parsed contents. Some of them better than the other, in some
>> aspect.
>> 
>> What I'm looking for is to be able to read D source as input, parse
>> it to a tree, then output it as (almost) the same source.
> 
> What about emulating boost's spirit library?
> 
> http://www.boost.org/libs/spirit/index.html

Whew! Thaks!

Spent 6 hours reading through the entire manual!

This is awsome stuff. Imagine that you can write source code just like always, and within it lines that look like "normal" grammar definitions -- without any jumping or gymnastics. Just unbelievable.

While the template "programming language" in C++ is a nightmare, some of these guys really can make it shine! And to think that the end result turns out to be so incredibly easy, usable, and obvious!

And the manual, and the quick reference. Oh boy!

---

And as a Linux user, I've had this all along -- what an embarrasment. No downloads, configuring, nothing. Just try out the examples and ideas, right now.

This is almost enough to make me go back to C++ (no panic, just for this one thing, nothing else), for a while to try this out.

Man, D metaprogramming features should be relentlessly pursued until we can _proove_ that anything the C++ guys could do is doable in D!