dotgnu-general
[Top][All Lists]
Advanced

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

[DotGNU]Can treecc help me?


From: Adam Treat
Subject: [DotGNU]Can treecc help me?
Date: Sun, 2 Feb 2003 07:35:31 -0500
User-agent: KMail/1.4.7

Hi all,

I've recently reread Rhys's excellent paper on treecc and I can't help feeling 
a sense of deja vu.  His paper seems to describe the exact problems I have 
encountered as Binge (the new Qt# binding generator) becomes more feature 
complete.  I wonder if treecc or some type of Aspect Oriented programming 
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:

Binge is the new Qt# binding generator I've been working on for a couple 
months.  It is becoming feature complete, but ever more hairy as corner cases 
pop up.  At first I was very happy with the design of Binge as it seemed 
infinitly more elegant than the old binding generator, but with the 
increasing complexity I am worried that one change will propogate 
errors/problems throughout.  

Ok, so Binge basically parses a file ... does some analysis/conversion ... and 
generates code.  In my case the file is XML and this XML file was created by 
another tool that parses C++ header files.  When binge parses the XML file it 
populates the data into a data structure that I've created.  This data 
structure has classes such as 'Namespace' and 'Object' and 'TypeBase' and 
'Interface' and 'Class' ... 'Member' ... 'Constructor' ... 'Method' ... 
'Property' ... 'Parameter' ... you get the picture.  All of these classes are 
then inserted into Hashtables such as the global namespaces hash and each 
member is inserted into the parent objects members hash and so on.  Then I 
walk the hash table and visit each data type and do various 
conversion/analysis/glue operations which try to associate all of these 
classes and convert some methods into properties for instance.  This phase 
takes forever because I am doing 2-3 passes through the global hashes so that 
any new data objects I've created in the previous pass are then converted 
themselves.  I also have to manage the generation of both C source glue code 
and C# binding code.  This is done during the print phase.  As you can 
imagine the analysis/conversion phase where I visit the various data objects 
and do a bunch of comparison and introspective hashtable lookups is time 
consuming.

So, Binge is capable of going on and it is possible to produce a solid binding 
generator, but I am just wondering about other possibilities.  Perhaps what 
binge does is different and so does not fit nicely into a treecc or Aspect 
Oriented strategy, but I thought I'd put it out there and see if anyone has a 
better way.

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.  
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?

Cheers,

Adam


reply via email to

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