X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCC.lex;h=b67cda3da8f7c1fd7747e2eb381e20574cea6955;hb=6b5e433931b8b1ba61bb6c694f74f42f48c3acf5;hp=4eddd3ee77a507cd4513327bcce86108b9577e48;hpb=5df1b9a579235d42fcec8a8884808334ed99a246;p=fw%2Fsdcc diff --git a/src/SDCC.lex b/src/SDCC.lex index 4eddd3ee..b67cda3d 100644 --- a/src/SDCC.lex +++ b/src/SDCC.lex @@ -76,7 +76,8 @@ struct options save_options ; P_NOGCSE , P_CALLEE_SAVES, P_EXCLUDE , - P_LOOPREV + P_LOOPREV , + P_OVERLAY }; %} @@ -84,14 +85,14 @@ struct options save_options ; %% "_asm" { count(); - asmp = asmbuff = Safe_realloc (asmbuff, INITIAL_INLINEASM); + asmp = asmbuff = realloc (asmbuff, INITIAL_INLINEASM); asmbuffSize=INITIAL_INLINEASM; BEGIN(asm) ; } "_endasm" { count(); *asmp = '\0'; - yylval.yyinline = Safe_alloc (strlen(asmbuff)+1); + yylval.yyinline = malloc (strlen(asmbuff)+1); strcpy(yylval.yyinline,asmbuff); BEGIN(INITIAL); return (INLINEASM); @@ -101,7 +102,7 @@ struct options save_options ; // increase the buffersize with 50% int size=asmp-asmbuff; asmbuffSize=asmbuffSize*3/2; - asmbuff = Safe_realloc (asmbuff, asmbuffSize); + asmbuff = realloc (asmbuff, asmbuffSize); asmp=asmbuff+size; } *asmp++ = yytext[0]; @@ -112,7 +113,7 @@ struct options save_options ; // increase the buffersize with 50% int size=asmp-asmbuff; asmbuffSize=asmbuffSize*3/2; - asmbuff = Safe_realloc (asmbuff, asmbuffSize); + asmbuff = realloc (asmbuff, asmbuffSize); asmp=asmbuff+size; } *asmp++ = '\n' ; @@ -171,11 +172,14 @@ struct options save_options ; "while" { count(); return(WHILE); } "xdata" { count(); TKEYWORD(XDATA); } "..." { count(); return(VAR_ARGS);} +"__typeof" { count(); return TYPEOF;} +"_JavaNative" { count(); TKEYWORD(JAVANATIVE);} +"_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); } -'(\\.|[^\\'])+' { count();yylval.val = charVal (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); } {D}+"."{D}*({E})?{FS}? { count(); yylval.val = constFloatVal(yytext);return(CONSTANT); } @@ -243,7 +247,7 @@ struct options save_options ; } . { count() ; } %% - + int checkCurrFile ( char *s) { char lineNum[10] ; @@ -288,7 +292,7 @@ int checkCurrFile ( char *s) /* mark the end of the filename */ while (*s != '"') s++; *s = '\0'; - currFname = Safe_alloc (strlen(sb)+1); + currFname = malloc (strlen(sb)+1); strcpy(currFname,sb); lineno = yylineno = lNum; } @@ -447,15 +451,17 @@ void doPragma (int op, char *cp) /* append to the functions already listed in callee-saves */ for (; options.calleeSaves[i] ;i++); - parseWithComma(&options.calleeSaves[i],strdup(cp)); + parseWithComma(&options.calleeSaves[i], Safe_strdup(cp)); } break; case P_EXCLUDE: - parseWithComma(options.excludeRegs,strdup(cp)); + parseWithComma(options.excludeRegs, Safe_strdup(cp)); break; case P_LOOPREV: optimize.noLoopReverse = 1; break; + case P_OVERLAY: + break; /* notyet */ } } @@ -567,10 +573,13 @@ 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++; + if (yylineno && filename) { + fprintf(stdout,"\n%s:%d: %s: token -> '%s' ; column %d\n", + filename,yylineno, + s,yytext,column); + fatalError++; + } else { + // this comes from an empy file, no problem + } return 0; }