Question: Update Lexer.flex and generate Lexer.java that returns tokens for mini - C compiler to Parser.java. You can print comments, white spaces, and new lines on

Update Lexer.flex and generate Lexer.java that returns tokens for mini-C compiler to Parser.java. You can print comments, white spaces, and new lines on the console in Lexer.java; Update Parser.java that prints tokens returned by Lexer on the console in a form explained in the next page; You can add extra java programs if you need them. During the lexical analyzing process, your lexer should handle the compiler directive properly: your lexer should replace all lexemes defined by #define into their corresponding other lexemes and then should return their corresponding tokens Followings list a part (or modified) of keywords and symbols of the mini-C language, which will be used in this project:
keywords: "print", "func", "var", "void", "bool", "int", "float", "struct", "size",
"new", "if", "else", "while", "return", "break", "continue", "true", "false",
"begin", "end", "addr", "value", "then"
symbols: "(",")","[","]",";",",",".",":=","::"
operator keywords/symbols: "+","-","*","/", "and", "or", "not"
relative-operator symbols: "=","<>","<",">","<=",">="
The followings describe patterns of integer, real number, identifier, comment, newline, and whitespace:
int -> positive integers.
float -> positive real numbers except for integers, which have fractional parts but not exponential parts.
-> It can be 12.3,2.0,00.000, etc., but not 10. or .10 or 1.10E1.
identifier -> C language identifier. It can start with a lowercase letter or a capital letter but not with _.
comment ->"//".*, a string that starts with // and ends at the end of line
block comment ->"/*[^]*"*/", a string including newlines that starts with /* and ends with */.
newline ->
whitespace ->[\t\r]+
Output:
<>
<>
<>
//* hello
/*+4 ;
c := a + b; // hello
d := b */
<>
Success!

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!