Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question #1 (25 Marks) Consider the below language specifications. Write a program to show token, token type, line no. and appropriate error message if there
Question #1 (25 Marks) Consider the below language specifications. Write a program to show token, token type, line no. and appropriate error message if there is any lexical error? Note: You need to firstly remove white spaces and comments from the program. A LEXICAL CONVENTIONS OF C- 1. The keywords of the language are the following: .... 18'dnt return vold while All keywords are reserved, and must be written in lowercase. 2. Special symbols are the following: DOR. 3. Other tokens are ID and NOM, defined by the following regular expressions: ID letter lettert NUM - digit digit. letter al.. Iza- digit - 01-19 Lower- and uppercase letters are distinct. 4. White space consists of blanks, newlines, and tabs. White space is ignored except that it must separate ID's, MUM's, and keywords 5. Comments are surrounded by the usual C notations /*...*1. Comments can be placed anywhere white space can appear (that is, comments cannot be placed within tokens) and may include more than one line. Comments may not be nested. Question #1 (25 Marks) Consider the below language specifications. Write a program to show token, token type, line no. and appropriate error message if there is any lexical error? Note: You need to firstly remove white spaces and comments from the program. A LEXICAL CONVENTIONS OF C- 1. The keywords of the language are the following: .... 18'dnt return vold while All keywords are reserved, and must be written in lowercase. 2. Special symbols are the following: DOR. 3. Other tokens are ID and NOM, defined by the following regular expressions: ID letter lettert NUM - digit digit. letter al.. Iza- digit - 01-19 Lower- and uppercase letters are distinct. 4. White space consists of blanks, newlines, and tabs. White space is ignored except that it must separate ID's, MUM's, and keywords 5. Comments are surrounded by the usual C notations /*...*1. Comments can be placed anywhere white space can appear (that is, comments cannot be placed within tokens) and may include more than one line. Comments may not be nested
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