readinglist |
author | Hayes & Kaba |
status | reading |
This is an old revision of the document!
- asm.lark
%import common.WS
%import common.CPP_COMMENT
%import common.INT
%import common.WORD
%ignore WS
%ignore CPP_COMMENT
start: (LABEL | ainstr | cinstr)*
LABEL: "(" WORD ")"
ainstr: "@" SYMBOL
SYMBOL: WORD
| INT
| "R" "0".."15"
| "SP"
| "LCL"
| "ARG"
| "THIS"
| "THAT"
| "KBD"
| "SCREEN"
cinstr: (DEST "=")? COMP (";" JUMP)?
- vm.lark
%import common.WS
%import common.CPP_COMMENT
%import common.INT
%import common.SIGNED_INT
%ignore WS
%ignore CPP_COMMENT
start: (stackop | arithop)*
stackop: (PUSH|POP) SEGMENT INDEX
PUSH: "push"
POP: "pop"
arithop: ADD
| SUB
| NEG
| EQ
| GT
| LT
| AND
| OR
| NOT
ADD: "add"
SUB: "sub"
NEG: "neg"
EQ: "eq"
GT: "gt"
LT: "lt"
AND: "and"
OR: "or"
NOT: "not"
SEGMENT: "argument"
| "local"
| "static"
| "constant"
| "this"
| "that"
| "pointer"
| "temp"
INDEX: INT