X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=tools%2Fminiswig%2Flexer.ll;h=954138b07fed3e9510061edefcd091c9a3a3e62f;hb=30f0f1d78e3f0bbbaf0b8d9d80fcbb579059941e;hp=ccaf06712d34f5bd8e1cb56dc3d7c074e3fab602;hpb=74863ab9562536398b7f15861f30075758ab4285;p=supertux.git diff --git a/tools/miniswig/lexer.ll b/tools/miniswig/lexer.ll index ccaf06712..954138b07 100644 --- a/tools/miniswig/lexer.ll +++ b/tools/miniswig/lexer.ll @@ -1,4 +1,6 @@ %{ +#include + #include #include #include @@ -7,6 +9,11 @@ #include "parser.hpp" #include "globals.hpp" +// there seems to be a bug in flex that adds some ECHO directives +// in some rules, we don't need debug output +#define ECHO {} + +#define YY_NEVER_INTERACTIVE 1 #define YY_DECL int yylex(YYSTYPE* yylval) #define YY_INPUT(buf, result, max_size) \ @@ -77,7 +84,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; } @@ -93,14 +100,17 @@ public { return T_PUBLIC; } protected { return T_PROTECTED; } private { return T_PRIVATE; } namespace { return T_NAMESPACE; } +__suspend { return T_SUSPEND; } +__custom { return T_CUSTOM; } [a-zA-Z_][a-zA-Z_0-9]* { Namespace* ns = search_namespace; if(ns == 0) 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 +121,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]; } %%