> How I can run bison from C source code passing a string to parse? `yyparse' works by calling `yylex' which, in effect, passes token-value pairs to `yyparse'. There is a difference depending on whether your parser is reentrant or not. If it is, `yyparse' doesn't use global variables. Passing a string as an argument to `yyparse' is not the way it's meant to be used. Nor are the token-value pairs passed back to `yyparse' as the return value of `yylex'.
> For example I have abcbdc sequence to parse. I can call yyparse function passing this string like parameters or directly like executable parameters > (./parser abcbdc) ? The input source is a matter for `yylex'. You can write `yylex' by hand or use Lex, Flex, or some other package to generate it. The Flex documentation specifically explains how to get `yylex' to read from a string. In fact, you can read from any input source you want: a file, a pipe, a device, whatever. It is also possible to pass a parameter to `yyparse' which can also be passed to `yylex'. A `void*' which points to the actual object is the argument. You can, of course, use this object to refer, directly or indirectly, to the string you want to read. This probably isn't the easiest solution, though. It is certainly possible to pass a string or the name of a file to your `main' function and arrange for it to be parsed. In this case, you should certainly ensure that only a certain number of characters is read in order to prevent buffer overflows. You will, of course, also need to use appropriate quoting, to make sure that the shell doesn't expand characters that have a special meaning to the shell. Laurence Finston _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison