Hello the team:
I'm now learning the yacc & lex and want to write a simple SQL parser,
Here's part of my code
%option noyywrap %option bison-bridge %option reentrant ... enum { UNDEFINED = 1, CREATE, TABLE, UPDATE, SET, INSERT, INTO, VALUES, DELETE, FROM, SELECT, GET, PUT, EXIST, USER, BEGIN, COMMIT, ROLLBACK }; ... [Cc][Rr][Ee][Aa][Tt][Ee] RETURN_TOKEN(CREATE) [Tt][Aa][Bb][Ll][Ee] RETURN_TOKEN(TABLE) [Uu][Pp][Dd][Aa][Tt][Ee] RETURN_TOKEN(UPDATE) [Ss][Ee][Tt] RETURN_TOKEN(SET) [Ii][Nn][Ss][Ee][Rr][Tt] RETURN_TOKEN(INSERT) [Ii][Nn][Tt]Oo RETURN_TOKEN(INTO)
As you can see,I want to let the lex recognized the token,but when I compile the c code generated by the lex,
some error showed:
[beginnerc@fedora SimpleSQL]$ lex try.l [beginnerc@fedora SimpleSQL]$ gcc lex.yy.c lex.yy.c:145:18: error: expected ',' or '}' before '->' token 145 | */ | ^ try.l:32:5: note: in expansion of macro 'BEGIN' 32 | BEGIN, | ^~~~~ lex.yy.c:559:5: error: unknown type name 'YYSTYPE' 559 | | ^ lex.yy.c:606:1: error: unknown type name 'YYSTYPE'; did you mean 'YYSTATE'? 606 | | ^ | YYSTATE lex.yy.c:608:19: error: unknown type name 'YYSTYPE'; did you mean 'YYSTATE'? 608 | | ^ | YYSTATE lex.yy.c:726:17: error: unknown type name 'YYSTYPE'; did you mean 'YYSTATE'? 726 | extern int yylex \ | ^~ | YYSTATE
Can someone give me some advice to fix the error?
Thanks in advance!
Yours,
WenYi.
|