remusao / Bison-Flex-CPP-template

A C++ template for Bison / Flex projects
MIT License
34 stars 7 forks source link

Move location tracking out of the driver #6

Closed flofriday closed 1 year ago

flofriday commented 1 year ago

This now let's us use the @n location actions in the parser to get the location of each token.

Bison calls yylex with a pointer to a location and expects the scanner to update the location. Before, this location was ignored and a separate location in the driver was used. However, bison wasn't aware of that and therefore the location actions pointed to bad locations.

I know that the template doesn't use the location actions in it's grammar, but it took me almost two days of research and debugging to get bison's location tracking to work and I think this would be nice to have in the template (also it's less code 😊).