]> git.draconx.ca Git - gob-dx.git/blobdiff - src/lexer.l
Release 0.92.2
[gob-dx.git] / src / lexer.l
index d80b927394a82931b20f8b5bfe534871c0e011ee..d896eb2f4b504e997ae87ab60081eb68b1da441c 100644 (file)
 
 #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;
                }
 
 <C_CODE>\'\{\'         { add_to_cbuf(yytext); }
@@ -195,6 +207,30 @@ class              {
                        return CLASS;
                }
 
+^[ \t]*requires[ \t]+[0-9]+\.[0-9]+\.[0-9]+[\t ]*$     {
+                       int maj = 0,min = 0,pl = 0;
+                       int rmaj = 0,rmin = 0,rpl = 0;
+                       char *p;
+                       
+                       sscanf(VERSION,"%d.%d.%d",&rmaj,&rmin,&rpl);
+                       p = strchr(yytext,'r');
+                       g_assert(p); /* we MUST have found it */
+                       sscanf(p,"requires %d.%d.%d",&maj,&min,&pl);
+                       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);
+                       }
+               }
+
 <CLASS_CODE,CLASS_CODE_I>class|this    {
                        if(for_cpp) {
                                char *s;