X-Git-Url: http://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/a611f21fab136f64bbf979bd62b2fc6ecb62933c..40647d7b7b7fbeae828e0a032a3c3a5f204cdfa8:/src/lexer.l diff --git a/src/lexer.l b/src/lexer.l index aabc7ad..320e25b 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; }