6

How can I pass one aditional parameter (not the token minor of type YYSTYPE) to the yypush_parse() function?

The parser is indeed reentrant, but this one aditional variable is crucial for the thread-safety of the application I need to integrate my parser in (it's a PHP extension, so we're talking about TSRM).

I cannot just get rid of that parameter because inside the action code I'm going to call functions which will generate an AST in a userland-accessible form.

I've tried to hack around YYPUSH_DECLS and it works as far as declaring the function is concerned, BUT a few thousand LOCs down comes the implementation of yypush_parse, and I can't see any way to overwrite the function signature where the implementation of yypush_parse starts.

YYPARSE_PARAM is only used when the parser is not a push one (as far as I can tell), but in my case I NEED it be push because of the things I have to do in the processing loop, after lexing and prior to adding a new token to the parsing stack.

So I am wondering if there's a %directive or something that may help.

On the other side, I really think YYPARSE_PARAM should be used as far as it's defined, no matter what type of parser it is. It's a pity it's not.

Flavius
  • 13,566
  • 13
  • 80
  • 126

1 Answers1

1

%parse-param. YYPARSE_PARAM is deprecated and shouldn't be used.

Flavius
  • 13,566
  • 13
  • 80
  • 126
  • Sadly, `%parse-param` is for the `yyparse()` function, not `yypush_parse()`. – Jonathan Leffler Apr 17 '11 at 13:55
  • OK: let's revise my comment - sadly, the documentation does not mention that `%parse-param` can be used with `yypush_parse()`, AFAICS. Your empirical evidence suggests that it can be used; we should perhaps get a note to the Bison team that this bit is missing from the documentation. – Jonathan Leffler Apr 17 '11 at 17:54