[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU]Can treecc help me?

From: Gopal V
Subject: Re: [DotGNU]Can treecc help me?
Date: Mon, 3 Feb 2003 02:08:24 +0530
User-agent: Mutt/1.2.5i

If memory serves me right, Adam Treat wrote:
> encountered as Binge (the new Qt# binding generator) becomes more feature 
> complete. 

Like I mentioned in IRC , binge is yet another code translator ... which
is TreeCC's special area :)

> approach might be in order here.  Currently, I am using a visitor pattern 
> with a little mix of the inheritance pattern.  I've seriously thought about 
> moving to an inheritance pattern completely, but now I'm in doubt.  Let me 
> describe Binge a little more:

hhmm... TreeCC has been about mixing inheritance and visitors safely...

> I don't entirely understand treecc.  It seems that you write input files for 
> treecc that use an internal treecc language and then treecc will generate 
> scaffolding for your compiler in whatever output language you choose.  

TreeCC is like the familiar compiler dev tools ,ie flex and bison ... Both
of them have their mini-language and then jump down into C (or C# etc...)
for the actions ..

> Surely, this scaffolding is just stub code and you'd have to actually modify 
> the scaffolding to produce a compiler ... but then you are likely to 
> regenerate the scaffolding as you flesh out the compiler so then you'd have 
> to reinsert the implementation code ... What am I missing?

The treecc tool is called the "Aspect Weaver" so to say ... it meshes the 
various concerns together ...

For example the base set of nodes for the CSCC compiler is in pnet/codegen/
So when we add a new operation in pnet/cscc/csharp/ the original code is
not affected ... In fact the C compiler and the C# compiler re-use a lot 
of the basic nodes by having different SemanticAnalysis operations.

%node basenode %abstract %typedef =
        /* abstract class */

%node mynode basenode = /* inheritance */
        int val; /* included in the constructor */
        %nocreate int hidden={0};  /* not included in .ctor */

%operation void Processor:Process([basenode b])

/* which means Processor.Process() has a trigger "basenode b" */

        Console.WriteLine(b); /* print b */
        /* some other processing for mynode b */


So you can add new visitors without affecting the original code ...
and still use (psuedo)inheritance to re-use operations of parents 

Hope it's clearer ... and I think the JScript implementation of pnet
might be an even better example from a C# point of view...

PS: the example code was written , and was never tested !!
The difference between insanity and genius is measured by success

reply via email to

[Prev in Thread] Current Thread [Next in Thread]