Bison uses a special error token (called 'error') that one can use in a Bison par开发者_Go百科ser to recover from errors. Is there a way to return this specific token from a scanner generated by Flex?
The 'error' token is not really a token. It's used for error handling only.
On http://dinosaur.compilertools.net/yacc/index.html you can read: The token name error is reserved for error handling, and should not be used naively.
In my own parser I use the error token like this (to parse a C-like macro-language:
StatementList  :
               |  StatementList Statement ';'
               |  error ';'
If the user makes an error, yacc/bison will go on until the next semi-colon (end of a statement) and then go on with the next statement.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论