Question: Scanner : % { #include #include int line _ num = 1 ; / / Track the current line number int char _ pos =
Scanner :
#include
#include
int linenum ; Track the current line number
int charpos ; Track the character position on the line
option noyywrap
DIGIT
LETTER AZaz
SYMBOL @
ID LETTERLETTERDIGITSYMBOLLETTERDIGIT
NUM DIGITDIGITDIGITEeDIGIT
DIGITDIGITEe
fprintfstderr "Error: Incomplete token at line d position d
linenum, charpos;
charpos yyleng;
DIGITDIGITEe
fprintfstderr "Error: Incomplete token at line d position d
linenum, charpos;
charpos yyleng;
ID#$&;:~
fprintfstderr "Error: Invalid character in identifier at line d position d
linenum, charpos;
charpos yyleng;
#$&;:~@ID
fprintfstderr "Error: Symbol at beginning of identifier at line d position d
linenum, charpos;
charpos yyleng;
IDprintfToken: ID Lexeme: s at line d position d
yytext, linenum, charpos;
NUMprintfToken: NUM, Lexeme: s at line d position d
yytext, linenum, charpos;
charpos yyleng;
fprintfstderr "Error: Unclosed comment at line d position d
linenum, charpos;exit;
linenum;charpos ;
tcharpos yyleng;
fprintfstderr "Error: Unknown character s at line d position d
yytext, linenum, charpos;
int mainvoid
yylex;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
