Latest commit was incomplete
[fw/sdcc] / src / SDCC.lex
index 821cff05c1b0b8d7b10067561f4a0c3ed3d79fa6..b335a917aaf958af396969789c558046a5d9867b 100644 (file)
@@ -34,6 +34,7 @@ IS       (u|U|l|L)*
 #include <string.h>
 #include <ctype.h>
 #include "common.h"
+#include "newalloc.h"
     
 char *stringLiteral();
 char *currFname;
@@ -110,12 +111,15 @@ struct options  save_options  ;
 "far"          { count(); TKEYWORD(XDATA);  }
 "eeprom"       { count(); TKEYWORD(EEPROM);  }
 "float"        { count(); return(FLOAT); }
+"flash"        { count(); TKEYWORD(CODE);}
 "for"          { count(); return(FOR); }
 "goto"        { count(); return(GOTO); }
 "idata"        { count(); TKEYWORD(IDATA);}
 "if"           { count(); return(IF); }
 "int"          { count(); return(INT); }
 "interrupt"    { count(); return(INTERRUPT);}
+"nonbanked"    { count(); TKEYWORD(NONBANKED);}
+"banked"       { count(); TKEYWORD(BANKED);}
 "long"        { count(); return(LONG); }
 "near"        { count(); TKEYWORD(DATA);}
 "pdata"        { count(); TKEYWORD(PDATA); }
@@ -127,6 +131,7 @@ struct options  save_options  ;
 "short"        { count(); return(SHORT); }
 "signed"       { count(); return(SIGNED); }
 "sizeof"       { count(); return(SIZEOF); }
+"sram"         { count(); TKEYWORD(XDATA);}
 "static"       { count(); return(STATIC); }
 "struct"       { count(); return(STRUCT); }
 "switch"       { count(); return(SWITCH); }
@@ -141,8 +146,10 @@ struct options  save_options  ;
 "_data"               { count(); TKEYWORD(_NEAR); }
 "_code"               { count(); TKEYWORD(_CODE); }
 "_eeprom"      { count(); TKEYWORD(_EEPROM); }
+"_flash"       { count(); TKEYWORD(_CODE); }
 "_generic"     { count(); TKEYWORD(_GENERIC); }
 "_near"               { count(); TKEYWORD(_NEAR); }
+"_sram"        { count(); TKEYWORD(_XDATA);}
 "_xdata"       { count(); TKEYWORD(_XDATA);}
 "_pdata"       { count(); TKEYWORD(_PDATA); }
 "_idata"       { count(); TKEYWORD(_IDATA); }
@@ -256,7 +263,7 @@ int checkCurrFile ( char *s)
        /* mark the end of the filename */
        while (*s != '"') s++;
        *s = '\0';
-       ALLOC_ATOMIC(currFname,strlen(sb)+1);
+       currFname = Safe_calloc(1,strlen(sb)+1);
        strcpy(currFname,sb);
        yylineno = lNum - 2;
     }
@@ -431,6 +438,10 @@ int process_pragma(char *s)
           (*s != '\n')) 
        s++ ;    
 
+    /* First give the port a chance */
+    if (port->process_pragma && !port->process_pragma(cp))
+       return 0;
+
     /* now compare and do what needs to be done */
     if (strncmp(cp,PRAGMA_SAVE,strlen(PRAGMA_SAVE)) == 0) {
        doPragma(P_SAVE,cp+strlen(PRAGMA_SAVE));
@@ -511,3 +522,17 @@ int isTargetKeyword(char *s)
     
     return 0;
 }
+
+extern int fatalError;
+
+int yyerror(char *s)
+{
+   fflush(stdout);
+
+   if (yylineno && filename)
+       fprintf(stdout,"\n%s(%d) %s: token -> '%s' ; column %d\n",
+               filename,yylineno,
+               s,yytext,column);
+   fatalError++;
+   return 0;
+}