diff options
author | Yuchen Pei <me@ypei.me> | 2018-01-09 15:51:29 +0100 |
---|---|---|
committer | Yuchen Pei <me@ypei.me> | 2018-01-09 15:51:29 +0100 |
commit | fd8c3f43853eea490cb7b3f8fd2ec86635ad1589 (patch) | |
tree | 350ea0f877504aaa70d8959d6874df8bc5bcebb1 /projects | |
parent | 8d610ca02dc7b76238fb582b1dac148505e38c05 (diff) |
started working on project 10.
- trying to figure out all the data types for jack ast
Diffstat (limited to 'projects')
-rw-r--r-- | projects/10/JackParser.hs | 26 | ||||
-rw-r--r-- | projects/10/jackspec.wiki | 3 | ||||
-rw-r--r-- | projects/10/spec1 | 0 | ||||
-rw-r--r-- | projects/10/spec1.png | bin | 0 -> 224788 bytes | |||
-rw-r--r-- | projects/10/spec2.png | bin | 0 -> 152598 bytes |
5 files changed, 29 insertions, 0 deletions
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 --- /dev/null +++ b/projects/10/spec1 diff --git a/projects/10/spec1.png b/projects/10/spec1.png Binary files differnew file mode 100644 index 0000000..d1a128e --- /dev/null +++ b/projects/10/spec1.png diff --git a/projects/10/spec2.png b/projects/10/spec2.png Binary files differnew file mode 100644 index 0000000..8cd374b --- /dev/null +++ b/projects/10/spec2.png |