Закрыт

implementing a Type checker for AST -- 2

In Java, write a type-checker for the language specified by the CFG below, with initial variable E:

E → INT  |  ID  |  (E BINOP E)

| E COMP E  |  BLOCK  |  ID := E

| if E then BLOCK else BLOCK

| while E do BLOCK

| repeat BLOCK until E

BLOCK → { ENE }

ENE → E  |  E; ENE

COMP → ==  |  <  |  >  |  <=  |  >=

BINOP → +  |  −  |  *  |  /

ID → (an identifier)

INT → (an integer)

The type-checker is not responsible for constructing an AST for an expression as above, but may take it as input. It is also not responsible for checking that variables are well-defined where they occur: it is allowed to assume that any variable it encounters is well-defined, and has type Int. Your type-checker should assign types as follows:

It should assign Int to any identifier, integer, or arithmetic expression on values of type Int;

It should assign Bool to any comparison between values of type Int;

It should assign Unit to any if statement or any loop, or to any assignment to an identifier;

It should assign to any BLOCK, the type of the last expression within that BLOCK.

The type-checker should produce a String as output, containing the value "Int", "Bool", or "Unit", as appropriate. The type-checker should throw a TCException if it encounters any of the following:

an expression which either involves comparisons / operations / assignments in which one arguments does not have type Int;

a conditional / loop with a condition which is not of type Bool;

a conditional / loop with a BLOCK expression which is not of type Unit.

In the tests that it will be checks against, it should always terminate correctly or throw a TCException; in particular, it should not simply abort if it encounters some other problem.

Навыки: Java

Показать больше: java write class text file, java write bmi calculator, connect board java write game code, java multi language website, encapsulation java bangla language, java write gui program java, java write games, java write file ppm format example, java write instance file ppm format, swedish write language, linux java write utf file, java write java face detection proggram, java write article market partner, library management system java programming language, java write simple image photo editor, java write log text file, java write pgp encrypted file sample, java code language transliteration, java modeling language

О работодателе:
( 13 отзыв(-а, -ов) ) Ma On Shan, Hong Kong

ID проекта: #30944701

3 фрилансеров(-а) готовы выполнить эту работу в среднем за $1217

vineetmishra82

Hi, I start on this and finish ASAP. I am a Java with Spring /Spring Boot, C, C++,.Net,C#, Python, Trainer & Web Developer(HTML,CSS,BootStrap, JS,Angular,ASP.Net,Django) for more than 7 years and have completed lot o Больше

$650 HKD за 1 день
(10 отзывов(-а))
4.6
mlobovic

Hi Nice to meet you. I have read your job carefully and I'm very confident about your job. As a talented application developer, I have much experience with JAVA for more than 10+ years. If you give me a chance to chat Больше

$1000 HKD за 3 дней(-я)
(3 отзывов(-а))
2.4
denpopov

Hello I am a java expert and confident in java language. I can solve your problem. Let's discuss more details. Hope to hear from you. thanks.

$2000 HKD за 7 дней(-я)
(0 отзывов(-а))
0.0