Question: Lexical analyzer How can i design and implement a lexical analyzer that recognizes the following tokens: , , , , , , , < parentheses>

Lexical analyzer

How can i design and implement a lexical analyzer that recognizes the following tokens:

, , , , , ,

,< parentheses> , < braces > , < letter > , < digit> , < identifier>,< num> , < array>

< compound stmt> : : = { }

: : =

: : = if ()

The input for the lexical analyzer is a text file SOURCE.TXT consisting of several lines of text (a program) containing sequences of lexemes corresponding to the above definitions, whitespaces and comments. The input program can be incorrect so your lexical analyzer should generate error messages indicating the line(s) of these errors. The output of your lexical analyzer consists of 2 text files ST.TXT and TOKENS.TXT. 1. ST.TXT is the symbol table created by the lexical analyzer. Each line consists of three parts: line number the lexeme (string) type (string) ,being one of the following : keyword, identifier, num 2. TOKENS.TXT is the list of tokens produced by the lexical analyzer with the following structure: one line of input (in the order of appearance in SOURCE.TXT) corresponding pairs token, attribute, each in separate line in the order as they occur in the line blank line The attribute of keyword, identifier or a number is the line number in the symbol table. The attribute of any other token is lexeme itself. The longest prefix of the input that can match any regular expression pi is taken as the next token. how can i do this?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!