Encerrado

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 = 1.25;

The output: KEYWORD(int) IDENT (abcd) ASSIGN_OP (=) FLOAT_LIT (1.25) SEMICOLON(;)

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

If the input is: float abcd = 090.90;

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: @

Habilidades: Java

Ver mais: using regular expressions in java, using regular expressions, using expressions, use regular expressions, unix programming language, tutorial string, tutorial regular expressions, tutorial programming, tutorial numbers, tutorial in programming, tutorial for programming, the string problem, the java programming language, the assignment problem, string tutorial in c, string tutorial, string problem, string in c tutorial, software design patterns tutorial, regular tutorial, regular expressions tutorial, regular expressions list, regular expressions java tutorial, regular expressions in c, regular expressions example

Acerca do Empregador:
( 0 comentários ) Faisalabad, Pakistan

ID do Projeto: #14119

1 freelancer está ofertando em média $100 para este trabalho

bid5

we could do it.

$100 USD in 5 dias
(0 Comentários)
0.0