Answered step by step
Verified Expert Solution
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.
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
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