Question: write using LEX AND YACC write using LEX AND YACC Design and implement a lexical analyzer that recognizes the following tokens: num :;s 011213141516171819 letter>

write using LEX AND YACC  write using LEX AND YACC write using LEX AND YACC Design
write using LEX AND YACC

Design and implement a lexical analyzer that recognizes the following tokens: num :;s 011213141516171819 letter> ( I )* cdigit+(. digit+?(E(+1-Jdigit+)? V : := array : : estmt stmtb stmtb estmt stmt stmt> stmtb estmt stmt { | end :if (cexpr>) ::#while ( : do while (expr>) :case : : = switch ( ) : : break ; I continue ; ::retum cexpr cfor_stmt> cfor stmt> cassignstmt ccondition> expr :for(assign_stmt>; :cassign stmt>) cterm> 1 / term> cliteral> : : = | ( [digit>]. 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. Design and implement a lexical analyzer that recognizes the following tokens: num :;s 011213141516171819 letter> ( I )* cdigit+(. digit+?(E(+1-Jdigit+)? V : := array : : estmt stmtb stmtb estmt stmt stmt> stmtb estmt stmt { | end :if (cexpr>) ::#while ( : do while (expr>) :case : : = switch ( ) : : break ; I continue ; ::retum cexpr cfor_stmt> cfor stmt> cassignstmt ccondition> expr :for(assign_stmt>; :cassign stmt>) cterm> 1 / term> cliteral> : : = | ( [digit>]. 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

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!