flex+bison in a php extension
-
26-05-2021 - |
Question
I have created a small parser in c using flex and bison. The parser writes the result to some global variables and the caller function reads it from there.
I am trying to package my parser as a php extension. From what i understand from the php documentation true global variables are not recommended because they are not thread-safe and i have to use module globals instead.
In order to use module globals you have to pass in the function TSRMLS_DC as its last argument.
To you know if i can modify the yyparse to accept TSRMLS_DC as an argument. Or if there is another way to access global variable?
La solution
I wouldn't use global variables, but use a more modern parser generator that is also reentrant. Look for instance how I've done it for the meta extension (I use a slightly changed lemon and re2c).