X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/774037b15064dcc6e4995c0bba3b24abb1bde35f..e10d6e307623d0952f6e1f5d9fee8720ddab4808:/src/lexer.l diff --git a/src/lexer.l b/src/lexer.l index 392a636..d896eb2 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -26,13 +26,12 @@ #include "parse.h" #include "main.h" - -extern gboolean for_cpp; +#include "util.h" static int parenth_depth = 0; static int before_comment = INITIAL; -static int class_after_c = FALSE; -static int header_c = FALSE; +static gboolean class_after_c = FALSE; +static int code_type = CCODE; static GString *cbuf = NULL; int ccode_line = 1; @@ -119,11 +118,27 @@ add_to_cbuf(char *s) if(before_comment == C_CODE) add_to_cbuf(yytext); } -^\%h\{ { +^\%(ht|headertop)\{ { + BEGIN(C_CODE); + parenth_depth = 1; + class_after_c = FALSE; + code_type = HTCODE; + clear_cbuf(); + ccode_line = line_no; + } +^\%(ph|privateheader)\{ { BEGIN(C_CODE); parenth_depth = 1; class_after_c = FALSE; - header_c = TRUE; + code_type = PHCODE; + clear_cbuf(); + ccode_line = line_no; + } +^\%(h|header)\{ { + BEGIN(C_CODE); + parenth_depth = 1; + class_after_c = FALSE; + code_type = HCODE; clear_cbuf(); ccode_line = line_no; } @@ -131,7 +146,7 @@ add_to_cbuf(char *s) BEGIN(C_CODE); parenth_depth = 1; class_after_c = FALSE; - header_c = FALSE; + code_type = CCODE; clear_cbuf(); ccode_line = line_no; if(look_for_includes==0) @@ -143,10 +158,7 @@ add_to_cbuf(char *s) cbuf = NULL; if(look_for_includes==1) look_for_includes=0; - if(header_c) - return HCODE; - else - return CCODE; + return code_type; } \'\{\' { add_to_cbuf(yytext); }