Question: Using C#, implement a console application of the source code of a lexical analyzer (front.c) on page 166 in the textbook. Your console application should
Using C#, implement a console application of the source code of a lexical analyzer (front.c) on page 166 in the textbook. Your console application should receive an input (for example sum + 56/total) and give the similar output like on page 171.
convert C to C#






/ Function declarations / void addChar(); void getChar(); void getNonBlank(); int lex(); / Character classes */ \#define LETTER 0 \#define DIGIT 1 \#define UNKNOWN 99 / Token COdes / \#define INT_LIT 10 \#define IDENT 11 \#define ASSIGN_OP 20 \#define ADD_OP 21 \#define SUB_OP 22 \#define MULT_OP 23 \#define DIV_OP 24 \#define LEFT_PAREN 25 \#define RIGHT_PAREN 26 This code illustrates the relative simplicity of lexical analyzers. Of course, we have left out input buffering, as well as some other important details. Furthermore, we have dealt with a very small and simple input language. Consider the following expression: ( sum +47)/ total Following is the output of the lexical analyzer of front. c when used on this expression: Next token is: 25 Next lexeme is ( Next token is: 11 Next lexeme is sum Next token is: 21 Next lexeme is + Next token is: 10 Next lexeme is 47 Next token is: 26 Next lexeme is) Next token is: 24 Next lexeme is/ Next token is: 11 Next lexeme is total Next token is: -1 Next lexeme is EOF
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
