[antlr-interest] [C Target] Getting segmentation fault in isNilNode () from libatnlr3c.so

L. Rahyen research at science.su
Thu Dec 2 13:16:08 PST 2010


On 2010-12-02 (December, Thursday) 18:39:15 Jim Idle wrote:
> Please study the downloadable examples for using the C output

	Thanks, my problem is solved (below I explain where the problem was and 
why I encountered it).

	I did looked at the examples again. It turned out that my mistake was 
translating from Java "new CommonTreeNodeStream" to 
"antlr3CommonTreeNodeStreamNew" instead of "antlr3CommonTreeNodeStreamNewTree" 
(just missed second "Tree" at the end and used ".tree->strFactory" instead of 
".tree" because was reading "wrong" doc about antlr3CommonTreeNodeStreamNew). I 
should have studied the examples more carefully before writing to mailing list.
	For some reason mailing list deleted fifth attachment in my previous 
message - Test.cpp; I'm attaching fixed version of it to this message: perhaps 
somebody will find it as useful short example in the future.

> also be more reasonable to use the Java output until you are more familiar
> with everything.

	As you can see from the above Java target isn't very useful thing to learn 
by itself if I want to use C target; in other words, knowing well ANTLR Java 
target will not always help with problems in C target. That's exactly why I'm 
learning ANTLR C target by translating simple examples to C++ from the book. I 
think this is effective and fast way of learning both ANTLR and its C target.

> > -----Original Message-----
> > From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> > bounces at antlr.org] On Behalf Of L. Rahyen
> > Sent: Thursday, December 02, 2010 10:22 AM
> > To: antlr-interest at antlr.org
> > Subject: [antlr-interest] [C Target] Getting segmentation fault in
> > isNilNode() from libatnlr3c.so
> > 
> > 	I'm trying to get working (for C target) very simple example from
> > 
> > "The Definitive ANTLR Reference" book, page 73, "3.3 Evaluating
> > Expressions Using an AST Intermediate Form". Of course, for Java target
> > everything is fine. I'm trying to write the same thing using C target
> > but it looks like I did something wrong because I get segmentation
> > 
> > fault at this line in Test.cpp:
> >   walker->prog(walker); (in isNilNode() from libatnlr3c.so)
> > 	
> > 	I'm just getting started with ANTLR. I would really appreciate if
> > 
> > somebody suggest something that could help me to find where is the
> > 
> > problem. To reproduce the problem, please use attached files:
> > 	0) Save all files in the same directory, cd to it and run "chmod
> > 
> > +x compile"
> > 
> > 	1) Open Expr.g in ANTLRWorks, generate code, then do the same with
> > 
> > Eval.g
> > 
> > 	2) Run (I'm using GNU C++ compiler): ./compile
> > 	3) Run: ./Test input
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address


More information about the antlr-interest mailing list