* src/SDCCcse.c (cseBBlock): retain assignment to self when volatile
[fw/sdcc] / src / SDCC.lex
index 3564dd7936beac2a4f0b74340f2275da8ffd9b30..43074e9d810e42152ffc5a08e5b3a05bfccaa7ae 100644 (file)
@@ -114,6 +114,8 @@ static int checkCurrFile(char *s);
 "near"         { count(); TKEYWORD(DATA); }
 "pdata"        { count(); TKEYWORD(PDATA); }
 "reentrant"    { count(); TKEYWORD(REENTRANT); }
+"shadowregs"   { count(); TKEYWORD(SHADOWREGS); }
+"wparam"       { count(); TKEYWORD(WPARAM); }
 "register"     { count(); return(REGISTER); }
 "return"       { count(); return(RETURN); }
 "sfr"          { count(); TKEYWORD(SFR); }
@@ -140,8 +142,8 @@ static int checkCurrFile(char *s);
 "_overlay"     { count(); TKEYWORD(OVERLAY); }
 {L}({L}|{D})*  { count(); return(check_type()); }
 0[xX]{H}+{IS}? { count(); yylval.val = constVal(yytext); return(CONSTANT); }
-0{D}+{IS}?     { count(); yylval.val = constVal(yytext); return(CONSTANT); }
-{D}+{IS}?      { count(); yylval.val = constVal(yytext); return(CONSTANT); }
+0[0-7]*{IS}?     { count(); yylval.val = constVal(yytext); return(CONSTANT); }
+[1-9]{D}*{IS}?      { count(); yylval.val = constVal(yytext); return(CONSTANT); }
 '(\\.|[^\\'])+' { count();yylval.val = charVal (yytext); return(CONSTANT); /* ' make syntax highliter happy */ }
 {D}+{E}{FS}?   { count(); yylval.val = constFloatVal(yytext);return(CONSTANT); }
 {D}*"."{D}+({E})?{FS}?  { count(); yylval.val = constFloatVal(yytext);return(CONSTANT); }
@@ -428,6 +430,7 @@ enum pragma_id {
 
 STACK_DCL(options_stack, struct options *, SAVE_RESTORE_SIZE)
 STACK_DCL(optimize_stack, struct optimize *, SAVE_RESTORE_SIZE)
+STACK_DCL(SDCCERRG_stack, struct SDCCERRG *, SAVE_RESTORE_SIZE)
 
 /*
  * cloneXxx functions should be updated every time a new set is
@@ -456,7 +459,7 @@ static struct optimize *cloneOptimize(struct optimize *opt)
 {
   struct optimize *new_opt;
 
-  new_opt = Safe_malloc(sizeof (struct options));
+  new_opt = Safe_malloc(sizeof (struct optimize));
 
   /* clone scalar values */
   *new_opt = *opt;
@@ -464,6 +467,18 @@ static struct optimize *cloneOptimize(struct optimize *opt)
   return new_opt;
 }
 
+static struct SDCCERRG *cloneSDCCERRG (struct SDCCERRG *val)
+{
+  struct SDCCERRG *new_val;
+
+  new_val = Safe_malloc(sizeof (struct SDCCERRG));
+
+  /* clone scalar values */
+  *new_val = *val;
+
+  return new_val;
+}
+
 static void copyAndFreeOptions(struct options *dest, struct options *src)
 {
   /* delete dest sets */
@@ -472,7 +487,7 @@ static void copyAndFreeOptions(struct options *dest, struct options *src)
   /* not implemented yet: */
   /* deleteSet(&dest->olaysSet); */
 
-  /* dopy src to dest */
+  /* copy src to dest */
   *dest = *src;
 
   Safe_free(src);
@@ -480,7 +495,15 @@ static void copyAndFreeOptions(struct options *dest, struct options *src)
 
 static void copyAndFreeOptimize(struct optimize *dest, struct optimize *src)
 {
-  /* dopy src to dest */
+  /* copy src to dest */
+  *dest = *src;
+
+  Safe_free(src);
+}
+
+static void copyAndFreeSDCCERRG(struct SDCCERRG *dest, struct SDCCERRG *src)
+{
+  /* copy src to dest */
   *dest = *src;
 
   Safe_free(src);
@@ -495,6 +518,7 @@ static void doPragma(int op, char *cp)
     {
       STACK_PUSH(options_stack, cloneOptions(&options));
       STACK_PUSH(optimize_stack, cloneOptimize(&optimize));
+      STACK_PUSH(SDCCERRG_stack, cloneSDCCERRG(&_SDCCERRG));
     }
     break;
 
@@ -502,12 +526,16 @@ static void doPragma(int op, char *cp)
     {
       struct options *optionsp;
       struct optimize *optimizep;
+      struct SDCCERRG *sdccerrgp;
 
       optionsp = STACK_POP(options_stack);
       copyAndFreeOptions(&options, optionsp);
 
       optimizep = STACK_POP(optimize_stack);
       copyAndFreeOptimize(&optimize, optimizep);
+
+      sdccerrgp = STACK_POP(SDCCERRG_stack);
+      copyAndFreeSDCCERRG(&_SDCCERRG, sdccerrgp);
     }
     break;
 
@@ -541,6 +569,7 @@ static void doPragma(int op, char *cp)
 
   case P_LESSPEDANTIC:
     options.lessPedantic = 1;
+    setErrorLogLevel(ERROR_LEVEL_WARNING);
     break;
 
   case P_CALLEE_SAVES:
@@ -663,6 +692,10 @@ static int process_pragma(char *s)
   while ((!isspace(*s)) && (*s != '\n'))
     s++ ;
 
+  /* skip separating whitespace */
+  while (isspace(*s) && (*s != '\n'))
+    s++;
+
   /* First give the port a chance */
   if (port->process_pragma && !port->process_pragma(cp))
     return 0;
@@ -677,7 +710,7 @@ static int process_pragma(char *s)
           if (pragma_tbl[i].deprecated != 0)
             werror(W_DEPRECATED_PRAGMA, pragma_tbl[i].name);
 
-          doPragma(pragma_tbl[i].id, cp + len);
+          doPragma(pragma_tbl[i].id, s);
           return 0;
         }
     }