Skip to content

Commit

Permalink
fix some bugs and add some new function
Browse files Browse the repository at this point in the history
  • Loading branch information
loyio committed Jan 5, 2021
1 parent ac697a6 commit 4b95c6e
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
All notable changes to the "Nand2Tetris for vscode" extension will be documented in this file.

## [0.2]

- add .hack syntax support
- add new computer-architecture snippets
- fix some bugs

## [0.1.2]

- update the description pages
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ A vscode extension for Nand2Tetris Project

## Change log

### v0.2

- add .hack syntax support
- add new computer-architecture snippets
- fix some bugs

### v0.1.2

- update the description pages
Expand All @@ -47,7 +53,14 @@ A vscode extension for Nand2Tetris Project

## TODO

* [ ] Syntaxes

* [x] hack
* [ ] jack


* [ ] Snippets

* [ ] jack


Expand Down
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"asm",
"out",
"cmp",
"hack",
"nand2tetris",
"snippets",
"syntax-highlighting",
Expand Down Expand Up @@ -95,6 +96,17 @@
".asm"
],
"configuration": "./language-configuration.json"
},
{
"id": "hack",
"aliases": [
"HACK",
"hack"
],
"extensions": [
".hack"
],
"configuration": "./language-configuration.json"
}
],
"grammars": [
Expand Down Expand Up @@ -122,6 +134,11 @@
"language": "asm",
"scopeName": "source.asm",
"path": "./syntaxes/asm.tmLanguage.json"
},
{
"language": "hack",
"scopeName": "source.hack",
"path": "./syntaxes/hack.tmLanguage.json"
}
],
"snippets": [
Expand Down
7 changes: 6 additions & 1 deletion snippets/hdl-files/Combinational-chips.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"Creates a ALU (arithmetic-logic unit)": {
"prefix": "ALU",
"body": "ALU(x=${1:inputX}, y=${2:inputY}, zx=${3:zeroX}, nx=${4:negateX}, ny=${5:negateY}, f=${6:AddOrAddition}, no=${7:negateOut}, out=${8:out}, zr=${9:outIsZero}, ng=${10:OutNegitive});",
"body": "ALU(x=${1:inputX}, y=${2:inputY}, zx=${3:zeroX}, nx=${4:negateX}, zy=${5:zeroY} ny=${6:negateY}, f=${7:AddOrAddition}, no=${8:negateOut}, out=${9:out}, zr=${10:outIsZero}, ng=${11:OutNegitive});",
"description": [
"Takes two 16 bit values (x, y)\n",
"zx: zero the x input",
Expand All @@ -50,6 +50,11 @@
"no: negate the out output\n"
]
},
"Creates a Register": {
"prefix": "Register",
"body": "Register(in=${1:in}, load=${2:load}, out=${3:out});",
"description": "Store Data chip of the hack platform"
},
"Creates ROM32k": {
"prefix": "ROM32",
"body": "ROM32K(address=${1:addr}, out=${2:out});",
Expand Down
21 changes: 20 additions & 1 deletion snippets/hdl-files/Computer-Architecture.code-snippets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Creates Memory chip": {
"prefix": "Memory",
"body": "Memory(in=${1:in}, load=${2:load}, address=${3:addr}, out={4:out});",
"body": "Memory(in=${1:in}, load=${2:load}, address=${3:addr}, out=${4:out});",
"description": "takes in a 16 bit value, load value and a 15 bit address\n"
},
"Creates a CPU": {
Expand All @@ -18,6 +18,25 @@
"pc: address of next instruction\n"
]
},
"Creates a SCREEN": {
"prefix": "Screen",
"body": "Screen(in=${1:in}, load=${2:load}, address=${3:address}, out=${4:out});",
"description": [
"The built-in Screen chip",
"in : the screen pixel group data",
"load : if is screen address",
"address : the address of screen pixel group",
"out : out of this screen chip"
]
},
"Creates a Keyboard": {
"prefix": "Keyboard",
"body": "Keyboard(out=${1:out});",
"description": [
"The built-in Keyboard chip",
"get the pressing key address",
]
},
"Creates a Computer": {
"prefix": "Computer",
"body": "Computer(inM=${1:inM}, instruction=${2:instruction}, reset=${3:reset}, outM=${4:outM}, writeM=${5:outwriteIntoM}, addressM=${6:outAddrM}, pc=${7:outPc});",
Expand Down
55 changes: 55 additions & 0 deletions syntaxes/hack.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Hack Machine Language",
"patterns": [
{
"include": "#a"
},
{
"include": "#c"
}
],
"repository": {
"a": {
"patterns": [
{
"comment": "0-value",
"begin": "\\b0",
"end": "\\b",
"name": "keyword.other",
"patterns": [
{
"comment": "value",
"match": "[01]{15}\\b",
"name": "constant.numeric"
}
]
}
]
},
"c": {
"patterns": [
{
"comment": "111-comp-dest-jump",
"match": "\\b111([01]{7})([01]{3})([01]{3})\\b",
"name": "keyword.other",
"captures": {
"1": {
"comment": "comp",
"name": "string.unquoted"
},
"2": {
"comment": "dest",
"name": "variable.language"
},
"3": {
"comment": "jump",
"name": "keyword.control"
}
}
}
]
}
},
"scopeName": "source.hack"
}

0 comments on commit 4b95c6e

Please sign in to comment.