aboutsummaryrefslogtreecommitdiff
path: root/projects/10/ArrayTest
diff options
context:
space:
mode:
Diffstat (limited to 'projects/10/ArrayTest')
-rw-r--r--projects/10/ArrayTest/Main.ast1
-rw-r--r--projects/10/ArrayTest/Main.jack38
-rw-r--r--projects/10/ArrayTest/Main.xml286
-rw-r--r--projects/10/ArrayTest/MainT.xml142
4 files changed, 0 insertions, 467 deletions
diff --git a/projects/10/ArrayTest/Main.ast b/projects/10/ArrayTest/Main.ast
deleted file mode 100644
index f8194cb..0000000
--- a/projects/10/ArrayTest/Main.ast
+++ /dev/null
@@ -1 +0,0 @@
-Right (JClass "Main" [] [JSubroutineDec (JSubroutineHeader "function" ("void","main") []) (JSubroutineBody [("Array","a"),("int","length"),("int","i"),("int","sum")] [JLetStatment (JVarId "length" Nothing) (JExpCall (JSubroutineCall "Keyboard" (Just "readInt") [JStrConst "HOW MANY NUMBERS? "])),JLetStatment (JVarId "a" Nothing) (JExpCall (JSubroutineCall "Array" (Just "new") [JExpVar (JVarId "length" Nothing)])),JLetStatment (JVarId "i" Nothing) (JIntConst 0),JWhileStatment (JExpBin (JExpVar (JVarId "i" Nothing)) [('<',JExpVar (JVarId "length" Nothing))]) [JLetStatment (JVarId "a" (Just (JExpVar (JVarId "i" Nothing)))) (JExpCall (JSubroutineCall "Keyboard" (Just "readInt") [JStrConst "ENTER THE NEXT NUMBER: "])),JLetStatment (JVarId "i" Nothing) (JExpBin (JExpVar (JVarId "i" Nothing)) [('+',JIntConst 1)])],JLetStatment (JVarId "i" Nothing) (JIntConst 0),JLetStatment (JVarId "sum" Nothing) (JIntConst 0),JWhileStatment (JExpBin (JExpVar (JVarId "i" Nothing)) [('<',JExpVar (JVarId "length" Nothing))]) [JLetStatment (JVarId "sum" Nothing) (JExpBin (JExpVar (JVarId "sum" Nothing)) [('+',JExpVar (JVarId "a" (Just (JExpVar (JVarId "i" Nothing)))))]),JLetStatment (JVarId "i" Nothing) (JExpBin (JExpVar (JVarId "i" Nothing)) [('+',JIntConst 1)])],JDoStatement (JSubroutineCall "Output" (Just "printString") [JStrConst "THE AVERAGE IS: "]),JDoStatement (JSubroutineCall "Output" (Just "printInt") [JExpBin (JExpVar (JVarId "sum" Nothing)) [('/',JExpVar (JVarId "length" Nothing))]]),JDoStatement (JSubroutineCall "Output" (Just "println") []),JReturnStatement Nothing])]) \ No newline at end of file
diff --git a/projects/10/ArrayTest/Main.jack b/projects/10/ArrayTest/Main.jack
deleted file mode 100644
index aa237b1..0000000
--- a/projects/10/ArrayTest/Main.jack
+++ /dev/null
@@ -1,38 +0,0 @@
-// This file is part of www.nand2tetris.org
-// and the book "The Elements of Computing Systems"
-// by Nisan and Schocken, MIT Press.
-// File name: projects/10/ArrayTest/Main.jack
-
-// (identical to projects/09/Average/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;
- }
-}
diff --git a/projects/10/ArrayTest/Main.xml b/projects/10/ArrayTest/Main.xml
deleted file mode 100644
index 0ea96df..0000000
--- a/projects/10/ArrayTest/Main.xml
+++ /dev/null
@@ -1,286 +0,0 @@
-<class>
- <keyword> class </keyword>
- <identifier> Main </identifier>
- <symbol> { </symbol>
- <subroutineDec>
- <keyword> function </keyword>
- <keyword> void </keyword>
- <identifier> main </identifier>
- <symbol> ( </symbol>
- <parameterList>
- </parameterList>
- <symbol> ) </symbol>
- <subroutineBody>
- <symbol> { </symbol>
- <varDec>
- <keyword> var </keyword>
- <identifier> Array </identifier>
- <identifier> a </identifier>
- <symbol> ; </symbol>
- </varDec>
- <varDec>
- <keyword> var </keyword>
- <keyword> int </keyword>
- <identifier> length </identifier>
- <symbol> ; </symbol>
- </varDec>
- <varDec>
- <keyword> var </keyword>
- <keyword> int </keyword>
- <identifier> i </identifier>
- <symbol> , </symbol>
- <identifier> sum </identifier>
- <symbol> ; </symbol>
- </varDec>
- <statements>
- <letStatement>
- <keyword> let </keyword>
- <identifier> length </identifier>
- <symbol> = </symbol>
- <expression>
- <term>
- <identifier> Keyboard </identifier>
- <symbol> . </symbol>
- <identifier> readInt </identifier>
- <symbol> ( </symbol>
- <expressionList>
- <expression>
- <term>
- <stringConstant> HOW MANY NUMBERS? </stringConstant>
- </term>
- </expression>
- </expressionList>
- <symbol> ) </symbol>
- </term>
- </expression>
- <symbol> ; </symbol>
- </letStatement>
- <letStatement>
- <keyword> let </keyword>
- <identifier> a </identifier>
- <symbol> = </symbol>
- <expression>
- <term>
- <identifier> Array </identifier>
- <symbol> . </symbol>
- <identifier> new </identifier>
- <symbol> ( </symbol>
- <expressionList>
- <expression>
- <term>
- <identifier> length </identifier>
- </term>
- </expression>
- </expressionList>
- <symbol> ) </symbol>
- </term>
- </expression>
- <symbol> ; </symbol>
- </letStatement>
- <letStatement>
- <keyword> let </keyword>
- <identifier> i </identifier>
- <symbol> = </symbol>
- <expression>
- <term>
- <integerConstant> 0 </integerConstant>
- </term>
- </expression>
- <symbol> ; </symbol>
- </letStatement>
- <whileStatement>
- <keyword> while </keyword>
- <symbol> ( </symbol>
- <expression>
- <term>
- <identifier> i </identifier>
- </term>
- <symbol> &lt; </symbol>
- <term>
- <identifier> length </identifier>
- </term>
- </expression>
- <symbol> ) </symbol>
- <symbol> { </symbol>
- <statements>
- <letStatement>
- <keyword> let </keyword>
- <identifier> a </identifier>
- <symbol> [ </symbol>
- <expression>
- <term>
- <identifier> i </identifier>
- </term>
- </expression>
- <symbol> ] </symbol>
- <symbol> = </symbol>
- <expression>
- <term>
- <identifier> Keyboard </identifier>
- <symbol> . </symbol>
- <identifier> readInt </identifier>
- <symbol> ( </symbol>
- <expressionList>
- <expression>
- <term>
- <stringConstant> ENTER THE NEXT NUMBER: </stringConstant>
- </term>
- </expression>
- </expressionList>
- <symbol> ) </symbol>
- </term>
- </expression>
- <symbol> ; </symbol>
- </letStatement>
- <letStatement>
- <keyword> let </keyword>
- <identifier> i </identifier>
- <symbol> = </symbol>
- <expression>
- <term>
- <identifier> i </identifier>
- </term>
- <symbol> + </symbol>
- <term>
- <integerConstant> 1 </integerConstant>
- </term>
- </expression>
- <symbol> ; </symbol>
- </letStatement>
- </statements>
- <symbol> } </symbol>
- </whileStatement>
- <letStatement>
- <keyword> let </keyword>
- <identifier> i </identifier>
- <symbol> = </symbol>
- <expression>
- <term>
- <integerConstant> 0 </integerConstant>
- </term>
- </expression>
- <symbol> ; </symbol>
- </letStatement>
- <letStatement>
- <keyword> let </keyword>
- <identifier> sum </identifier>
- <symbol> = </symbol>
- <expression>
- <term>
- <integerConstant> 0 </integerConstant>
- </term>
- </expression>
- <symbol> ; </symbol>
- </letStatement>
- <whileStatement>
- <keyword> while </keyword>
- <symbol> ( </symbol>
- <expression>
- <term>
- <identifier> i </identifier>
- </term>
- <symbol> &lt; </symbol>
- <term>
- <identifier> length </identifier>
- </term>
- </expression>
- <symbol> ) </symbol>
- <symbol> { </symbol>
- <statements>
- <letStatement>
- <keyword> let </keyword>
- <identifier> sum </identifier>
- <symbol> = </symbol>
- <expression>
- <term>
- <identifier> sum </identifier>
- </term>
- <symbol> + </symbol>
- <term>
- <identifier> a </identifier>
- <symbol> [ </symbol>
- <expression>
- <term>
- <identifier> i </identifier>
- </term>
- </expression>
- <symbol> ] </symbol>
- </term>
- </expression>
- <symbol> ; </symbol>
- </letStatement>
- <letStatement>
- <keyword> let </keyword>
- <identifier> i </identifier>
- <symbol> = </symbol>
- <expression>
- <term>
- <identifier> i </identifier>
- </term>
- <symbol> + </symbol>
- <term>
- <integerConstant> 1 </integerConstant>
- </term>
- </expression>
- <symbol> ; </symbol>
- </letStatement>
- </statements>
- <symbol> } </symbol>
- </whileStatement>
- <doStatement>
- <keyword> do </keyword>
- <identifier> Output </identifier>
- <symbol> . </symbol>
- <identifier> printString </identifier>
- <symbol> ( </symbol>
- <expressionList>
- <expression>
- <term>
- <stringConstant> THE AVERAGE IS: </stringConstant>
- </term>
- </expression>
- </expressionList>
- <symbol> ) </symbol>
- <symbol> ; </symbol>
- </doStatement>
- <doStatement>
- <keyword> do </keyword>
- <identifier> Output </identifier>
- <symbol> . </symbol>
- <identifier> printInt </identifier>
- <symbol> ( </symbol>
- <expressionList>
- <expression>
- <term>
- <identifier> sum </identifier>
- </term>
- <symbol> / </symbol>
- <term>
- <identifier> length </identifier>
- </term>
- </expression>
- </expressionList>
- <symbol> ) </symbol>
- <symbol> ; </symbol>
- </doStatement>
- <doStatement>
- <keyword> do </keyword>
- <identifier> Output </identifier>
- <symbol> . </symbol>
- <identifier> println </identifier>
- <symbol> ( </symbol>
- <expressionList>
- </expressionList>
- <symbol> ) </symbol>
- <symbol> ; </symbol>
- </doStatement>
- <returnStatement>
- <keyword> return </keyword>
- <symbol> ; </symbol>
- </returnStatement>
- </statements>
- <symbol> } </symbol>
- </subroutineBody>
- </subroutineDec>
- <symbol> } </symbol>
-</class>
diff --git a/projects/10/ArrayTest/MainT.xml b/projects/10/ArrayTest/MainT.xml
deleted file mode 100644
index 68721ec..0000000
--- a/projects/10/ArrayTest/MainT.xml
+++ /dev/null
@@ -1,142 +0,0 @@
-<tokens>
-<keyword> class </keyword>
-<identifier> Main </identifier>
-<symbol> { </symbol>
-<keyword> function </keyword>
-<keyword> void </keyword>
-<identifier> main </identifier>
-<symbol> ( </symbol>
-<symbol> ) </symbol>
-<symbol> { </symbol>
-<keyword> var </keyword>
-<identifier> Array </identifier>
-<identifier> a </identifier>
-<symbol> ; </symbol>
-<keyword> var </keyword>
-<keyword> int </keyword>
-<identifier> length </identifier>
-<symbol> ; </symbol>
-<keyword> var </keyword>
-<keyword> int </keyword>
-<identifier> i </identifier>
-<symbol> , </symbol>
-<identifier> sum </identifier>
-<symbol> ; </symbol>
-<keyword> let </keyword>
-<identifier> length </identifier>
-<symbol> = </symbol>
-<identifier> Keyboard </identifier>
-<symbol> . </symbol>
-<identifier> readInt </identifier>
-<symbol> ( </symbol>
-<stringConstant> HOW MANY NUMBERS? </stringConstant>
-<symbol> ) </symbol>
-<symbol> ; </symbol>
-<keyword> let </keyword>
-<identifier> a </identifier>
-<symbol> = </symbol>
-<identifier> Array </identifier>
-<symbol> . </symbol>
-<identifier> new </identifier>
-<symbol> ( </symbol>
-<identifier> length </identifier>
-<symbol> ) </symbol>
-<symbol> ; </symbol>
-<keyword> let </keyword>
-<identifier> i </identifier>
-<symbol> = </symbol>
-<integerConstant> 0 </integerConstant>
-<symbol> ; </symbol>
-<keyword> while </keyword>
-<symbol> ( </symbol>
-<identifier> i </identifier>
-<symbol> &lt; </symbol>
-<identifier> length </identifier>
-<symbol> ) </symbol>
-<symbol> { </symbol>
-<keyword> let </keyword>
-<identifier> a </identifier>
-<symbol> [ </symbol>
-<identifier> i </identifier>
-<symbol> ] </symbol>
-<symbol> = </symbol>
-<identifier> Keyboard </identifier>
-<symbol> . </symbol>
-<identifier> readInt </identifier>
-<symbol> ( </symbol>
-<stringConstant> ENTER THE NEXT NUMBER: </stringConstant>
-<symbol> ) </symbol>
-<symbol> ; </symbol>
-<keyword> let </keyword>
-<identifier> i </identifier>
-<symbol> = </symbol>
-<identifier> i </identifier>
-<symbol> + </symbol>
-<integerConstant> 1 </integerConstant>
-<symbol> ; </symbol>
-<symbol> } </symbol>
-<keyword> let </keyword>
-<identifier> i </identifier>
-<symbol> = </symbol>
-<integerConstant> 0 </integerConstant>
-<symbol> ; </symbol>
-<keyword> let </keyword>
-<identifier> sum </identifier>
-<symbol> = </symbol>
-<integerConstant> 0 </integerConstant>
-<symbol> ; </symbol>
-<keyword> while </keyword>
-<symbol> ( </symbol>
-<identifier> i </identifier>
-<symbol> &lt; </symbol>
-<identifier> length </identifier>
-<symbol> ) </symbol>
-<symbol> { </symbol>
-<keyword> let </keyword>
-<identifier> sum </identifier>
-<symbol> = </symbol>
-<identifier> sum </identifier>
-<symbol> + </symbol>
-<identifier> a </identifier>
-<symbol> [ </symbol>
-<identifier> i </identifier>
-<symbol> ] </symbol>
-<symbol> ; </symbol>
-<keyword> let </keyword>
-<identifier> i </identifier>
-<symbol> = </symbol>
-<identifier> i </identifier>
-<symbol> + </symbol>
-<integerConstant> 1 </integerConstant>
-<symbol> ; </symbol>
-<symbol> } </symbol>
-<keyword> do </keyword>
-<identifier> Output </identifier>
-<symbol> . </symbol>
-<identifier> printString </identifier>
-<symbol> ( </symbol>
-<stringConstant> THE AVERAGE IS: </stringConstant>
-<symbol> ) </symbol>
-<symbol> ; </symbol>
-<keyword> do </keyword>
-<identifier> Output </identifier>
-<symbol> . </symbol>
-<identifier> printInt </identifier>
-<symbol> ( </symbol>
-<identifier> sum </identifier>
-<symbol> / </symbol>
-<identifier> length </identifier>
-<symbol> ) </symbol>
-<symbol> ; </symbol>
-<keyword> do </keyword>
-<identifier> Output </identifier>
-<symbol> . </symbol>
-<identifier> println </identifier>
-<symbol> ( </symbol>
-<symbol> ) </symbol>
-<symbol> ; </symbol>
-<keyword> return </keyword>
-<symbol> ; </symbol>
-<symbol> } </symbol>
-<symbol> } </symbol>
-</tokens>