Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The objective of this assignment is to gain an understanding of the lexical analysis phase of a compiler and the process of constructing a symbol

image text in transcribed

The objective of this assignment is to gain an understanding of the lexical analysis phase of a compiler and the process of constructing a symbol table. Problem: 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. Write a program (in C, C++, C#, Java, or Python) that implements a simple scanner for a source file given as a command-line argument. The format of the tokens is described below. You may assume that the input is syntactically correct. Your program should build a symbol table which contains an entry for each token that was found in the input. When all the input has been read, your program should produce a summary report that includes a list of all the tokens that appeared in the input, the number of times each token appears in the input and the class of each token. Your program should also list how many times tokens of each class appeared in the input. The grammar for producing tokens is as follows: keyword::-if l then else | begin | end identifier -> character character identifier integer-digit I digit integer real ->integer.integer special-> ( 1 ) 1 [ 1 ] 1 + 1-1 = digit -> 0111213141516171819 character -> alblc . .. z|A|BIC |Z More details: Case is not used to distinguish keywords or identifiers. The delimiters are space, tab, newline, and the special characters The token classes that should be recognized are keyword, identifier, integer, real and special

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

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions