compiler/libec: (#307, #70) Warning on undeclared class; Overriding namespaces
[sdk] / compiler / libec / src / lexer.l
index 1ccf586..12fadae 100644 (file)
@@ -2,10 +2,13 @@ D         [0-9]
 L         [a-zA-Z_]
 H         [a-fA-F0-9]
 E         [Ee][+-]?{D}+
+P         [Pp][+-]?{D}+
 FS         (f|F|l|L|i|I|j|J)*
 IS         (u|U|l|L|i|I|j|J)*
 IDENT    {L}({L}|{D})*
 
+%option nounput
+
 %{
 import "ecdefs"
 #define YYLTYPE Location
@@ -47,7 +50,7 @@ void TESTTTT()
 YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
 File fileStack[MAX_INCLUDE_DEPTH];
 char sourceFileStack[MAX_INCLUDE_DEPTH][MAX_LOCATION];
-public void SetSomeSourceFileStack(char * fileName, int index) { strcpy(sourceFileStack[index], fileName); }
+public void SetSomeSourceFileStack(const char * fileName, int index) { strcpy(sourceFileStack[index], fileName); }
 YYLTYPE locStack[MAX_INCLUDE_DEPTH];
 AccessMode declModeStack[MAX_INCLUDE_DEPTH];
 int include_stack_ptr = 0;
@@ -178,7 +181,7 @@ default:
 "_stdcall"                 { return(EXT_DECL); }
 "stdcall"                  { return(EXT_DECL); }
 "__restrict"               { return(EXT_DECL); }
-"__const"                  { return(EXT_DECL); }
+"__const"                  { return(CONST /*EXT_DECL*/); }
 "__restrict__"             { return(EXT_DECL); }
 "public"                   { return(PUBLIC); }
 "private"                  { return(PRIVATE); }
@@ -209,9 +212,14 @@ default:
 "dbindex"                  { return(DBINDEX); }
 "database_open"            { return(DATABASE_OPEN); }
 
-("::"|(({IDENT}"&"?"::")*)){IDENT}?    { return(check_type()); }     // {L}({L}|{D})*      { return(check_type()); }  // ("::"|(({IDENT}"::")*)){IDENT}  { return(check_type()); }     // {L}({L}|{D})*      { return(check_type()); }
+("::"?(({IDENT}"&"?"::")*)){IDENT}?    { return(check_type()); }     // {L}({L}|{D})*      { return(check_type()); }  // ("::"|(({IDENT}"::")*)){IDENT}  { return(check_type()); }     // {L}({L}|{D})*      { return(check_type()); }
 
 0[xX]{H}+{IS}?          { return(CONSTANT); }
+
+0[xX]{H}+{P}{FS}?    { return(CONSTANT); }
+0[xX]{H}*"."{H}+({P})?{FS}?    { return(CONSTANT); }
+0[xX]{H}+"."{H}*({P})?{FS}?    { return(CONSTANT); }
+
 0{D}+{IS}?              { return(CONSTANT); }
 {D}+{IS}?               { return(CONSTANT); }
 L?'(\\.|[^\\'])+'       { return(CONSTANT); }
@@ -220,7 +228,8 @@ L?'(\\.|[^\\'])+'       { return(CONSTANT); }
 {D}*"."{D}+({E})?{FS}?  { return(CONSTANT); }
 {D}+"."{D}*({E})?{FS}?  { return(CONSTANT); }
 
-L?\"(\\.|[^\\"])*\"     { return(STRING_LITERAL); }
+\"(\\.|[^\\"])*\"     { return(STRING_LITERAL); }
+L\"(\\.|[^\\"])*\"     { return(WIDE_STRING_LITERAL); }
 
 "..."       { return(ELLIPSIS); }
 ">>="       { return(RIGHT_ASSIGN); }
@@ -320,7 +329,7 @@ L?\"(\\.|[^\\"])*\"     { return(STRING_LITERAL); }
 
 private:
 
-yywrap()
+int yywrap()
 {
    return(1);
 }
@@ -361,7 +370,7 @@ int comment()
 
 int commentCPP()
 {
-   int c, last = 0;
+   int c; //, last = 0;
    for(;;)
    {
       c = input();
@@ -386,7 +395,7 @@ int commentCPP()
          yylloc.end.charPos++;
          yylloc.end.pos++;
       }
-      last = c;
+      //last = c;
    }
    yylloc.start = yylloc.end;
    return 0;
@@ -523,7 +532,7 @@ int preprocessor()
 
       if ( include_stack_ptr >= MAX_INCLUDE_DEPTH )
       {
-         fprintf( stderr, $"Includes nested too deeply" );
+         fprintf( stderr, "%s", $"Includes nested too deeply" );
          exit( 1 );
       }
 
@@ -552,8 +561,6 @@ int preprocessor()
             yy_switch_to_buffer( yy_create_buffer( fileInput, YY_BUF_SIZE ) );
             BEGIN(INITIAL);
          }
-         else
-            printf("");
       }
    }
    return 0;