Added Hoon programming language (#2978)
Co-authored-by: Michael Schmidt <mitchi5000.ms@googlemail.com>
This commit is contained in:
parent
158f25d40c
commit
ea7767562a
File diff suppressed because one or more lines are too long
|
@ -518,6 +518,10 @@
|
|||
"require": "c",
|
||||
"owner": "RunDevelopment"
|
||||
},
|
||||
"hoon": {
|
||||
"title": "Hoon",
|
||||
"owner": "matildepark"
|
||||
},
|
||||
"http": {
|
||||
"title": "HTTP",
|
||||
"optional": [
|
||||
|
|
|
@ -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': /:_|\.[\^\+\*=\?]|![><:\.=\?!]|=[>|:,\.\-\^<+;/~\*\?]|\?[>|:\.\-\^<\+&~=@!]|\|[\$_%:\.\-\^~\*=@\?]|\+[|\$\+\*]|:[_\-\^\+~\*]|%[_:\.\-\^\+~\*=]|\^[|:\.\-\+&~\*=\?]|\$[|_%:<>\-\^&~@=\?]|;[:<\+;\/~\*=]|~[>|\$_%<\+\/&=\?!]|--|==/
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
Prism.languages.hoon={constant:/%(?:\.[ny]|[\w-]+)/,comment:{pattern:/::.*/,greedy:!0},function:/(?:\+[-+] {2})?(?:[a-z](?:[a-z0-9-]*[a-z0-9])?)/,"class-name":[{pattern:/@(?:[A-Za-z0-9-]*[A-Za-z0-9])?/},/\*/],string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},keyword:/:_|\.[\^\+\*=\?]|![><:\.=\?!]|=[>|:,\.\-\^<+;/~\*\?]|\?[>|:\.\-\^<\+&~=@!]|\|[\$_%:\.\-\^~\*=@\?]|\+[|\$\+\*]|:[_\-\^\+~\*]|%[_:\.\-\^\+~\*=]|\^[|:\.\-\+&~\*=\?]|\$[|_%:<>\-\^&~@=\?]|;[:<\+;\/~\*=]|~[>|\$_%<\+\/&=\?!]|--|==/};
|
|
@ -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>
|
|
@ -39,6 +39,11 @@ const testOptions = {
|
|||
word: false,
|
||||
template: false
|
||||
},
|
||||
// Hoon uses _ in its keywords
|
||||
'hoon': {
|
||||
word: false,
|
||||
template: false
|
||||
},
|
||||
|
||||
// LilyPond doesn't tokenize based on words
|
||||
'lilypond': {
|
||||
|
|
|
@ -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.
|
|
@ -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.
|
|
@ -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.
|
Loading…
Reference in New Issue