Question
Write your program in C++. In this programming project, you will get your compiler to a great start by implementing the lexical analysis phase. For
Write your program in C++. In this programming project, you will get your compiler to a great start by implementing the lexical analysis phase. For the first task of the front-end, you will develop a scanner for the Decaf 19 programming language. Your scanner will run through the source program, recognizing Decaf tokens in the order in which they are read, until end-of-file is reached. For each token, your scanner will record its attributes appropriately (this will eventually be used by other components of your compiler) so that information about each token will be properly printed. Decaf shares many similarities with C++, although not all features exactly match. Our hope is that the familiar syntax will make things easier on you, but do be aware of the differences.
For the scanner, you are only concerned with being able to recognize and categorize the valid tokens from the input. Here is a summary of the token types in Decaf. The following are keywords. They are all reserved. void int double bool string null for while if else return break Print ReadInteger ReadLine An identier is a sequence of letters, digits, and underscores, starting with a letter. Decaf is case-sensitive, e.g., if is a keyword, but IF is an identier; binky and Binky are two distinct identiers.
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