X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/b17287deb56775a49030d738d8c8c0e9cd15f9fe..853c670e4b839fd435507201f04d16080590a894:/src/lexer.l diff --git a/src/lexer.l b/src/lexer.l index ddbd951..f45fcc5 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -24,6 +24,7 @@ #include #include +#include "treefuncs.h" #include "parse.h" #include "main.h" #include "util.h" @@ -50,9 +51,9 @@ static void clear_cbuf(void) { if(!cbuf) { - cbuf = g_string_new(""); + cbuf = g_string_new(NULL); } else { - cbuf = g_string_assign(cbuf,""); + cbuf = g_string_assign(cbuf, ""); } } @@ -80,6 +81,10 @@ add_gtk_doc_func(void) gtk_doc_func = NULL; } +/* Ugly warning avoiding */ +#ifdef FLEX_SCANNER +int yylex(void); +#endif %} @@ -92,11 +97,33 @@ add_gtk_doc_func(void) %x GTK_DOC %x GTK_DOC_LINE + + %% <*>\n { line_no++; REJECT; } -<*>MOTHERFUCKER { fprintf(stderr,"You are a bad bad person!\n"); REJECT; } +^(I(S.RI).E\(([1-9][0-9]+|[2-9]))/(\)) { +/* Thy evil easter egg */ +#define QQ(x) long x +#define KK(x) =atoi(__(&,,x,)) +#define MM(x,a) {QQ(i);for(i=2;i^#[ \t]*include[ \t][<"][^\n">]*[>"] { @@ -307,9 +334,8 @@ class { BEGIN(CLASS_CODE); if(++found_classes > 1) { - print_error(FALSE, - "Only one class per file allowed", - line_no); + error_print(GOB_ERROR, line_no, + "Only one class per file allowed"); } return CLASS; @@ -327,26 +353,21 @@ class { if(rmaj < maj || (rmaj == maj && rmin < min) || (rmaj == maj && rmin == min && rpl < pl)) { - char *s; - s = g_strdup_printf( - "GOB version %d.%d.%d required " - "(this is %s)\n" - "To upgrade your gob, see: " - "http://www.5z.com/jirka/gob.html", - maj,min,pl,VERSION); - print_error(FALSE, s, line_no); - g_free(s); + error_printf(GOB_ERROR, line_no, + "GOB version %d.%d.%d required " + "(this is %s)\n" + "To upgrade your gob, see: " + "http://www.5z.com/jirka/gob.html", + maj, min, pl, VERSION); } } class|this { if(for_cpp) { - char *s; - s = g_strdup_printf("'%s' keyword should not " - "be used when generating " - "C++ code",yytext); - print_error(TRUE, s, line_no); - g_free(s); + error_printf(GOB_WARN, line_no, + "'%s' keyword should not " + "be used when generating " + "C++ code", yytext); } REJECT; } @@ -372,16 +393,22 @@ class { public {yylval.line = line_no; return PUBLIC;} private {yylval.line = line_no; return PRIVATE;} protected {yylval.line = line_no; return PROTECTED;} +classwide {yylval.line = line_no; return CLASSWIDE;} argument {yylval.line = line_no; return ARGUMENT;} virtual {yylval.line = line_no; return VIRTUAL;} signal {yylval.line = line_no; return SIGNAL;} override {yylval.line = line_no; return OVERRIDE;} -onerror {return ONERROR;} -0|[1-9][0-9]*|0x[0-9a-fA-F]+|0[0-7]+|[0-9]*\.[0-9]+|\.[0-9][0-9]* { +0|[1-9][0-9]*|0x[0-9a-fA-F]+|0[0-7]+|[0-9]*\.[0-9]+|\.[0-9][0-9]* { yylval.id = g_strdup(yytext); return NUMBER; } -:?[A-Za-z_][A-Za-z0-9_]*(:[A-Za-z0-9_]*)+ { +[A-Za-z_][A-Za-z0-9_]*(:[A-Za-z0-9_]*)+ { + /* this one is for a classname with a namespace */ + yylval.id = g_strdup(yytext); + return TYPETOKEN; + } +:[A-Za-z_][A-Za-z0-9_]*(:[A-Za-z0-9_]*)* { + /* this is for a classname with an empty namespace */ yylval.id = g_strdup(yytext); return TYPETOKEN; } @@ -390,7 +417,7 @@ class { return TOKEN; } -(\[[0-9]*\])+ { +(\[[0-9]*\]|\[[A-Za-z_][A-Za-z0-9_]*\])+ { yylval.id = g_strdup(yytext); return ARRAY_DIM; } @@ -421,3 +448,16 @@ class { } <*>[\n\r] ; /*ignore*/ + +%% + +/* Ugly warning avoiding */ +#ifdef FLEX_SCANNER +static void warning_avoider(void) G_GNUC_UNUSED; +static void warning_avoider(void) { + yy_flex_realloc(NULL, 0); + yyunput(0, NULL); + warning_avoider(); +} +#endif +