Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-core-dev] Prototype AST2 available in cdt_ast2

Title: Re: [cdt-core-dev] Prototype AST2 available in cdt_ast2
Hi Doug,

Thanks for your document, excellent to see the efforts your making.  You may know that I have been working on this exact idea and have exchanged several emails with both John Camelon and Andrew Niefer.

I have been working with the call-back architecture and overriding the current Parser class to enable the creation of an AST and I actually like the approach very much.  Consequently, I’d like to suggest that you combine the ideas of call-back with AST construction since I believe these would give the greatest flexibility in parser, the difficulty is knowing how to partition up the syntactic constructs of the different languages that you would like to finally be able to parse.  It seems that you have a fair list in your document and certainly seems to be a good start.  

However the call-back mechanism would be more granular than the current ASTFactory and would reflect more the break-down of functionality in the Parser implementation.  I’m not sure I’m being very clear here.

In terms of the AST itself, it will be interesting to see what your AST structures look like.  I ran into issues with defining classes for for, if-then-else, while etc. since I really wanted some of them to be scoped objects and others to contained scoped objects.  This is somewhat related (but not really) to the issues encountered in the Parser itself when the simpleStatement function creates a code scope, but compoundStatement doesn’t (unless told to).  Also, as suggested by Andrew, it is probably a good idea to attach statements to the symbol table and not to functions.  I have tried the latter and when one things of a function that walks over the DFG of a piece of code it becomes a bit messy.  I think this would be have more clarity if everything was inside the symbol table, I think.  What is your take on this?

Depending on your focus, the AST probably should be explicit or more precisely any syntactic slight of hand should be represented in the AST in full hand notation, so in the example

    float i = 3.0;
    int j = 20;
    float k =  i * j;

The cast on j should appear in the AST tree.

I think it would be valuable to have all AST classes objects as serializable which could help reduce memory requirements by enabling reloading of ASTs when needed.

So, overall I think that the idea of having an AST from the Parser to the Client is a very good step, however I believe that the call-back mechanism could also be a very useful way to retain flexibility in the parser.

Jason



From: Douglas Schaefer <dschaefe@xxxxxxxxxx>
Reply-To: <cdt-core-dev@xxxxxxxxxxx>
Date: Mon, 20 Sep 2004 16:23:19 -0400
To: <cdt-core-dev@xxxxxxxxxxx>
Subject: [cdt-core-dev] Prototype AST2 available in cdt_ast2


Hey gang,

I've taken a quick stab at a prototype implementation of the new AST. This work, of course, is being done on the cdt_ast2 branch. I have created a new JUnit test class AST2Tests in core.tests. The AST interface and factory class are in org.eclipse.cdt.core.parser.ast2 in the parser folder. The AST implementation, including a source element requestor to reuse our parser to create the AST, are in org.eclipse.cdt.internal.core.parser.ast2.

So far, I am just parsing "int x;", but it lets me get a feel for the architecture and applicability of the AST.

Any feedback is appreciated, knowing of course this is a pretty rough run at it. Discussion of this feature is being done at: https://bugs.eclipse.org/bugs/show_bug.cgi?id=57816.

Cheers,
Doug Schaefer, IBM's Eclipse CDT Architect
Ottawa (Palladium), Ontario, Canada

Back to the top