-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the Nand2Tetris HDL language (#1710)
This adds support for the [Nand2Tetris](https://www.nand2tetris.org/) HDL language.
- Loading branch information
1 parent
b1f8a65
commit b94b56c
Showing
15 changed files
with
169 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Prism.languages['nand2tetris-hdl'] = { | ||
'comment': /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/, | ||
'keyword': /\b(?:CHIP|IN|OUT|PARTS|BUILTIN|CLOCKED)\b/, | ||
'boolean': /\b(?:true|false)\b/, | ||
'function': /[A-Za-z][A-Za-z0-9]*(?=\()/, | ||
'number': /\b\d+\b/, | ||
'operator': /=|\.\./, | ||
'punctuation': /[{}[\];(),:]/ | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<h2>Comments</h2> | ||
<pre><code>// Single line comment | ||
/* Multi-line | ||
comment */</code></pre> | ||
|
||
<h2>Literal values</h2> | ||
<pre><code>0 | ||
32 | ||
true | ||
false</code></pre> | ||
|
||
<h2>Full example</h2> | ||
<pre><code>/* | ||
* Checks if two input bits are equal | ||
*/ | ||
|
||
CHIP Eq { | ||
IN a, b; | ||
OUT out; // True iff a=b | ||
PARTS: | ||
Xor(a=a, b=b, out=uneq); | ||
Not(in=uneq, out=out); | ||
}</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
true | ||
false | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["boolean", "true"], | ||
["boolean", "false"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for booleans. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// foobar | ||
/**/ | ||
/* foo | ||
bar */ | ||
/* | ||
* foobar | ||
*/ | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "// foobar"], | ||
["comment", "/**/"], | ||
["comment", "/* foo\r\nbar */"], | ||
["comment", "/*\r\n * foobar\r\n */"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for single-line and multi-line comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
And() | ||
not() | ||
mux16() | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "And"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
["function", "not"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
["function", "mux16"], | ||
["punctuation", "("], | ||
["punctuation", ")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
CHIP | ||
IN | ||
OUT | ||
PARTS | ||
BUILTIN | ||
CLOCKED | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "CHIP"], | ||
["keyword", "IN"], | ||
["keyword", "OUT"], | ||
["keyword", "PARTS"], | ||
["keyword", "BUILTIN"], | ||
["keyword", "CLOCKED"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for all keywords. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
0 | ||
16 | ||
32 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["number", "0"], | ||
["number", "16"], | ||
["number", "32"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for integer numbers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
= | ||
.. | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["operator", "="], | ||
["operator", ".."] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for all operators. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
( ) | ||
{ } | ||
[ ] | ||
, | ||
; | ||
: | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
["punctuation", "{"], | ||
["punctuation", "}"], | ||
["punctuation", "["], | ||
["punctuation", "]"], | ||
["punctuation", ","], | ||
["punctuation", ";"], | ||
["punctuation", ":"] | ||
] | ||
---------------------------------------------------- | ||
|
||
Checks for punctuation. |