From d3a0cc3a8ba6dfeb64d3faeffdeb6845b60e5840 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sat, 20 Jan 2018 15:41:49 +0100 Subject: rearranged the dir for github - removed tools and pdfs - rearranged the projects dirs - added md files - other minor changes --- projects/10/ExpressionLessSquare/Main.ast | 1 - projects/10/ExpressionLessSquare/Main.jack | 36 - projects/10/ExpressionLessSquare/Main.xml | 205 ----- projects/10/ExpressionLessSquare/MainT.xml | 109 --- projects/10/ExpressionLessSquare/Square.ast | 1 - projects/10/ExpressionLessSquare/Square.jack | 99 --- projects/10/ExpressionLessSquare/Square.xml | 967 ----------------------- projects/10/ExpressionLessSquare/SquareGame.ast | 1 - projects/10/ExpressionLessSquare/SquareGame.jack | 60 -- projects/10/ExpressionLessSquare/SquareGame.xml | 544 ------------- projects/10/ExpressionLessSquare/SquareGameT.xml | 268 ------- projects/10/ExpressionLessSquare/SquareT.xml | 449 ----------- 12 files changed, 2740 deletions(-) delete mode 100644 projects/10/ExpressionLessSquare/Main.ast delete mode 100644 projects/10/ExpressionLessSquare/Main.jack delete mode 100644 projects/10/ExpressionLessSquare/Main.xml delete mode 100644 projects/10/ExpressionLessSquare/MainT.xml delete mode 100644 projects/10/ExpressionLessSquare/Square.ast delete mode 100644 projects/10/ExpressionLessSquare/Square.jack delete mode 100644 projects/10/ExpressionLessSquare/Square.xml delete mode 100644 projects/10/ExpressionLessSquare/SquareGame.ast delete mode 100644 projects/10/ExpressionLessSquare/SquareGame.jack delete mode 100644 projects/10/ExpressionLessSquare/SquareGame.xml delete mode 100644 projects/10/ExpressionLessSquare/SquareGameT.xml delete mode 100644 projects/10/ExpressionLessSquare/SquareT.xml (limited to 'projects/10/ExpressionLessSquare') diff --git a/projects/10/ExpressionLessSquare/Main.ast b/projects/10/ExpressionLessSquare/Main.ast deleted file mode 100644 index 57a44eb..0000000 --- a/projects/10/ExpressionLessSquare/Main.ast +++ /dev/null @@ -1 +0,0 @@ -Right (JClass "Main" [JClassVarDec "static" ("boolean","test")] [JSubroutineDec (JSubroutineHeader "function" ("void","main") []) (JSubroutineBody [("SquareGame","game")] [JLetStatment (JVarId "game" Nothing) (JExpVar (JVarId "game" Nothing)),JDoStatement (JSubroutineCall "game" (Just "run") []),JDoStatement (JSubroutineCall "game" (Just "dispose") []),JReturnStatement Nothing]),JSubroutineDec (JSubroutineHeader "function" ("void","test") []) (JSubroutineBody [("int","i"),("int","j"),("String","s"),("Array","a")] [JIfStatement (JExpVar (JVarId "i" Nothing)) [JLetStatment (JVarId "s" Nothing) (JExpVar (JVarId "i" Nothing)),JLetStatment (JVarId "s" Nothing) (JExpVar (JVarId "j" Nothing)),JLetStatment (JVarId "a" (Just (JExpVar (JVarId "i" Nothing)))) (JExpVar (JVarId "j" Nothing))] (Just [JLetStatment (JVarId "i" Nothing) (JExpVar (JVarId "i" Nothing)),JLetStatment (JVarId "j" Nothing) (JExpVar (JVarId "j" Nothing)),JLetStatment (JVarId "i" Nothing) (JExpBin (JExpVar (JVarId "i" Nothing)) [('|',JExpVar (JVarId "j" Nothing))])]),JReturnStatement Nothing])]) \ No newline at end of file diff --git a/projects/10/ExpressionLessSquare/Main.jack b/projects/10/ExpressionLessSquare/Main.jack deleted file mode 100644 index d2c5561..0000000 --- a/projects/10/ExpressionLessSquare/Main.jack +++ /dev/null @@ -1,36 +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/ExpressionLessSquare/Main.jack - -/** Expressionless version of projects/10/Square/Main.jack. */ - -class Main { - static boolean test; // Added for testing -- there is no static keyword - // in the Square files. - - function void main() { - var SquareGame game; - let game = game; - do game.run(); - do game.dispose(); - return; - } - - function void test() { // Added to test Jack syntax that is not use in - var int i, j; // the Square files. - var String s; - var Array a; - if (i) { - let s = i; - let s = j; - let a[i] = j; - } - else { // There is no else keyword in the Square files. - let i = i; - let j = j; - let i = i | j; - } - return; - } -} diff --git a/projects/10/ExpressionLessSquare/Main.xml b/projects/10/ExpressionLessSquare/Main.xml deleted file mode 100644 index 6beb694..0000000 --- a/projects/10/ExpressionLessSquare/Main.xml +++ /dev/null @@ -1,205 +0,0 @@ - - class - Main - { - - static - boolean - test - ; - - - function - void - main - ( - - - ) - - { - - var - SquareGame - game - ; - - - - let - game - = - - - game - - - ; - - - do - game - . - run - ( - - - ) - ; - - - do - game - . - dispose - ( - - - ) - ; - - - return - ; - - - } - - - - function - void - test - ( - - - ) - - { - - var - int - i - , - j - ; - - - var - String - s - ; - - - var - Array - a - ; - - - - if - ( - - - i - - - ) - { - - - let - s - = - - - i - - - ; - - - let - s - = - - - j - - - ; - - - let - a - [ - - - i - - - ] - = - - - j - - - ; - - - } - else - { - - - let - i - = - - - i - - - ; - - - let - j - = - - - j - - - ; - - - let - i - = - - - i - - | - - j - - - ; - - - } - - - return - ; - - - } - - - } - diff --git a/projects/10/ExpressionLessSquare/MainT.xml b/projects/10/ExpressionLessSquare/MainT.xml deleted file mode 100644 index f074ba4..0000000 --- a/projects/10/ExpressionLessSquare/MainT.xml +++ /dev/null @@ -1,109 +0,0 @@ - - class - Main - { - static - boolean - test - ; - function - void - main - ( - ) - { - var - SquareGame - game - ; - let - game - = - game - ; - do - game - . - run - ( - ) - ; - do - game - . - dispose - ( - ) - ; - return - ; - } - function - void - test - ( - ) - { - var - int - i - , - j - ; - var - String - s - ; - var - Array - a - ; - if - ( - i - ) - { - let - s - = - i - ; - let - s - = - j - ; - let - a - [ - i - ] - = - j - ; - } - else - { - let - i - = - i - ; - let - j - = - j - ; - let - i - = - i - | - j - ; - } - return - ; - } - } - diff --git a/projects/10/ExpressionLessSquare/Square.ast b/projects/10/ExpressionLessSquare/Square.ast deleted file mode 100644 index 884c695..0000000 --- a/projects/10/ExpressionLessSquare/Square.ast +++ /dev/null @@ -1 +0,0 @@ -Right (JClass "Square" [JClassVarDec "field" ("int","x"),JClassVarDec "field" ("int","y"),JClassVarDec "field" ("int","size")] [JSubroutineDec (JSubroutineHeader "constructor" ("Square","new") [("int","Ax"),("int","Ay"),("int","Asize")]) (JSubroutineBody [] [JLetStatment (JVarId "x" Nothing) (JExpVar (JVarId "Ax" Nothing)),JLetStatment (JVarId "y" Nothing) (JExpVar (JVarId "Ay" Nothing)),JLetStatment (JVarId "size" Nothing) (JExpVar (JVarId "Asize" Nothing)),JDoStatement (JSubroutineCall "draw" Nothing []),JReturnStatement (Just (JExpVar (JVarId "x" Nothing)))]),JSubroutineDec (JSubroutineHeader "method" ("void","dispose") []) (JSubroutineBody [] [JDoStatement (JSubroutineCall "Memory" (Just "deAlloc") [JKeywordConst "this"]),JReturnStatement Nothing]),JSubroutineDec (JSubroutineHeader "method" ("void","draw") []) (JSubroutineBody [] [JDoStatement (JSubroutineCall "Screen" (Just "setColor") [JExpVar (JVarId "x" Nothing)]),JDoStatement (JSubroutineCall "Screen" (Just "drawRectangle") [JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing),JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing)]),JReturnStatement Nothing]),JSubroutineDec (JSubroutineHeader "method" ("void","erase") []) (JSubroutineBody [] [JDoStatement (JSubroutineCall "Screen" (Just "setColor") [JExpVar (JVarId "x" Nothing)]),JDoStatement (JSubroutineCall "Screen" (Just "drawRectangle") [JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing),JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing)]),JReturnStatement Nothing]),JSubroutineDec (JSubroutineHeader "method" ("void","incSize") []) (JSubroutineBody [] [JIfStatement (JExpVar (JVarId "x" Nothing)) [JDoStatement (JSubroutineCall "erase" Nothing []),JLetStatment (JVarId "size" Nothing) (JExpVar (JVarId "size" Nothing)),JDoStatement (JSubroutineCall "draw" Nothing [])] Nothing,JReturnStatement Nothing]),JSubroutineDec (JSubroutineHeader "method" ("void","decSize") []) (JSubroutineBody [] [JIfStatement (JExpVar (JVarId "size" Nothing)) [JDoStatement (JSubroutineCall "erase" Nothing []),JLetStatment (JVarId "size" Nothing) (JExpVar (JVarId "size" Nothing)),JDoStatement (JSubroutineCall "draw" Nothing [])] Nothing,JReturnStatement Nothing]),JSubroutineDec (JSubroutineHeader "method" ("void","moveUp") []) (JSubroutineBody [] [JIfStatement (JExpVar (JVarId "y" Nothing)) [JDoStatement (JSubroutineCall "Screen" (Just "setColor") [JExpVar (JVarId "x" Nothing)]),JDoStatement (JSubroutineCall "Screen" (Just "drawRectangle") [JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing),JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing)]),JLetStatment (JVarId "y" Nothing) (JExpVar (JVarId "y" Nothing)),JDoStatement (JSubroutineCall "Screen" (Just "setColor") [JExpVar (JVarId "x" Nothing)]),JDoStatement (JSubroutineCall "Screen" (Just "drawRectangle") [JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing),JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing)])] Nothing,JReturnStatement Nothing]),JSubroutineDec (JSubroutineHeader "method" ("void","moveDown") []) (JSubroutineBody [] [JIfStatement (JExpVar (JVarId "y" Nothing)) [JDoStatement (JSubroutineCall "Screen" (Just "setColor") [JExpVar (JVarId "x" Nothing)]),JDoStatement (JSubroutineCall "Screen" (Just "drawRectangle") [JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing),JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing)]),JLetStatment (JVarId "y" Nothing) (JExpVar (JVarId "y" Nothing)),JDoStatement (JSubroutineCall "Screen" (Just "setColor") [JExpVar (JVarId "x" Nothing)]),JDoStatement (JSubroutineCall "Screen" (Just "drawRectangle") [JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing),JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing)])] Nothing,JReturnStatement Nothing]),JSubroutineDec (JSubroutineHeader "method" ("void","moveLeft") []) (JSubroutineBody [] [JIfStatement (JExpVar (JVarId "x" Nothing)) [JDoStatement (JSubroutineCall "Screen" (Just "setColor") [JExpVar (JVarId "x" Nothing)]),JDoStatement (JSubroutineCall "Screen" (Just "drawRectangle") [JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing),JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing)]),JLetStatment (JVarId "x" Nothing) (JExpVar (JVarId "x" Nothing)),JDoStatement (JSubroutineCall "Screen" (Just "setColor") [JExpVar (JVarId "x" Nothing)]),JDoStatement (JSubroutineCall "Screen" (Just "drawRectangle") [JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing),JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing)])] Nothing,JReturnStatement Nothing]),JSubroutineDec (JSubroutineHeader "method" ("void","moveRight") []) (JSubroutineBody [] [JIfStatement (JExpVar (JVarId "x" Nothing)) [JDoStatement (JSubroutineCall "Screen" (Just "setColor") [JExpVar (JVarId "x" Nothing)]),JDoStatement (JSubroutineCall "Screen" (Just "drawRectangle") [JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing),JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing)]),JLetStatment (JVarId "x" Nothing) (JExpVar (JVarId "x" Nothing)),JDoStatement (JSubroutineCall "Screen" (Just "setColor") [JExpVar (JVarId "x" Nothing)]),JDoStatement (JSubroutineCall "Screen" (Just "drawRectangle") [JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing),JExpVar (JVarId "x" Nothing),JExpVar (JVarId "y" Nothing)])] Nothing,JReturnStatement Nothing])]) \ No newline at end of file diff --git a/projects/10/ExpressionLessSquare/Square.jack b/projects/10/ExpressionLessSquare/Square.jack deleted file mode 100644 index 33a54ad..0000000 --- a/projects/10/ExpressionLessSquare/Square.jack +++ /dev/null @@ -1,99 +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/ExpressionLessSquare/Square.jack - -/** Expressionless version of projects/10/Square/Square.jack. */ - -class Square { - - field int x, y; - field int size; - - constructor Square new(int Ax, int Ay, int Asize) { - let x = Ax; - let y = Ay; - let size = Asize; - do draw(); - return x; - } - - method void dispose() { - do Memory.deAlloc(this); - return; - } - - method void draw() { - do Screen.setColor(x); - do Screen.drawRectangle(x, y, x, y); - return; - } - - method void erase() { - do Screen.setColor(x); - do Screen.drawRectangle(x, y, x, y); - return; - } - - method void incSize() { - if (x) { - do erase(); - let size = size; - do draw(); - } - return; - } - - method void decSize() { - if (size) { - do erase(); - let size = size; - do draw(); - } - return; - } - - method void moveUp() { - if (y) { - do Screen.setColor(x); - do Screen.drawRectangle(x, y, x, y); - let y = y; - do Screen.setColor(x); - do Screen.drawRectangle(x, y, x, y); - } - return; - } - - method void moveDown() { - if (y) { - do Screen.setColor(x); - do Screen.drawRectangle(x, y, x, y); - let y = y; - do Screen.setColor(x); - do Screen.drawRectangle(x, y, x, y); - } - return; - } - - method void moveLeft() { - if (x) { - do Screen.setColor(x); - do Screen.drawRectangle(x, y, x, y); - let x = x; - do Screen.setColor(x); - do Screen.drawRectangle(x, y, x, y); - } - return; - } - - method void moveRight() { - if (x) { - do Screen.setColor(x); - do Screen.drawRectangle(x, y, x, y); - let x = x; - do Screen.setColor(x); - do Screen.drawRectangle(x, y, x, y); - } - return; - } -} diff --git a/projects/10/ExpressionLessSquare/Square.xml b/projects/10/ExpressionLessSquare/Square.xml deleted file mode 100644 index ed0e6ec..0000000 --- a/projects/10/ExpressionLessSquare/Square.xml +++ /dev/null @@ -1,967 +0,0 @@ - - class - Square - { - - field - int - x - , - y - ; - - - field - int - size - ; - - - constructor - Square - new - ( - - int - Ax - , - int - Ay - , - int - Asize - - ) - - { - - - let - x - = - - - Ax - - - ; - - - let - y - = - - - Ay - - - ; - - - let - size - = - - - Asize - - - ; - - - do - draw - ( - - - ) - ; - - - return - - - x - - - ; - - - } - - - - method - void - dispose - ( - - - ) - - { - - - do - Memory - . - deAlloc - ( - - - - this - - - - ) - ; - - - return - ; - - - } - - - - method - void - draw - ( - - - ) - - { - - - do - Screen - . - setColor - ( - - - - x - - - - ) - ; - - - do - Screen - . - drawRectangle - ( - - - - x - - - , - - - y - - - , - - - x - - - , - - - y - - - - ) - ; - - - return - ; - - - } - - - - method - void - erase - ( - - - ) - - { - - - do - Screen - . - setColor - ( - - - - x - - - - ) - ; - - - do - Screen - . - drawRectangle - ( - - - - x - - - , - - - y - - - , - - - x - - - , - - - y - - - - ) - ; - - - return - ; - - - } - - - - method - void - incSize - ( - - - ) - - { - - - if - ( - - - x - - - ) - { - - - do - erase - ( - - - ) - ; - - - let - size - = - - - size - - - ; - - - do - draw - ( - - - ) - ; - - - } - - - return - ; - - - } - - - - method - void - decSize - ( - - - ) - - { - - - if - ( - - - size - - - ) - { - - - do - erase - ( - - - ) - ; - - - let - size - = - - - size - - - ; - - - do - draw - ( - - - ) - ; - - - } - - - return - ; - - - } - - - - method - void - moveUp - ( - - - ) - - { - - - if - ( - - - y - - - ) - { - - - do - Screen - . - setColor - ( - - - - x - - - - ) - ; - - - do - Screen - . - drawRectangle - ( - - - - x - - - , - - - y - - - , - - - x - - - , - - - y - - - - ) - ; - - - let - y - = - - - y - - - ; - - - do - Screen - . - setColor - ( - - - - x - - - - ) - ; - - - do - Screen - . - drawRectangle - ( - - - - x - - - , - - - y - - - , - - - x - - - , - - - y - - - - ) - ; - - - } - - - return - ; - - - } - - - - method - void - moveDown - ( - - - ) - - { - - - if - ( - - - y - - - ) - { - - - do - Screen - . - setColor - ( - - - - x - - - - ) - ; - - - do - Screen - . - drawRectangle - ( - - - - x - - - , - - - y - - - , - - - x - - - , - - - y - - - - ) - ; - - - let - y - = - - - y - - - ; - - - do - Screen - . - setColor - ( - - - - x - - - - ) - ; - - - do - Screen - . - drawRectangle - ( - - - - x - - - , - - - y - - - , - - - x - - - , - - - y - - - - ) - ; - - - } - - - return - ; - - - } - - - - method - void - moveLeft - ( - - - ) - - { - - - if - ( - - - x - - - ) - { - - - do - Screen - . - setColor - ( - - - - x - - - - ) - ; - - - do - Screen - . - drawRectangle - ( - - - - x - - - , - - - y - - - , - - - x - - - , - - - y - - - - ) - ; - - - let - x - = - - - x - - - ; - - - do - Screen - . - setColor - ( - - - - x - - - - ) - ; - - - do - Screen - . - drawRectangle - ( - - - - x - - - , - - - y - - - , - - - x - - - , - - - y - - - - ) - ; - - - } - - - return - ; - - - } - - - - method - void - moveRight - ( - - - ) - - { - - - if - ( - - - x - - - ) - { - - - do - Screen - . - setColor - ( - - - - x - - - - ) - ; - - - do - Screen - . - drawRectangle - ( - - - - x - - - , - - - y - - - , - - - x - - - , - - - y - - - - ) - ; - - - let - x - = - - - x - - - ; - - - do - Screen - . - setColor - ( - - - - x - - - - ) - ; - - - do - Screen - . - drawRectangle - ( - - - - x - - - , - - - y - - - , - - - x - - - , - - - y - - - - ) - ; - - - } - - - return - ; - - - } - - - } - diff --git a/projects/10/ExpressionLessSquare/SquareGame.ast b/projects/10/ExpressionLessSquare/SquareGame.ast deleted file mode 100644 index 0abe80b..0000000 --- a/projects/10/ExpressionLessSquare/SquareGame.ast +++ /dev/null @@ -1 +0,0 @@ -Right (JClass "SquareGame" [JClassVarDec "field" ("Square","square"),JClassVarDec "field" ("int","direction")] [JSubroutineDec (JSubroutineHeader "constructor" ("SquareGame","new") []) (JSubroutineBody [] [JLetStatment (JVarId "square" Nothing) (JExpVar (JVarId "square" Nothing)),JLetStatment (JVarId "direction" Nothing) (JExpVar (JVarId "direction" Nothing)),JReturnStatement (Just (JExpVar (JVarId "square" Nothing)))]),JSubroutineDec (JSubroutineHeader "method" ("void","dispose") []) (JSubroutineBody [] [JDoStatement (JSubroutineCall "square" (Just "dispose") []),JDoStatement (JSubroutineCall "Memory" (Just "deAlloc") [JExpVar (JVarId "square" Nothing)]),JReturnStatement Nothing]),JSubroutineDec (JSubroutineHeader "method" ("void","moveSquare") []) (JSubroutineBody [] [JIfStatement (JExpVar (JVarId "direction" Nothing)) [JDoStatement (JSubroutineCall "square" (Just "moveUp") [])] Nothing,JIfStatement (JExpVar (JVarId "direction" Nothing)) [JDoStatement (JSubroutineCall "square" (Just "moveDown") [])] Nothing,JIfStatement (JExpVar (JVarId "direction" Nothing)) [JDoStatement (JSubroutineCall "square" (Just "moveLeft") [])] Nothing,JIfStatement (JExpVar (JVarId "direction" Nothing)) [JDoStatement (JSubroutineCall "square" (Just "moveRight") [])] Nothing,JDoStatement (JSubroutineCall "Sys" (Just "wait") [JExpVar (JVarId "direction" Nothing)]),JReturnStatement Nothing]),JSubroutineDec (JSubroutineHeader "method" ("void","run") []) (JSubroutineBody [("char","key"),("boolean","exit")] [JLetStatment (JVarId "exit" Nothing) (JExpVar (JVarId "key" Nothing)),JWhileStatment (JExpVar (JVarId "exit" Nothing)) [JWhileStatment (JExpVar (JVarId "key" Nothing)) [JLetStatment (JVarId "key" Nothing) (JExpVar (JVarId "key" Nothing)),JDoStatement (JSubroutineCall "moveSquare" Nothing [])],JIfStatement (JExpVar (JVarId "key" Nothing)) [JLetStatment (JVarId "exit" Nothing) (JExpVar (JVarId "exit" Nothing))] Nothing,JIfStatement (JExpVar (JVarId "key" Nothing)) [JDoStatement (JSubroutineCall "square" (Just "decSize") [])] Nothing,JIfStatement (JExpVar (JVarId "key" Nothing)) [JDoStatement (JSubroutineCall "square" (Just "incSize") [])] Nothing,JIfStatement (JExpVar (JVarId "key" Nothing)) [JLetStatment (JVarId "direction" Nothing) (JExpVar (JVarId "exit" Nothing))] Nothing,JIfStatement (JExpVar (JVarId "key" Nothing)) [JLetStatment (JVarId "direction" Nothing) (JExpVar (JVarId "key" Nothing))] Nothing,JIfStatement (JExpVar (JVarId "key" Nothing)) [JLetStatment (JVarId "direction" Nothing) (JExpVar (JVarId "square" Nothing))] Nothing,JIfStatement (JExpVar (JVarId "key" Nothing)) [JLetStatment (JVarId "direction" Nothing) (JExpVar (JVarId "direction" Nothing))] Nothing,JWhileStatment (JExpVar (JVarId "key" Nothing)) [JLetStatment (JVarId "key" Nothing) (JExpVar (JVarId "key" Nothing)),JDoStatement (JSubroutineCall "moveSquare" Nothing [])]],JReturnStatement Nothing])]) \ No newline at end of file diff --git a/projects/10/ExpressionLessSquare/SquareGame.jack b/projects/10/ExpressionLessSquare/SquareGame.jack deleted file mode 100644 index 2866f0d..0000000 --- a/projects/10/ExpressionLessSquare/SquareGame.jack +++ /dev/null @@ -1,60 +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/ExpressionLessSquare/SquareGame.jack - -/** Expressionless version of projects/10/Square/SquareGame.jack. */ - -class SquareGame { - field Square square; - field int direction; - - constructor SquareGame new() { - let square = square; - let direction = direction; - return square; - } - - method void dispose() { - do square.dispose(); - do Memory.deAlloc(square); - return; - } - - method void moveSquare() { - if (direction) { do square.moveUp(); } - if (direction) { do square.moveDown(); } - if (direction) { do square.moveLeft(); } - if (direction) { do square.moveRight(); } - do Sys.wait(direction); - return; - } - - method void run() { - var char key; - var boolean exit; - - let exit = key; - while (exit) { - while (key) { - let key = key; - do moveSquare(); - } - - if (key) { let exit = exit; } - if (key) { do square.decSize(); } - if (key) { do square.incSize(); } - if (key) { let direction = exit; } - if (key) { let direction = key; } - if (key) { let direction = square; } - if (key) { let direction = direction; } - - while (key) { - let key = key; - do moveSquare(); - } - } - return; - } -} - diff --git a/projects/10/ExpressionLessSquare/SquareGame.xml b/projects/10/ExpressionLessSquare/SquareGame.xml deleted file mode 100644 index 288c6cd..0000000 --- a/projects/10/ExpressionLessSquare/SquareGame.xml +++ /dev/null @@ -1,544 +0,0 @@ - - class - SquareGame - { - - field - Square - square - ; - - - field - int - direction - ; - - - constructor - SquareGame - new - ( - - - ) - - { - - - let - square - = - - - square - - - ; - - - let - direction - = - - - direction - - - ; - - - return - - - square - - - ; - - - } - - - - method - void - dispose - ( - - - ) - - { - - - do - square - . - dispose - ( - - - ) - ; - - - do - Memory - . - deAlloc - ( - - - - square - - - - ) - ; - - - return - ; - - - } - - - - method - void - moveSquare - ( - - - ) - - { - - - if - ( - - - direction - - - ) - { - - - do - square - . - moveUp - ( - - - ) - ; - - - } - - - if - ( - - - direction - - - ) - { - - - do - square - . - moveDown - ( - - - ) - ; - - - } - - - if - ( - - - direction - - - ) - { - - - do - square - . - moveLeft - ( - - - ) - ; - - - } - - - if - ( - - - direction - - - ) - { - - - do - square - . - moveRight - ( - - - ) - ; - - - } - - - do - Sys - . - wait - ( - - - - direction - - - - ) - ; - - - return - ; - - - } - - - - method - void - run - ( - - - ) - - { - - var - char - key - ; - - - var - boolean - exit - ; - - - - let - exit - = - - - key - - - ; - - - while - ( - - - exit - - - ) - { - - - while - ( - - - key - - - ) - { - - - let - key - = - - - key - - - ; - - - do - moveSquare - ( - - - ) - ; - - - } - - - if - ( - - - key - - - ) - { - - - let - exit - = - - - exit - - - ; - - - } - - - if - ( - - - key - - - ) - { - - - do - square - . - decSize - ( - - - ) - ; - - - } - - - if - ( - - - key - - - ) - { - - - do - square - . - incSize - ( - - - ) - ; - - - } - - - if - ( - - - key - - - ) - { - - - let - direction - = - - - exit - - - ; - - - } - - - if - ( - - - key - - - ) - { - - - let - direction - = - - - key - - - ; - - - } - - - if - ( - - - key - - - ) - { - - - let - direction - = - - - square - - - ; - - - } - - - if - ( - - - key - - - ) - { - - - let - direction - = - - - direction - - - ; - - - } - - - while - ( - - - key - - - ) - { - - - let - key - = - - - key - - - ; - - - do - moveSquare - ( - - - ) - ; - - - } - - - } - - - return - ; - - - } - - - } - diff --git a/projects/10/ExpressionLessSquare/SquareGameT.xml b/projects/10/ExpressionLessSquare/SquareGameT.xml deleted file mode 100644 index 278a8a9..0000000 --- a/projects/10/ExpressionLessSquare/SquareGameT.xml +++ /dev/null @@ -1,268 +0,0 @@ - - class - SquareGame - { - field - Square - square - ; - field - int - direction - ; - constructor - SquareGame - new - ( - ) - { - let - square - = - square - ; - let - direction - = - direction - ; - return - square - ; - } - method - void - dispose - ( - ) - { - do - square - . - dispose - ( - ) - ; - do - Memory - . - deAlloc - ( - square - ) - ; - return - ; - } - method - void - moveSquare - ( - ) - { - if - ( - direction - ) - { - do - square - . - moveUp - ( - ) - ; - } - if - ( - direction - ) - { - do - square - . - moveDown - ( - ) - ; - } - if - ( - direction - ) - { - do - square - . - moveLeft - ( - ) - ; - } - if - ( - direction - ) - { - do - square - . - moveRight - ( - ) - ; - } - do - Sys - . - wait - ( - direction - ) - ; - return - ; - } - method - void - run - ( - ) - { - var - char - key - ; - var - boolean - exit - ; - let - exit - = - key - ; - while - ( - exit - ) - { - while - ( - key - ) - { - let - key - = - key - ; - do - moveSquare - ( - ) - ; - } - if - ( - key - ) - { - let - exit - = - exit - ; - } - if - ( - key - ) - { - do - square - . - decSize - ( - ) - ; - } - if - ( - key - ) - { - do - square - . - incSize - ( - ) - ; - } - if - ( - key - ) - { - let - direction - = - exit - ; - } - if - ( - key - ) - { - let - direction - = - key - ; - } - if - ( - key - ) - { - let - direction - = - square - ; - } - if - ( - key - ) - { - let - direction - = - direction - ; - } - while - ( - key - ) - { - let - key - = - key - ; - do - moveSquare - ( - ) - ; - } - } - return - ; - } - } - diff --git a/projects/10/ExpressionLessSquare/SquareT.xml b/projects/10/ExpressionLessSquare/SquareT.xml deleted file mode 100644 index cd03a1e..0000000 --- a/projects/10/ExpressionLessSquare/SquareT.xml +++ /dev/null @@ -1,449 +0,0 @@ - - class - Square - { - field - int - x - , - y - ; - field - int - size - ; - constructor - Square - new - ( - int - Ax - , - int - Ay - , - int - Asize - ) - { - let - x - = - Ax - ; - let - y - = - Ay - ; - let - size - = - Asize - ; - do - draw - ( - ) - ; - return - x - ; - } - method - void - dispose - ( - ) - { - do - Memory - . - deAlloc - ( - this - ) - ; - return - ; - } - method - void - draw - ( - ) - { - do - Screen - . - setColor - ( - x - ) - ; - do - Screen - . - drawRectangle - ( - x - , - y - , - x - , - y - ) - ; - return - ; - } - method - void - erase - ( - ) - { - do - Screen - . - setColor - ( - x - ) - ; - do - Screen - . - drawRectangle - ( - x - , - y - , - x - , - y - ) - ; - return - ; - } - method - void - incSize - ( - ) - { - if - ( - x - ) - { - do - erase - ( - ) - ; - let - size - = - size - ; - do - draw - ( - ) - ; - } - return - ; - } - method - void - decSize - ( - ) - { - if - ( - size - ) - { - do - erase - ( - ) - ; - let - size - = - size - ; - do - draw - ( - ) - ; - } - return - ; - } - method - void - moveUp - ( - ) - { - if - ( - y - ) - { - do - Screen - . - setColor - ( - x - ) - ; - do - Screen - . - drawRectangle - ( - x - , - y - , - x - , - y - ) - ; - let - y - = - y - ; - do - Screen - . - setColor - ( - x - ) - ; - do - Screen - . - drawRectangle - ( - x - , - y - , - x - , - y - ) - ; - } - return - ; - } - method - void - moveDown - ( - ) - { - if - ( - y - ) - { - do - Screen - . - setColor - ( - x - ) - ; - do - Screen - . - drawRectangle - ( - x - , - y - , - x - , - y - ) - ; - let - y - = - y - ; - do - Screen - . - setColor - ( - x - ) - ; - do - Screen - . - drawRectangle - ( - x - , - y - , - x - , - y - ) - ; - } - return - ; - } - method - void - moveLeft - ( - ) - { - if - ( - x - ) - { - do - Screen - . - setColor - ( - x - ) - ; - do - Screen - . - drawRectangle - ( - x - , - y - , - x - , - y - ) - ; - let - x - = - x - ; - do - Screen - . - setColor - ( - x - ) - ; - do - Screen - . - drawRectangle - ( - x - , - y - , - x - , - y - ) - ; - } - return - ; - } - method - void - moveRight - ( - ) - { - if - ( - x - ) - { - do - Screen - . - setColor - ( - x - ) - ; - do - Screen - . - drawRectangle - ( - x - , - y - , - x - , - y - ) - ; - let - x - = - x - ; - do - Screen - . - setColor - ( - x - ) - ; - do - Screen - . - drawRectangle - ( - x - , - y - , - x - , - y - ) - ; - } - return - ; - } - } - -- cgit v1.2.3