Zebediah Figura (@zfigura) commented about dlls/msado15/filter.l:
+"=" { yylval->ival = op_equal; return TOKEN_EQ; } +">" { yylval->ival = op_greater; return TOKEN_GREATER; } +"<" { yylval->ival = op_less; return TOKEN_LESS; } +"<>" { yylval->ival = op_not_equal; return TOKEN_NOT_EQ; } +">=" { yylval->ival = op_greater_equal; return TOKEN_GREATER_EQ; } +"<=" { yylval->ival = op_less_equal; return TOKEN_LESS_EQ; } +"like" { yylval->ival = op_like; return TOKEN_LIKE; }
+"and" { yylval->ival = join_and; return TOKEN_AND; } +"or" { yylval->ival = join_or; return TOKEN_OR; }
+[A-Za-z_0-9.]* { yylval->token = strdup(yytext); return TOKEN_COLUMN; }
+%%
In general you want a rule like
. {return yytext[0];}
This does two things:
- in the absence of such a rule, the lexer will silently accept any characters it cannot match, which probably isn't what you want (you probably want them to generate a syntax error instead, which is easily achieved by simply providing no corresponding parser rules for the token)
- it allows you to express single-character tokens (e.g. '=') as a literal character in the parser, and at the same time removes the need to specify them in the lexer.