Bison does not appear to recognize C string literals appropriately

前提是你 提交于 2019-12-08 05:36:18
jpalecek

This is a classic error, if you use flex to lex your input into tokens, you must not refer to the literal strings in the parser as literal strings, but rather use tokens for them.

For details, see this similar question

Thankee, thankee, thankee!

Just to clarify, here is how I implemented my solution, based on the comments from jpalecek. First, I declared an INSERT token in the bison code (parser.yy):

71 %token INSERT

Next, I defined that token in the flex code (scanner.ll):

79 "INSERT INTO" { return token::INSERT; }

Finally, I used the token INSERT in my grammar rule:

132 insertexpr :  INSERT expr '(' expr ')'
133 
134                  {
135                         $$ = new QLInsert( $2, $4 );
136                          }
137                         ;

And voila! my over-extended headache is finally over!

Thanks, jpalecek :).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!