jonathan-beard / simple_wc_example

simple word count example using flex/bison parser
Apache License 2.0
139 stars 43 forks source link

Fixed issue with locations of parse errors #12

Closed bbliem closed 8 years ago

bbliem commented 8 years ago

If you change your grammar in such a way that, for some strange reason, you want each upper-case letter to be followed by an 'x', the resulting rules in mc_parser.yy could look like this:

item : UPPER 'x' { driver.add_upper(); } ... ;

Now if your parser encounters an upper-case letter and then a character that is not 'x', it would report an error. However, the printed location is always line 1, column 1. The proposed change should fix that.