From fd8c3f43853eea490cb7b3f8fd2ec86635ad1589 Mon Sep 17 00:00:00 2001
From: Yuchen Pei <me@ypei.me>
Date: Tue, 9 Jan 2018 15:51:29 +0100
Subject: started working on project 10.

- trying to figure out all the data types for jack ast
---
 projects/10/JackParser.hs |  26 ++++++++++++++++++++++++++
 projects/10/jackspec.wiki |   3 +++
 projects/10/spec1         |   0
 projects/10/spec1.png     | Bin 0 -> 224788 bytes
 projects/10/spec2.png     | Bin 0 -> 152598 bytes
 5 files changed, 29 insertions(+)
 create mode 100644 projects/10/JackParser.hs
 create mode 100644 projects/10/jackspec.wiki
 create mode 100644 projects/10/spec1
 create mode 100644 projects/10/spec1.png
 create mode 100644 projects/10/spec2.png

(limited to 'projects')

diff --git a/projects/10/JackParser.hs b/projects/10/JackParser.hs
new file mode 100644
index 0000000..a6fe7b3
--- /dev/null
+++ b/projects/10/JackParser.hs
@@ -0,0 +1,26 @@
+-- Jack Parser, as the coursework of Project 10 of Nand2Tetris course.
+-- Author: Yuchen Pei
+data JClass = JClass JIdentifier [JClassVarDec] [JSubroutineDec]
+data JIdentifier = JIdentifier [Char]
+data JClassVarDec = JClassVarDec JClassVarScope JType JIdentifier
+data JClassVarScope = JStatic | JField
+data JType = JInt | JChar | JBoolean | JVoid
+data JSubroutineDec = JSubroutineDec JSubroutineType JType JIdentifier [JParameter] JSubroutineBody
+data JSubroutineType = JConstructor | JFunction | JMethod
+data JParameter = JParameter JType JIdentifier
+data JSubroutineBody = JSubroutineBody [JVarDec] [JStatement]
+data JVarDec = JVarDec JType JIdentifier
+data JStatement = JLetStatement | JIfStatement | JWhileStatment | JDoStatement | JReturnStatement
+data JLetStatement = JLetStatment JLeftVarId JExpression
+data JIfStatement = JIfStatement JExpression [JStatement] (Maybe [JStatement])
+data JWhileStatment = JWhileStatment JExpression [JStatement]
+type JDoStatement = JSubroutineCall
+type JReturnStatement = Maybe JExpression
+data JExpression = JTerm [(JOp, JTerm)]
+data JTerm = JIntConst | JStrConst | JKeywordConst | JLeftVarId | JSubroutineCall | JExpression | JUnaryOpTerm
+data JLeftVarId = JIdentifier | JLeftVarId JIdentifier (Maybe JExpression)
+data JSubroutineCall = JSubroutineCall Identifier [JExpression] | JSubroutineCall Identifier Identifier [JExpression]
+type JOp = Char
+data JUnaryOpTerm = JUnaryOpTerm JUnaryOp Term
+type JUnaryOp = Char
+data JKeywordConst = JTrue | JFalse | JNull | JThis
diff --git a/projects/10/jackspec.wiki b/projects/10/jackspec.wiki
new file mode 100644
index 0000000..e746941
--- /dev/null
+++ b/projects/10/jackspec.wiki
@@ -0,0 +1,3 @@
+Class = Name ClassVarDec* SubroutineDec*
+ClassVarDec = ClassVarScope Type Identifier*
+Type = JInt
diff --git a/projects/10/spec1 b/projects/10/spec1
new file mode 100644
index 0000000..e69de29
diff --git a/projects/10/spec1.png b/projects/10/spec1.png
new file mode 100644
index 0000000..d1a128e
Binary files /dev/null and b/projects/10/spec1.png differ
diff --git a/projects/10/spec2.png b/projects/10/spec2.png
new file mode 100644
index 0000000..8cd374b
Binary files /dev/null and b/projects/10/spec2.png differ
-- 
cgit v1.2.3