X-Git-Url: http://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/2310330e7d4d724bf6641339836be8523f95c916..refs/tags/v0.91.2:/src/lexer.l diff --git a/src/lexer.l b/src/lexer.l index aabc7ad..448da95 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -22,6 +22,7 @@ #include "config.h" #include +#include #include "parse.h" #include "main.h" @@ -36,6 +37,10 @@ static int header_c = FALSE; static GString *cbuf = NULL; int ccode_line = 1; +GList *include_files = NULL; +/* 0 no, 1 means yes, 2+ means don't even start looking anymore */ +static int look_for_includes = 0; + int line_no = 1; static void @@ -73,6 +78,23 @@ add_to_cbuf(char *s) <*>MOTHERFUCKER { fprintf(stderr,"You are a bad bad person!\n"); REJECT; } \/\/.*$ { ; /*comment, ignore*/ } +^#[ \t]*include[ \t][<"][^\n">]*[>"] { + if(look_for_includes==1) { + char *p; + char *file; + char *str = g_strdup(yytext); + file = strchr(str,'"'); + if(!file) file = strchr(str,'<'); + file++; + p = strchr(file,'"'); + if(!p) p = strchr(file,'>'); + *p = '\0'; + include_files = g_list_prepend(include_files,g_strdup(file)); + g_free(str); + } + REJECT; +} + \/\/.*$ { add_to_cbuf(yytext); /*comment, ignore*/ } \/\/.*$ { ; /*comment, ignore*/ } \/\/.*$ { ; /*comment, ignore*/ } @@ -112,11 +134,15 @@ add_to_cbuf(char *s) header_c = FALSE; clear_cbuf(); ccode_line = line_no; + if(look_for_includes==0) + look_for_includes=1; } ^\%\} { BEGIN(INITIAL); yylval.cbuf = cbuf; cbuf = NULL; + if(look_for_includes==1) + look_for_includes=0; if(header_c) return HCODE; else @@ -164,6 +190,7 @@ add_to_cbuf(char *s) \n { add_to_cbuf(yytext); } class { + look_for_includes = 2; BEGIN(CLASS_CODE); return CLASS; } @@ -218,6 +245,11 @@ class { return TOKEN; } +(\[[0-9]*\])+ { + yylval.id = g_strdup(yytext); + return ARRAY_DIM; + } + \{ { BEGIN(CLASS_CODE_I); return '{'; @@ -226,8 +258,9 @@ class { BEGIN(C_CODE); parenth_depth=1; class_after_c = TRUE; - ccode_line = line_no; yylval.line = line_no; + clear_cbuf(); + ccode_line = line_no; return '{'; } \} {