سؤال

I'm currently dealing with yacc & lex. That part is mostly done, however I would like my yyparse function to recieve a parameter.

I found in the bison documentation this http://www.gnu.org/software/bison/manual/html_node/Parser-Function.html

Which pretty much solves my problem, however I would like to know if you guys have used

%parse-param  {int *nastiness}

Outside of Linux, I mean, do you know if %parse-param is portable? is it included in the yacc standard?

هل كانت مفيدة؟

المحلول

%parse-param is not in Posix, and it will not work with all implementations of yacc. On the other hand, nothing links bison to Linux, and bison itself is quite portable.

If you are seeking portability in order to distribute source for you program, you'll likely find that many people these days do not have any yacc installed. It's generally easier to include the bison- and (f)lex- processed files in the tarball, and particularly if you use bison- and flex- specific features.

EDIT:

I just checked Berkeley yacc (byacc) and it does handle %parse-param. So it would only be AT&T yacc which doesn't, and that is not a very common installation afaik.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top