Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Statement Python Program You are to develop a simple lexical analyzer in python. Your analyzer should store a stream of lexemes in a list.

image text in transcribed

Problem Statement Python Program You are to develop a simple lexical analyzer in python. Your analyzer should store a stream of lexemes in a list. A lexeme consists of a token category and the actual text. Your program will: .Open a single text input file . Scan the file, line by line, to produce the token stream o For each line, display to the screen, the token-typelist -Ex: Line 3: A1A2 345; - Would produce a line of output like: 3: IDENT, ASSIGNOP,IDENT, MULTOP, INT, TERM o If there is an error on a line, note the line number ( & error message to the screen) and skip on to the next line .Produce a symbol table that stores each Identifier and a list of the lines on which that particular Identifier appears gnore white space between tokens. Although, whitespace is not required. A1 A1 345; is the same as - A1-A1 345; Write an output file that contains a copy of the symbol table (Sort the identifiers in alphabetic/alphanumeric order) Your lexical analyzer must recognize the following categories of token: o (IDENT) Identifiers: start with a letter, followed by any combination of letters and digits o (INT) Integers: any sequence of digits o (MULTOP) Multiplication operator ,/ o (ADDOP) Addition operators (ASSIGNOP) Assignment operators?+-,--, *-, /- (TERM) Terminator symbol; o Other symbols not listed would be errors because they would be unrecognized

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago