Question: % { #include #include #include #define INTEGER 1 #define STRING 2 #define IDENTIFIER 3 #define READ 4 #define PRINT 5 #define IF 6 #define THEN
#include
#include
#include
#define INTEGER
#define STRING
#define IDENTIFIER
#define READ
#define PRINT
#define IF
#define THEN
#define ELSE
#define DO
#define PROGRAM
#define END
#define GT
#define LT
#define EQ
"PROGRAM" return PROGRAM;
"INTEGER" return INTEGER;
"READ" return READ;
"PRINT" return PRINT;
IF return IF;
"THEN" return THEN;
"ELSE" return ELSE;
DO return DO;
"END" return END;
GT return GT;
LT return LT;
EQ return EQ;
yylval atoiyytext; return INTEGER;
az yylval strdupyytext; return IDENTIFIER;
yylval strdupyytext; return STRING;
return ;
return ;
return ;
return ;
return ;
return ;
return ;
Ignore new lines
t Ignore whitespaces
Ignore comments
printfUnrecognized token: s
yytext; exit;
int yywrap
return ;
Write a flex specification for the language of F using the lexical grammar.
the lexer.l file is already provided
Write your mainin a separate file FirstNameLastNameAc to test your lexer.
Prepare a Makefile to compile the specifications and generate the lexer.
Prepare a test input file FirstNameLastNameAnc that will test all the lexical rules that you have
coded.
Prepare a FirstNameLastNameApdf file explaining the working of your lexer and your design
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
