Suljettu

little Java Assignment

Write a lexical analyzer in Java according to the following description:

1. write a formal description of the token patterns of the language using java language related to regular expressions and use a software tool to automatically generate a lexical analyzer, e.g. the lex, which is included in UNIX

2. Design a state transition diagram that describes the token patterns of the language and write a program that implements the diagram

3. Design a state transition diagram that describes the token patterns of the language and hand-construct a table-driven implementation of the state diagram

Your analyzer should be able to recognize the following ADDITIONAL tokens and lexemes:

Tokens Lexeme

IDENT sum

ASSIGN_OP =

IDENT oldsum

SUBTRACT_OP -

IDENT value

DIVISION_OP /

INT_LIT 100

SEMICOLON ;

KEYWORD all the Java keywords (check the following URL: [url removed, login to view])

FLOAT_LIT all the floating numbers (in order to simplify the programming work, let us assume that all the floating numbers have the following format: [url removed, login to view], where each d is a digit, the first d can NOT be zero. Integers have the similar format ddddd, where d is a digit and the first d can NOT be zero)

MULTI_OP *

SUB_OP -

The input will be a string of characters and the output will be a list of token followed by lexeme. For example, if the intput is: int abcd = 9090;

The output should be: KEYWORD(int) IDENT (abcd) ASSIGN_OP (=) INT_LIT (9090) SEMICOLON(;)

If the input is: int abcd = [url removed, login to view];

The output: KEYWORD(int) IDENT (abcd) ASSIGN_OP (=) FLOAT_LIT ([url removed, login to view]) SEMICOLON(;)

Note: Although the input has type problem, it is the concern of this exercise.

If the input is: float abcd = [url removed, login to view];

You should output the following error message: incorrect floating number format

If the input is: int abcd = 09090;

You should output the following error message: incorrect integer format

If the input is: int abcd = @;

You should output the following error message: unrecognized character: @

Taidot: Java

Näytä lisää: using regular expressions java, using regular expressions, using expressions, unix programming language, tutorial numbers, string problem, software design patterns tutorial, regular tutorial, regular expressions tutorial, regular expressions list, regular expressions java tutorial, regular expressions example, programming patterns, programming diagram, programming design patterns, program java programming, number tutorial, java string regular expressions, java regular expressions tutorial, java regular expressions example, java programming tutorial, java programming program, java programming books, java design patterns, integer tutorial

About the Employer:
( 0 reviews ) Faisalabad, Pakistan

Projektin tunnus: #14119

1 freelanceria on tarjonnut keskimäärin 100 $ tähän työhön

bid5

we could do it.

100 $ USD 5 päivässä
(0 arvostelua)
0.0