%{ #include #include #include "idlc/parser.h" #include "idlc/document.h" #include "idlc/declaration.h" #include "idlc/type.h" #include "idlc/parameter.h" #include "idlc/interface.h" #include "idlc/element.h" #include "idlc/structure.h" #include "idlc/block.h" #include "idlc/attribute.h" #include "idlc/tidlc_y.hpp" #define YY_USER_ACTION yylloc->columns(yyleng); %} %x COMMENT VALUE %option yylineno %option noyywrap %option reentrant %option bison-bridge %option bison-locations %% %{ std::string comments; std::string values; %} "/*" { comments += yytext; BEGIN(COMMENT); } "*/"+\/ { comments += yytext; yylloc->step(); BEGIN(INITIAL); } "*/" { comments += yytext; comments += "\n"; BEGIN(INITIAL); } "*/"\n+ { comments += yytext; yylloc->step(); BEGIN(INITIAL); } \n+ { comments += yytext; yylloc->lines(yyleng); } ([^*]\n)+|. { comments += yytext; yylloc->step(); } <> { return 0; } "//".*\n { comments += yytext; yylloc->step(); } "\"" { BEGIN(VALUE); } "\"" { BEGIN(INITIAL); yylval->token = new tidl::Token(values, comments); return yy::parser::token::T_VALUE; } ([^*]\n)+|. { values += yytext; yylloc->step(); } [\n]+ { yylloc->lines(yyleng); yylloc->step(); } [ \t\r\n] ; // ignore all whitespace "," { return yy::parser::token::T_COMMA; } "{" { return yy::parser::token::T_BRACE_OPEN; } "}" { return yy::parser::token::T_BRACE_CLOSE; } "(" { return yy::parser::token::T_LEFT; } ")" { return yy::parser::token::T_RIGHT; } ";" { return yy::parser::token::T_SEMICOLON; } "void" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_VOID; } "char" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_CHAR; } "short" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_SHORT; } "int" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_INT; } "long" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_LONG; } "float" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_FLOAT; } "double" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_DOUBLE; } "bundle" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_BUNDLE; } "string" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_STRING; } "bool" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_BOOL; } "in" { return yy::parser::token::T_IN; } "out" { return yy::parser::token::T_OUT; } "ref" { return yy::parser::token::T_REF; } "async" { return yy::parser::token::T_ASYNC; } "delegate" { return yy::parser::token::T_DELEGATE; } "<" { return yy::parser::token::T_META_OPEN; } ">" { return yy::parser::token::T_META_CLOSE; } "list" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_LIST; } "array" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_ARRAY; } "struct" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_STRUCTURE; } "interface" { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_INTERFACE; } [A-Za-z_][A-Za-z0-9_]* { yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_ID; } "[" { // Square Bracket yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_SB_OPEN; } "]" { // Square Bracket yylval->token = new tidl::Token(yytext, comments); return yy::parser::token::T_SB_CLOSE; } "=" { return yy::parser::token::T_EQUAL; } %%