Kapalı

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.

Beceriler: Java

Daha fazlasını gör: 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

İşveren Hakkında:
( 13 değerlendirme ) Ma On Shan, Hong Kong

Proje NO: #30944701

Bu iş için 3 freelancer ortalamada $1217 teklif veriyor

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 Daha Fazla

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% HKD
(10 Değerlendirme)
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 Daha Fazla

$1000 HKD in 3 gün içinde
(3 Değerlendirme)
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 in 7 gün içinde
(0 Değerlendirme)
0.0