Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I return data from yyparse?

I'm implementing a line-by-line data parser, and it works by calling yyparse in a loop. Only problem is that I have no way of extracting the data, other than a global variable, which I'd prefer to avoid. Any tips?

like image 834
alexgolec Avatar asked Dec 08 '25 23:12

alexgolec


1 Answers

You can use bison's %parse-param directive to add argument(s) for yyparse, which can include a pointer (or in C++ a reference) to some variable or data structure that can be written to in the actions in the parser.

like image 154
Chris Dodd Avatar answered Dec 12 '25 08:12

Chris Dodd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!