Hi there,

in an attempt to speed up my parser ( I am trying to stay away from
hand-writing it but all lex/yacc replacements in Perl are just far too
slow ) I came up with the idea of generating the scanner and the parser
code with flex/yacc and then using that code in my perl program via this
new and cool Inline module.

All went well with compiling - I replaced one #define in the code (YYSTYPE
generated by yacc conflicts with YYSTYPE in EXTERN.h and changed main() to
parse_it() - and so I called this function from the perl code. But then it
segfaults when it calls yyparse:

here is the former main() function, it never seems to reach yyparse():

...

void parse_it () {

        do {
                printf( "started yyparse\n");
                yyparse();
                printf( "finished yyparse\n");
        } while (!feof(yyin));
}


yyerror( char* s) {

        fprintf( stderr, "%S\n",s);
}

#line 131 "y.tab.c"
#define YYABORT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
yyparse()
{
    register int yym, yyn, yystate;

    printf("in yyparse\n");

...

[vlad@vlad c]$ perl parse.pl
started yyparse
Segmentation fault


The pure C version runs just fine.
I am using Inline 0.30 on  a Linux system (RedHat 6.0 with glibc 2.1),
gcc version pgcc-2.91.66, perl 5.6.

Any help is greatly appreciated.

Thanks,
Vlad

Reply via email to