Including a Flex/Yacc parser to my C program 
Author Message
 Including a Flex/Yacc parser to my C program

I'have made my own parser, which works good alone

But, when i want to include it in my program, a encounter a problem :
i can't parse 2 times in the same instance of the program

For example, if a have

For (i = ; 1 < 10 ; i++) {
        _yy_switch_to_string(<string i want to parse>);

        // the function _yy_switch_to_string is what i use to set a string
for

input of the parser
        yyparse();

Quote:
}

And, at the second execution of the for loop (when i = 2)
i get a seg fault in the yyparse call .. whereas the parsing works well the
first time

So, i suppose i have to make a reset of the parser .. but how ..
the flex-generated function yy_restart(FILE *) doesn't change anything ...

note : i've made other tests and i notice that i get the same problem with
a simple parser .. and that i again get this problem if a change the method
for inputing the string to the parser (for example with overloading yyin
with a FILE* containing my string)

Anybody can help ?

Thanks in advance ..

Antoine Thierry



Sat, 26 Jun 2004 17:21:51 GMT  
 Including a Flex/Yacc parser to my C program


Quote:
> I'have made my own parser, which works good alone

> But, when i want to include it in my program, a encounter a problem :
> i can't parse 2 times in the same instance of the program

> For example, if a have

> For (i = ; 1 < 10 ; i++) {
>         _yy_switch_to_string(<string i want to parse>);

>         // the function _yy_switch_to_string is what i use to set a string
> for

> input of the parser
>         yyparse();
> }

> And, at the second execution of the for loop (when i = 2)
> i get a seg fault in the yyparse call .. whereas the parsing works well
the
> first time

> So, i suppose i have to make a reset of the parser .. but how ..
> the flex-generated function yy_restart(FILE *) doesn't change anything ...

> note : i've made other tests and i notice that i get the same problem with
> a simple parser .. and that i again get this problem if a change the
method
> for inputing the string to the parser (for example with overloading yyin
> with a FILE* containing my string)

> Anybody can help ?

> Thanks in advance ..

> Antoine Thierry

<OT>

The easiest way to read input from a string in flex is to redefine the
YY_INPUT macro.  I did it in a previous post for someone to answer a similar
question.

</OT>

Gregory Pietsch



Sat, 26 Jun 2004 23:13:44 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Parser lex Yacc or bison flex

2. flex and yacc

3. lexx/yacc or flex/bison

4. Parser generator for C# (bison / flex style)

5. Problem with stdin for yacc and flex !

6. FLEX,YAcc

7. Debugging c-code generated from yacc and flex via gdb (xxgdb)

8. Dumb yacc/flex problem

9. Lex/Yacc Substitute (not bison/flex)

10. Bison/flex (lex/yacc)

11. Bison/flex (lex/yacc)

12. LEX and YACC based parser for FORTRAN

 

 
Powered by phpBB® Forum Software