Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Mini Java Compiler. Lexical Analyzer for a subset of the Java programming language This project consists of writing a Lexical Analyzer for a subset of

Mini Java Compiler.

Lexical Analyzer for a subset of the Java programming language

image text in transcribed

image text in transcribed

This project consists of writing a Lexical Analyzer for a subset of the Java programming language. The Lexical Analyzer is to be a module written in the high level language of your choice that exports the following: procedure GetNextToken global variables Token Lexeme Value ValueR Literal {for integer tokens} {for real tokens} {for quoted strings The following are the reserved words in the language (all are case sensitive): class, public, static, void, main, String, extends, return, int, boolean, if, else, while, System.out.println, length, true, false, this, new. The notation for specifying tokens is as follows: Comments begin with the symbol // and continue to the end of the line or are delimited by * and */ and may not be nested. Comments may appear after any token. Blanks between tokens are optional, with the exception of reserved words. Reserved words must be separated by blanks, newlines, the beginning of the program or the final semicolon. Token idt for identifiers matches a letter followed by letters, underscore and/or digits having a maximum length of 31 characters. Java identifiers are case sensitive. letter -> ['a'-'z','A'-'Z'l digit -> ['0-'9'] underscore ->'' idt -> letter(letter | digit | underscore )* Token numt matches unsigned integers or real numbers and has attribute Value for integers and ValueR for real numbers. digits -> digit digit* optional_fraction ->. digits & num -> digits optional_fraction String literals begin with a " and end with a " and should be stored in the literal variable. Strings must begin and end on the same line. The relational operators (Token relop) are: = =, !=, , >= The addop's are: +, -, and || The mulop's are: *,/, and &&. The assignop is: = The following symbols are also allowed in the language: ({}, ;.[1 A sample Java subset program looks like this: class factorial { public static void main(String[] a) { System.out.println(new Fac(.ComputeFac(10)); class Fac public int ComputeFac(int num) { int num_aux; if (num ['a'-'z','A'-'Z'l digit -> ['0-'9'] underscore ->'' idt -> letter(letter | digit | underscore )* Token numt matches unsigned integers or real numbers and has attribute Value for integers and ValueR for real numbers. digits -> digit digit* optional_fraction ->. digits & num -> digits optional_fraction String literals begin with a " and end with a " and should be stored in the literal variable. Strings must begin and end on the same line. The relational operators (Token relop) are: = =, !=, , >= The addop's are: +, -, and || The mulop's are: *,/, and &&. The assignop is: = The following symbols are also allowed in the language: ({}, ;.[1 A sample Java subset program looks like this: class factorial { public static void main(String[] a) { System.out.println(new Fac(.ComputeFac(10)); class Fac public int ComputeFac(int num) { int num_aux; if (num

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Why is it important to use ratios to analyze financial statements?

Answered: 1 week ago

Question

What are the most common types of program errors ( bugs ) ?

Answered: 1 week ago

Question

Determine miller indices of plane A Z a/2 X a/2 a/2 Y

Answered: 1 week ago