[antlr-interest] Comments and questions on a recent project

Tiller, Michael (M.M.) mtiller at ford.com
Mon Aug 26 12:18:35 PDT 2002


> From: mzukowski at yci.com [mailto:mzukowski at yci.com]
> Subject: RE: [antlr-interest] Comments and questions on a recent project
> 
> 
> 
> > I put this in my grammar:  "{ #cd1 = #[,#cd1,#f]; }"
> > 
> > This gives me "Syntax error in action: line 118: unexpected 
> > char: ," from ANTLR.
> > 
> > Are you just making this up as you go. ;-)
> 
> Darn, you mean you want it to work?  Let me look at some real 
> code.  Here
> you go, from the gcc project:
> 
> ## = #( null, ##, #( #[NParameterTypeList], #p ) );
> 
> Monty

Well, this works.  But it doesn't do what I need for two reasons.  First, it isn't language neutral.  I had to change "null" to "NULL" for the C++ backend.  But, more importantly, what I need is a language neutral way of doing this:

{ #cd1->addChild(#f); #cd1->addChild(#i); #cd1->addChild(#o); }

The problem is that:

{ #cd1 = #(NULL,#cd1,#f,#i,#o); }

is like:

{ #cd1->addSibling(#f); #cd1->addSibling(#i); #cd1->addSibling(#o); }

whereas

{ #cd1 = #(cd1, #f, #i, #o); }

is like:

{ #cd1 = #([...]); #cd1->addChild(#f); #cd1->addChild(#i); #cd1->addChild(#o); }

(i.e. it starts from scratch)

It is mostly a moot point since I'm not able to make my whole system language neutral at this point for other reasons.

To address Ter's comment about needing actions in the parser, I would say I guess I don't agree.  I have made a complete parser (not tree parser) that contains only basic tree manipulation routines.  I don't see any reason why all the things I needed to do to my tree couldn't have been done with a language neutral shorthand.

The point of my project was to establish a parser indepedent of application and I was 95% successful.  That is the sad thing since I don't see a good reason why it couldn't have been 100% successful.  The language I'm compiling is not a procedural language so I don't need a backend or even an interpreter.  The language is more like PROLOG (i.e. declarative) so there are lots of things you can do with just a tree.

--
Mike


> 
>  
> 
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ 
> 
> 

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list