-
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 Hoon programming language (#2978)
Co-authored-by: Michael Schmidt <mitchi5000.ms@googlemail.com>
- Loading branch information
1 parent
158f25d
commit ea77675
Showing
9 changed files
with
313 additions
and
1 deletion.
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
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,19 @@ | ||
Prism.languages.hoon = { | ||
'constant': /%(?:\.[ny]|[\w-]+)/, | ||
'comment': { | ||
pattern: /::.*/, | ||
greedy: true | ||
}, | ||
'function': /(?:\+[-+] {2})?(?:[a-z](?:[a-z0-9-]*[a-z0-9])?)/, | ||
'class-name': [ | ||
{ | ||
pattern: /@(?:[A-Za-z0-9-]*[A-Za-z0-9])?/, | ||
}, | ||
/\*/ | ||
], | ||
'string': { | ||
pattern: /"[^"]*"|'[^']*'/, | ||
greedy: true | ||
}, | ||
'keyword': /:_|\.[\^\+\*=\?]|![><:\.=\?!]|=[>|:,\.\-\^<+;/~\*\?]|\?[>|:\.\-\^<\+&~=@!]|\|[\$_%:\.\-\^~\*=@\?]|\+[|\$\+\*]|:[_\-\^\+~\*]|%[_:\.\-\^\+~\*=]|\^[|:\.\-\+&~\*=\?]|\$[|_%:<>\-\^&~@=\?]|;[:<\+;\/~\*=]|~[>|\$_%<\+\/&=\?!]|--|==/ | ||
}; |
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,17 @@ | ||
<h2>Caesar cipher</h2> | ||
|
||
<pre><code>|= [a=@ b=tape] | ||
^- tape | ||
?: (gth a 25) | ||
$(a (sub a 26)) | ||
%+ turn b | ||
|= c=@tD | ||
?: &((gte c 'A') (lte c 'Z')) | ||
=. c (add c a) | ||
?. (gth c 'Z') c | ||
(sub c 26) | ||
?: &((gte c 'a') (lte c 'z')) | ||
=. c (add c a) | ||
?. (gth c 'z') c | ||
(sub c 26) | ||
c</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
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,59 @@ | ||
:: Arvo formal interface | ||
:: | ||
:: this lifecycle wrapper makes the arvo door (multi-armed core) | ||
:: look like a gate (function or single-armed core), to fit | ||
:: urbit's formal lifecycle function. a practical interpreter | ||
:: can ignore it. | ||
:: | ||
|= [now=@da ovo=*] | ||
^- * | ||
~> %slog.[0 leaf+"arvo-event"] | ||
.(+> +:(poke now ovo)) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", ":: Arvo formal interface"], | ||
|
||
["comment", "::"], | ||
|
||
["comment", ":: this lifecycle wrapper makes the arvo door (multi-armed core)"], | ||
|
||
["comment", ":: look like a gate (function or single-armed core), to fit"], | ||
|
||
["comment", ":: urbit's formal lifecycle function. a practical interpreter"], | ||
|
||
["comment", ":: can ignore it."], | ||
|
||
["comment", "::"], | ||
|
||
["keyword", "|="], | ||
" [", | ||
["function", "now"], | ||
"=", | ||
["class-name", "@"], | ||
["function", "da"], | ||
["function", "ovo"], | ||
"=", | ||
["class-name", "*"], | ||
"]\r\n ", | ||
|
||
["keyword", "^-"], | ||
["class-name", "*"], | ||
|
||
["keyword", "~>"], | ||
["constant", "%slog"], | ||
".[0 ", | ||
["function", "leaf"], | ||
"+", | ||
["string", "\"arvo-event\""], | ||
"]\r\n .(+> +:(", | ||
["function", "poke"], | ||
["function", "now"], | ||
["function", "ovo"], | ||
"))" | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Tests for block comments and the inclusion of tapes and leaves inline in cells. |
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,83 @@ | ||
|% | ||
:: # %math | ||
:: unsigned arithmetic | ||
+| %math | ||
++ add | ||
~/ %add | ||
:: unsigned addition | ||
:: | ||
:: a: augend | ||
:: b: addend | ||
|= [a=@ b=@] | ||
:: sum | ||
^- @ | ||
?: =(0 a) b | ||
$(a (dec a), b +(b)) | ||
:: | ||
++ dec | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "|%"], | ||
|
||
["comment", ":: # %math"], | ||
|
||
["comment", ":: unsigned arithmetic"], | ||
|
||
["keyword", "+|"], | ||
["constant", "%math"], | ||
|
||
["function", "++ add"], | ||
|
||
["keyword", "~/"], | ||
["constant", "%add"], | ||
|
||
["comment", ":: unsigned addition"], | ||
|
||
["comment", "::"], | ||
|
||
["comment", ":: a: augend"], | ||
|
||
["comment", ":: b: addend"], | ||
|
||
["keyword", "|="], | ||
" [", | ||
["function", "a"], | ||
"=", | ||
["class-name", "@"], | ||
["function", "b"], | ||
"=", | ||
["class-name", "@"], | ||
"]\r\n ", | ||
|
||
["comment", ":: sum"], | ||
|
||
["keyword", "^-"], | ||
["class-name", "@"], | ||
|
||
["keyword", "?:"], | ||
" =(0 ", | ||
["function", "a"], | ||
") ", | ||
["function", "b"], | ||
|
||
"\r\n $(", | ||
["function", "a"], | ||
" (", | ||
["function", "dec"], | ||
["function", "a"], | ||
"), ", | ||
["function", "b"], | ||
" +(", | ||
["function", "b"], | ||
"))\r\n", | ||
|
||
["comment", "::"], | ||
|
||
["function", "++ dec"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Tests for a sample definition of a core with an arm. |
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,124 @@ | ||
|= [a=@ b=tape] | ||
^- tape | ||
?: (gth a 25) | ||
$(a (sub a 26)) | ||
%+ turn b | ||
|= c=@tD | ||
?: &((gte c 'A') (lte c 'Z')) | ||
=. c (add c a) | ||
?. (gth c 'Z') c | ||
(sub c 26) | ||
?: &((gte c 'a') (lte c 'z')) | ||
=. c (add c a) | ||
?. (gth c 'z') c | ||
(sub c 26) | ||
c | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "|="], | ||
" [", | ||
["function", "a"], | ||
"=", | ||
["class-name", "@"], | ||
["function", "b"], | ||
"=", | ||
["function", "tape"], | ||
"]\r\n", | ||
|
||
["keyword", "^-"], | ||
["function", "tape"], | ||
|
||
["keyword", "?:"], | ||
" (", | ||
["function", "gth"], | ||
["function", "a"], | ||
" 25)\r\n $(", | ||
["function", "a"], | ||
" (", | ||
["function", "sub"], | ||
["function", "a"], | ||
" 26))\r\n", | ||
|
||
["keyword", "%+"], | ||
["function", "turn"], | ||
["function", "b"], | ||
|
||
["keyword", "|="], | ||
["function", "c"], | ||
"=", | ||
["class-name", "@"], | ||
["function", "t"], | ||
"D\r\n", | ||
|
||
["keyword", "?:"], | ||
" &((", | ||
["function", "gte"], | ||
["function", "c"], | ||
["string", "'A'"], | ||
") (", | ||
["function", "lte"], | ||
["function", "c"], | ||
["string", "'Z'"], | ||
"))\r\n ", | ||
|
||
["keyword", "=."], | ||
["function", "c"], | ||
" (", | ||
["function", "add"], | ||
["function", "c"], | ||
["function", "a"], | ||
")\r\n ", | ||
|
||
["keyword", "?."], | ||
" (", | ||
["function", "gth"], | ||
["function", "c"], | ||
["string", "'Z'"], | ||
") ", | ||
["function", "c"], | ||
|
||
"\r\n (", | ||
["function", "sub"], | ||
["function", "c"], | ||
" 26)\r\n", | ||
|
||
["keyword", "?:"], | ||
" &((", | ||
["function", "gte"], | ||
["function", "c"], | ||
["string", "'a'"], | ||
") (", | ||
["function", "lte"], | ||
["function", "c"], | ||
["string", "'z'"], | ||
"))\r\n ", | ||
|
||
["keyword", "=."], | ||
["function", "c"], | ||
" (", | ||
["function", "add"], | ||
["function", "c"], | ||
["function", "a"], | ||
")\r\n ", | ||
|
||
["keyword", "?."], | ||
" (", | ||
["function", "gth"], | ||
["function", "c"], | ||
["string", "'z'"], | ||
") ", | ||
["function", "c"], | ||
|
||
"\r\n (", | ||
["function", "sub"], | ||
["function", "c"], | ||
" 26)\r\n", | ||
|
||
["function", "c"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Tests using the Caesar cipher to demonstrate multiple occasions of cords and tapes on the same line, correcting avoiding clobbering two cord and tape definitions into one. |