help-bison
[Top][All Lists]
Advanced

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

segmentation fault problem


From: gabriele renzi
Subject: segmentation fault problem
Date: Wed, 27 Nov 2002 12:10:46 +0100 (CET)

Hi all, that's the first time I write on this list.
I'm just learning bison's use, and after a couple
experiment I started with a mini translator from a
subset of pascal to C (I think this' quite a "hello
world " in the parsers' world).
My main problem is that even if the parser I generate
works fine in most cases, it crashes when I pass more
than one statement in the loop/conditional blocks:
I.E.

if l<10 then
write (l)
else
l:=10

works fine, but

if l<10 then
write (l);
l:=11
else
l:=11

gives segfault.

I made little research on google and found similar
problems discussed here,so I tried to apply the
suggested solution:

- put a malloc() when strcpy'ing yytext in  
yylval.string 

- malloc yyleng+1 
- use strncpy instead of strcpy

Anyway, I still get a sigsegv.

I even tried to memzero the string, thinking that
maybe the yylval.string was not \0 terminated, but not
even this worked.



I attach the .y & .fl files, the'y re just 2Kb 

Please, help me, I cannot understand what's happening
in my code.

PS
sorry about my english, I'm italian and I've just
studied it when I was at the high school

=====
icq #69488917

______________________________________________________________________
Per te Blu American Express รจ gratis!
http://it.yahoo.com/mail_it/foot/?http://www.americanexpress.it/land_yahoo

Attachment: p2c.tgz
Description: p2c.tgz


reply via email to

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