Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IF some culd really help me with this i'd really appreciate it it's due today at 11 pm and i've tried everything but it's not

IF some culd really help me with this i'd really appreciate it it's due today at 11 pm and i've tried everything but it's not working. Objective: Build a compiler for Jack -- a modern, object-based, Java-like language. The compiler construction spans two projects: 10 (Syntax Analysis) and 11 (Code Generation). In this project we build a syntax analyzer that parses programs according to the Jack grammar, producing an XML file that reflects the program's structure. Resources: The main tool in this project is the programming language in which you will implement the syntax analyzer. You will also need the TextComparer utility (available in your tools directory, assuming that you've installed the TECS software suite), which allows comparing the output files generated by your analyzer to the compare files supplied by us. You may also want to inspect the generated and supplied output files using an XML viewer (any standard web browser should do the job). All the test files necessary for this project are available in project 10.zip. Start by creating a directory named projects/10 on your computer, then extract this file into it (preserving the directory structure embedded in the zip file). files in the zip are:

main txt file:

// This file is part of the materials accompanying the book

// "The Elements of Computing Systems" by Nisan and Schocken,

// MIT Press. Book site: www.idc.ac.il/tecs

// File name: projects/10/ArrayTest/Main.jack

/** Computes the average of a sequence of integers. */

class Main {

function void main() {

var Array a;

var int length;

var int i, sum;

let length = Keyboard.readInt("HOW MANY NUMBERS? ");

let a = Array.new(length);

let i = 0;

while (i < length) {

let a[i] = Keyboard.readInt("ENTER THE NEXT NUMBER: ");

let i = i + 1;

}

let i = 0;

let sum = 0;

while (i < length) {

let sum = sum + a[i];

let i = i + 1;

}

do Output.printString("THE AVERAGE IS: ");

do Output.printInt(sum / length);

do Output.println();

return;

}

}

and the other one;

main T:

-

class

Main

{

function

void

main

(

)

{

var

Array

a

;

var

int

length

;

var

int

i

,

sum

;

let

length

=

Keyboard

.

readInt

(

HOW MANY NUMBERS?

)

;

let

a

=

Array

.

new

(

length

)

;

let

i

=

0

;

while

(

i

<

length

)

{

let

a

[

i

]

=

Keyboard

.

readInt

(

ENTER THE NEXT NUMBER:

)

;

let

i

=

i

+

1

;

}

let

i

=

0

;

let

sum

=

0

;

while

(

i

<

length

)

{

let

sum

=

sum

+

a

[

i

]

;

let

i

=

i

+

1

;

}

do

Output

.

printString

(

THE AVERAGE IS:

)

;

do

Output

.

printInt

(

sum

/

length

)

;

do

Output

.

println

(

)

;

return

;

}

}

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_2

Step: 3

blur-text-image_3

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 3 Lnai 9286

Authors: Albert Bifet ,Michael May ,Bianca Zadrozny ,Ricard Gavalda ,Dino Pedreschi ,Francesco Bonchi ,Jaime Cardoso ,Myra Spiliopoulou

1st Edition

3319234609, 978-3319234601

More Books

Students also viewed these Databases questions

Question

Explain why social conflicts are often intractable.

Answered: 1 week ago