X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=tools%2Fminiswig%2Flexer.ll;h=ac699ab5b2462a8dee3eaa140a9e00960afba351;hb=43c0eee23cceb62937e75c1652bb50572b854c8b;hp=21b13f4e94d55717cb2e7f5ad0c2298c567c6e05;hpb=e2ccc082212e81a7bc2d299d6d5ecb7dee374de2;p=supertux.git diff --git a/tools/miniswig/lexer.ll b/tools/miniswig/lexer.ll index 21b13f4e9..ac699ab5b 100644 --- a/tools/miniswig/lexer.ll +++ b/tools/miniswig/lexer.ll @@ -3,10 +3,11 @@ #include #include #include -#include "tree.h" +#include "tree.hpp" #include "parser.hpp" -#include "globals.h" +#include "globals.hpp" +#define YY_NEVER_INTERACTIVE 1 #define YY_DECL int yylex(YYSTYPE* yylval) #define YY_INPUT(buf, result, max_size) \ @@ -77,7 +78,7 @@ int getCurrentLine() class { return T_CLASS; } struct { return T_STRUCT; } static { return T_STATIC; } -virtual { return T_VIRTUAL; } +virtual { } const { return T_CONST; } unsigned { return T_UNSIGNED; } signed { return T_SIGNED; } @@ -99,8 +100,9 @@ namespace { return T_NAMESPACE; } ns = current_namespace; // is it a type? yylval->atomic_type = ns->_findType(yytext, search_down); - if(yylval->atomic_type) + if(yylval->atomic_type) { return T_ATOMIC_TYPE; + } // or a namespace? (hack for now...) yylval->_namespace = ns->_findNamespace(yytext, search_down); if(yylval->_namespace) { @@ -111,18 +113,18 @@ namespace { return T_NAMESPACE; } return T_ID; } \:\: { return T_DDCOL; } -[0-9]+ { - yylval->ival = atoi(yytext); - return T_INT; - } -[0-9]*\.[0-9]+(e[0-9]+)? { - yylval->fval = atof(yytext); - return T_FLOAT; - } -\".*\" { - yylval->str = strdup(yytext); - return T_STRING; - } +(0x)?[0-9]+ { + sscanf(yytext, "%i", &(yylval->ival)); + return T_INT; +} +[0-9]*\.[0-9]+(e[0-9]+)? { + sscanf(yytext, "%f", &(yylval->fval)); + return T_FLOAT; +} +\".*\" { + yylval->str = strdup(yytext); + return T_STRING; +} . { return yytext[0]; } %%