You are given a copy of “lex.h” from Programming Assignment 1, and a file called “tokensListing.cpp” as a driver program. DO NOT CHANGE neither “lex.h” nor “tokensListing.cpp”. Your implementation...

1 answer below »

You are given a copy of “lex.h” from Programming Assignment 1, and a file called “tokensListing.cpp” as a driver program.


DO NOT CHANGE neither “lex.h” nor “tokensListing.cpp”.


Your implementation should include the following in another file, called “RA5.cpp”:



  • The function


LexItem id_or_kw(const string& lexeme, int linenum);


id_or_kw () function accepts a reference to a string of a lexeme and a line number and returns a LexItem object. It searches for the lexeme in a directory that maps a string value of a keyword to its corresponding Token value, and it returns a LexItem object containing either the keyword Token if it is found, or the identifier token IDENT if not.



  • The overloaded operator function operator


ostream& operator


The operator




Note that the implementation of operator


Use the given driver program in “tokensListing.cpp” for testing your implementations. The driver program accepts two command line arguments, “-othertok” and “-idsonly”.


The “-othertok” flag is used to test your implementation of the overloaded operator






ucid pp222


password- Princep411$


since its auto grade tool you have to run there program make sure all cases successfully run in that tool. im attaching a video which navigate you which and where you have to run




CS 280 Spring 2022 Recitation Assignment 5 February 24, 2022 Due Date: Monday February 28, 2022, 23:59 Total Points: 5 You are given a copy of “lex.h” from Programming Assignment 1, and a file called “tokensListing.cpp” as a driver program. DO NOT CHANGE neither “lex.h” nor “tokensListing.cpp”. Your implementation should include the following in another file, called “RA5.cpp”: • The function LexItem id_or_kw(const string& lexeme, int linenum); id_or_kw () function accepts a reference to a string of a lexeme and a line number and returns a LexItem object. It searches for the lexeme in a directory that maps a string value of a keyword to its corresponding Token value, and it returns a LexItem object containing either the keyword Token if it is found, or the identifier token IDENT if not. • The overloaded operator function operator< for="" lexitem.="" ostream&=""><(ostream& out,="" const="" lexitem&="" tok);="" the=""><() function="" accepts="" a="" reference="" to="" an="" ostream="" object="" and="" a="" reference="" to="" a="" lexitem="" object,="" and="" returns="" a="" reference="" to="" the="" ostream="" object.="" the="">< function="" should="" print="" out="" the="" string="" value="" of="" the="" token="" in="" the="" tok="" object,="" followed="" by="" its="" lexeme="" and="" line="" number.="" note="" that="" the="" implementation="" of="">< function="" in="" ra5="" differs="" from="" its="" implementation="" in="" pa1.="" see="" the="" examples="" below="" for="" the="" output="" format.="" use="" the="" given="" driver="" program="" in="" “tokenslisting.cpp”="" for="" testing="" your="" implementations.="" the="" driver="" program="" accepts="" two="" command="" line="" arguments,="" “-othertok”="" and="" “-idsonly”.="" the="" “-othertok”="" flag="" is="" used="" to="" test="" your="" implementation="" of="" the="" overloaded="">< function="" only,="" and="" the="" “-idsonly”="" is="" used="" to="" test="" your="" implementation="" of="" both="" functions.="" see="" the="" details="" of="" the="" outputs="" for="" the="" examples="" in="" the="" slides.="" submission="" guidelines="" 1.1.="" please="" upload="" your="" ra5.cpp="" file="" to="" vocareum.="" the="" “lex.h”="" header="" file="" and="" “tokenslisting.cpp”="" driver="" program="" will="" be="" propagated="" to="" your="" work="" directory.="" 1.2.="" submissions="" after="" the="" due="" date="" are="" accepted="" with="" a="" fixed="" penalty="" of="" 25%.="" no="" submission="" is="" accepted="" after="" wednesday="" 11:59="" pm,="" march="" 2,="" 2021.="" grading="" table="" item="" points="" compiles="" successfully="" 1="" implementation="" of="" id_or_kw="" function="" 2="" implementation="" of="">< function 2 total 5 function="" 2="" total="">
Answered Same DayFeb 23, 2022

Answer To: You are given a copy of “lex.h” from Programming Assignment 1, and a file called “tokensListing.cpp”...

Pawan answered on Feb 24 2022
103 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here