#include <iostream>
#include "lexer.h"
#define yylex aaslex
#define yy_scan_string aas_scan_string
#define yy_delete_buffer aas_delete_buffer
int main()
{
std::string src = "username xx aa";
YY_BUFFER_STATE state = yy_scan_string(src.data());
yylex();
yy_delete_buffer(state);
}
lexer.l:
%option noyywrap noline
%option prefix="aas"
%option header-file="lexer.h"
%{
#include <iostream>
%}
%%
username {printf( "%s
", yytext ); }
. { printf( "other:%s
", yytext ); }
%%
命令行:
> win_flex --wincompat -o %(Filename).cc %(Identity)