added code to print out positions of incorrect tokens

This commit is contained in:
Partho Bhattacharya
2025-02-21 15:25:21 -05:00
parent 0a806fd5ba
commit eb3452fec9
2 changed files with 6 additions and 1 deletions

View File

@ -81,6 +81,8 @@ SCHAR \\n|\\t|\\\"|[^\"\n\\]
{ID} {if(DEBUG) {printf( "ID: %s (%d)\n", yytext, ID);} else {return ID;}} {ID} {if(DEBUG) {printf( "ID: %s (%d)\n", yytext, ID);} else {return ID;}}
\n {line_number++; column_number = 1;} \n {line_number++; column_number = 1;}
. {column_number++;} \t {column_number++;}
" " {column_number++;}
. {column_number++; return 1999;}
%% %%

View File

@ -79,6 +79,9 @@ int run(FILE *alpha) {
} }
continue; continue;
} }
if(token == 1999){
printf("On line number %d and column number %d we have an invalid character:%s\n",line_number,column_number,yytext);
}
column_number += yyleng; column_number += yyleng;
} }