Question: I need help modifying my file scanner.l based on the instructions below. I DON't need C program.TIA ---------------------------------------- Scanner.l File ( MODIFY This): -------------------------------------- /*

I need help modifying my file "scanner.l" based on the instructions below. I DON't need C program.TIA

I need help modifying my file "scanner.l" based on the instructions below.

----------------------------------------

Scanner.l File ( MODIFY This):

--------------------------------------

/* Compiler Theory and Design Dr. Duane J. Jarc */

/* This file contains flex input file */

%{ #include #include

using namespace std;

#include "listing.h" #include "tokens.h"

%}

%option noyywrap

ws [ \t ]+ comment \-\-.* line [ ] id [A-Za-z][A-Za-z0-9]* digit [0-9] int {digit}+ punc [\(\),:;] %%

{ws} { ECHO; } {comment} { ECHO; nextLine();} {line} { ECHO; nextLine();} "

int main() { firstLine(); FILE *file = fopen("lexemes.txt", "wa"); int token = yylex(); while (token) { fprintf(file, "%d %s ", token, yytext); token = yylex(); } lastLine(); fclose(file); return 0; }

---------------------------------------

The first project involves modifying the attached lexical analyzer and the compilation listing generator code. You need to make the following modifications to the lexical analyzer, scanner.1: rem. 1. A new token ARROW should be added for the two character punctuation symbol -> 2. The following reserved words should be added: case, else, endcase, endis, is, others, real, then, when Each reserved words should be a separate token. The token name should be the same as the lexeme, but in all upper case. 3. Two additional logical operators should be added. The lexeme for the first should be or and its token should be OROP. The second logical operator added should be not and its token should be NOTOP. 4. Five relational operators should be added. They are -/-->> and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!