Skip to content

Commit

Permalink
Fixed issue with locations of parse errors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bbliem committed Aug 12, 2016
1 parent f04aa98 commit 30e1449
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mc_lexer.l
Expand Up @@ -5,7 +5,7 @@
/* Implementation of yyFlexScanner */
#include "mc_scanner.hpp"
#undef YY_DECL
#define YY_DECL int MC::MC_Scanner::yylex( MC::MC_Parser::semantic_type * const lval, MC::MC_Parser::location_type *location )
#define YY_DECL int MC::MC_Scanner::yylex( MC::MC_Parser::semantic_type * const lval, MC::MC_Parser::location_type *loc )

/* typedef to make the returns for the tokens shorter */
using token = MC::MC_Parser::token;
Expand Down

0 comments on commit 30e1449

Please sign in to comment.