Menu
  • HOME
  • TAGS

How to do proper error handling in BNFC? (C++, Flex, Bison)

c++,bison,flex-lexer,bnfc

In bison you can access the starting and ending position of the current expression using the variable @$, which contains a struct with the members first_column, first_line, last_column and last_line. Similarly @1 etc. contain the same information for the sub-expressions $1 etc. respectively. In order to have access to the...

Why parsing this program with BNFC fails?

parsing,bnf,bnfc

I would think you would get a shift/reduce conflict report for that grammar, although where that error message shows up might well depend on which tool BNFC is using to generate the parser. As far as I know, all the backend tools have the same approach to dealing with shift/reduce...

BNF grammar for a simple c++ program example

c++,parsing,bnf,bnfc

The line on which it fails, cannot be parsed because you are missing some rules : You need a rule for parsing qualified ids. A qualified id is a special type of identifier, and can (for your purposes) be used in the same situations as an (unqualified) identifier. std::cout and...