Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ langugae only The first phase of compilation is called scanning or lexical analysis. This phase interprets the input program as a sequence of characters

C++ langugae only

The first phase of compilation is called scanning or lexical analysis. This phase interprets the input program as a sequence of characters and produces a sequence of tokens, which will be used by the parser.

Your job is to write (in C++) a simple scanner for source code that obeys the language described below. You may assume that the input is syntactically correct.

Your program simply needs to read each token and then print out what type it is, based on the following language rules:

keyword -> if | then | else | begin | end | function | return identifier -> character | character identifier integer -> digit | digit integer real -> integer.integer

special -> + | - | = | < | > digit -> 0|1|2|3|4|5|6|7|8|9 character -> a|b|c ... |z|A|B|C ... |Z

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

4. What action should Cherita Howard take and why?

Answered: 1 week ago