Answered step by step
Verified Expert Solution
Question
1 Approved Answer
code should be in C++ Language Write a scanner/lexical analyzer for MYC. You may write the program in C++ or in Java. Input to the
code should be in C++ Language
Write a scanner/lexical analyzer for MYC. You may write the program in C++ or in Java. Input to the Lexical Analyzer is obtained by getting input characters from the source provided by the instructor. You may create three different functions that (1) returns the next character from the input and moves the character pointer to the next character, (2) returns the next character without moving the pointer. (3) returns the second character without moving the pointer. These methods will help you to process input from the source file. These methods are optional and you may process the input the way that you prefer. The scanner returns a set of tokens or an error message. You may consider that a token object contains these following attributes: type is an integer (1..5) denoting the type of the token: OPTOK DELIMTOK KEYWORDTOK IDENTOK NUMTOK dataType is an integer that denotes the type of basic data: INT REAL. . Val contains the value of the token. You may save the value as a string. Later on you can convert it to your desired type based on its data type. Your scanner should have the ability to return tokens as requested by calling a function called getNextToken(). Note that your scanner shouldn't print any token on the screen if the program contains any errors. The output should be similar to the following: If the source file is the following: begin 1; while(* , Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started