Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added HDL (Hardware Description Language) support #1710

Merged
merged 6 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
"title": "HCL",
"owner": "outsideris"
},
"nand2tetris-hdl": {
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
"title": "Nand To Tetris HDL",
"owner": "stephanmax"
},
"http": {
"title": "HTTP",
"peerDependencies": [
Expand Down
1 change: 1 addition & 0 deletions components/prism-hdl.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions components/prism-nand2tetris-hdl.js
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]*(?=\()/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
'number': /\b\d+\b/,
'operator': /=|\.\./,
'punctuation': /[{}[\];(),:]/
};
1 change: 1 addition & 0 deletions components/prism-nand2tetris-hdl.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions examples/prism-nand2tetris-hdl.html
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
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
PARTS:
Xor(a=a, b=b, out=uneq);
Not(in=uneq, out=out);
}</code></pre>
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (!Prism.plugins.toolbar) {
}

// The languages map is built automatically with gulp
var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","arff":"ARFF","asciidoc":"AsciiDoc","asm6502":"6502 Assembly","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","autoit":"AutoIt","shell":"Shell","basic":"BASIC","csharp":"C#","cpp":"C++","cil":"CIL","coffeescript":"CoffeeScript","csp":"Content-Security-Policy","css-extras":"CSS Extras","django":"Django/Jinja2","erb":"ERB","fsharp":"F#","gcode":"G-code","gedcom":"GEDCOM","glsl":"GLSL","gml":"GameMaker Language","graphql":"GraphQL","hcl":"HCL","http":"HTTP","hpkp":"HTTP Public-Key-Pins","hsts":"HTTP Strict-Transport-Security","ichigojam":"IchigoJam","inform7":"Inform 7","javastacktrace":"Java stack trace","json":"JSON","jsonp":"JSONP","latex":"LaTeX","livescript":"LiveScript","lolcode":"LOLCODE","markup-templating":"Markup templating","matlab":"MATLAB","mel":"MEL","n1ql":"N1QL","n4js":"N4JS","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","opencl":"OpenCL","parigp":"PARI/GP","objectpascal":"Object Pascal","php":"PHP","php-extras":"PHP Extras","plsql":"PL/SQL","powershell":"PowerShell","properties":".properties","protobuf":"Protocol Buffers","q":"Q (kdb+ database)","jsx":"React JSX","tsx":"React TSX","renpy":"Ren'py","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","soy":"Soy (Closure Template)","tap":"TAP","toml":"TOML","tt2":"Template Toolkit 2","typescript":"TypeScript","vbnet":"VB.Net","vhdl":"VHDL","vim":"vim","visual-basic":"Visual Basic","wasm":"WebAssembly","wiki":"Wiki markup","xeoracube":"XeoraCube","xojo":"Xojo (REALbasic)","xquery":"XQuery","yaml":"YAML"}/*]*/;
var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","arff":"ARFF","asciidoc":"AsciiDoc","asm6502":"6502 Assembly","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","autoit":"AutoIt","shell":"Shell","basic":"BASIC","csharp":"C#","cpp":"C++","cil":"CIL","coffeescript":"CoffeeScript","csp":"Content-Security-Policy","css-extras":"CSS Extras","django":"Django/Jinja2","erb":"ERB","fsharp":"F#","gcode":"G-code","gedcom":"GEDCOM","glsl":"GLSL","gml":"GameMaker Language","graphql":"GraphQL","hcl":"HCL","nand2tetris-hdl":"Nand To Tetris HDL","http":"HTTP","hpkp":"HTTP Public-Key-Pins","hsts":"HTTP Strict-Transport-Security","ichigojam":"IchigoJam","inform7":"Inform 7","javastacktrace":"Java stack trace","json":"JSON","jsonp":"JSONP","latex":"LaTeX","livescript":"LiveScript","lolcode":"LOLCODE","markup-templating":"Markup templating","matlab":"MATLAB","mel":"MEL","n1ql":"N1QL","n4js":"N4JS","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","opencl":"OpenCL","parigp":"PARI/GP","objectpascal":"Object Pascal","php":"PHP","php-extras":"PHP Extras","plsql":"PL/SQL","powershell":"PowerShell","properties":".properties","protobuf":"Protocol Buffers","q":"Q (kdb+ database)","jsx":"React JSX","tsx":"React TSX","renpy":"Ren'py","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","soy":"Soy (Closure Template)","tap":"TAP","toml":"TOML","tt2":"Template Toolkit 2","typescript":"TypeScript","vbnet":"VB.Net","vhdl":"VHDL","vim":"vim","visual-basic":"Visual Basic","wasm":"WebAssembly","wiki":"Wiki markup","xeoracube":"XeoraCube","xojo":"Xojo (REALbasic)","xquery":"XQuery","yaml":"YAML"}/*]*/;
Prism.plugins.toolbar.registerButton('show-language', function(env) {
var pre = env.element.parentNode;
if (!pre || !/pre/i.test(pre.nodeName)) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions tests/languages/nand2tetris-hdl/boolean_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
true
false

----------------------------------------------------

[
["boolean", "true"],
["boolean", "false"]
]

----------------------------------------------------

Checks for booleans.
20 changes: 20 additions & 0 deletions tests/languages/nand2tetris-hdl/comment_feature.test
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.
23 changes: 23 additions & 0 deletions tests/languages/nand2tetris-hdl/function_feature.test
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.
21 changes: 21 additions & 0 deletions tests/languages/nand2tetris-hdl/keyword_feature.test
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.
15 changes: 15 additions & 0 deletions tests/languages/nand2tetris-hdl/number_feature.test
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.
13 changes: 13 additions & 0 deletions tests/languages/nand2tetris-hdl/operator_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=
..

----------------------------------------------------

[
["operator", "="],
["operator", ".."]
]

----------------------------------------------------

Checks for all operators.
23 changes: 23 additions & 0 deletions tests/languages/nand2tetris-hdl/punctuation_feature.test
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.