-
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.
Merge pull request #805 from Golmote/prism-oz
Add support for Oz
- Loading branch information
Showing
13 changed files
with
398 additions
and
0 deletions.
There are no files selected for viewing
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,21 @@ | ||
Prism.languages.oz = { | ||
'comment': /\/\*[\s\S]*?\*\/|%.*/, | ||
'string': /"(?:[^"\\]|\\[\s\S])*"/, | ||
'atom': { | ||
pattern: /'(?:[^'\\]|\\.)*'/, | ||
alias: 'builtin' | ||
}, | ||
'keyword': /[$_]|\[\]|\b(?:at|attr|case|catch|choice|class|cond|declare|define|dis|else(?:case|if)?|end|export|fail|false|feat|finally|from|fun|functor|if|import|in|local|lock|meth|nil|not|of|or|prepare|proc|prop|raise|require|self|skip|then|thread|true|try|unit)\b/, | ||
'function': [ | ||
/[a-z][A-Za-z\d]*(?=\()/, | ||
{ | ||
pattern: /(\{)[A-Z][A-Za-z\d]*/, | ||
lookbehind: true | ||
} | ||
], | ||
'number': /\b(?:0[bx][\da-f]+|\d+\.?\d*(?:e~?\d+)?\b)|&(?:[^\\]|\\(?:\d{3}|.))/i, | ||
'variable': /\b[A-Z][A-Za-z\d]*|`(?:[^`\\]|\\.)+`/, | ||
'attr-name': /\w+(?=:)/, | ||
'operator': /:(?:=|::?)|<[-:=]?|=(?:=|<?:?)|>=?:?|\\=:?|!!?|[|#+\-*\/,~^@]|\b(?:andthen|div|mod|orelse)\b/, | ||
'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,107 @@ | ||
<h1>Oz</h1> | ||
<p>To use this language, use the class "language-oz".</p> | ||
|
||
<h2>Comments</h2> | ||
<pre><code>% | ||
% Foobar | ||
|
||
/* Foo | ||
bar */</code></pre> | ||
|
||
<h2>Strings</h2> | ||
<pre><code>"" | ||
"Foo \"bar\" baz"</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code>0 | ||
42 | ||
0154 | ||
0xBadFace | ||
0B0101 | ||
3.14159 | ||
2e8 | ||
3.E~7 | ||
4.8E12 | ||
&0 | ||
&a | ||
&\n | ||
&\124</code></pre> | ||
|
||
<h2>Functions and procedures</h2> | ||
<pre><code>proc {Max X Y Z} | ||
{Browse Z} | ||
f(M Y)</code></pre> | ||
|
||
<h2>Full example</h2> | ||
<pre><code>proc {DisMember X Ys} | ||
dis Ys = X|_ [] Yr in Ys = _|Yr {DisMember X Yr} end | ||
end | ||
|
||
class DataBase from BaseObject | ||
attr d | ||
meth init | ||
d := {NewDictionary} | ||
end | ||
meth dic($) @d end | ||
meth tell(I) | ||
case {IsFree I.1} then | ||
raise database(nonground(I)) end | ||
else | ||
Is = {Dictionary.condGet @d I.1 nil} in | ||
{Dictionary.put @d I.1 {Append Is [I]}} | ||
end | ||
end | ||
meth ask(I) | ||
case {IsFree I} orelse {IsFree I.1} then | ||
{DisMember I {Flatten {Dictionary.items @d}}} | ||
else | ||
{DisMember I {Dictionary.condGet @d I.1 nil}} | ||
end | ||
end | ||
meth entries($) | ||
{Dictionary.entries @d} | ||
end | ||
end | ||
|
||
declare | ||
proc {Dynamic ?Pred} | ||
Pred = {New DataBase init} | ||
end | ||
proc {Assert P I} | ||
{P tell(I)} | ||
end | ||
proc {Query P I} | ||
{P ask(I)} | ||
end | ||
|
||
EdgeP = {Dynamic} | ||
{ForAll | ||
[edge(1 2) | ||
edge(2 1) % Cycle | ||
edge(2 3) | ||
edge(3 4) | ||
edge(2 5) | ||
edge(5 6) | ||
edge(4 6) | ||
edge(6 7) | ||
edge(6 8) | ||
edge(1 5) | ||
edge(5 1) % Cycle | ||
] | ||
proc {$ I} {Assert EdgeP I} end | ||
}</code></pre> | ||
|
||
<h2>Known failures</h2> | ||
<p>There are certain edge cases where Prism will fail. | ||
There are always such cases in every regex-based syntax highlighter. | ||
However, Prism dares to be open and honest about them. | ||
If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug. | ||
</p> | ||
|
||
<h3>Comment-like substrings</h3> | ||
<pre><code>"foo /* bar */ baz" | ||
"foo % bar"</code></pre> | ||
|
||
<h3>Atoms containing comment chars</h3> | ||
<pre><code>'foo /* bar */ baz' | ||
'foo % bar'</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'' | ||
'fo\'obar' | ||
'foo | ||
bar' | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["atom", "''"], | ||
["atom", "'fo\\'obar'"], | ||
["atom", "'foo\r\nbar'"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for atoms. |
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,14 @@ | ||
menubutton(text:'Test' underline:0) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "menubutton"], ["punctuation", "("], | ||
["attr-name", "text"], ["punctuation", ":"], ["atom", "'Test'"], | ||
["attr-name", "underline"], ["punctuation", ":"], ["number", "0"], | ||
["punctuation", ")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for parameter names. |
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,18 @@ | ||
% | ||
% Foobar | ||
/**/ | ||
/* Foo | ||
bar */ | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "%"], | ||
["comment", "% Foobar"], | ||
["comment", "/**/"], | ||
["comment", "/* Foo\r\nbar */"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for 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,13 @@ | ||
foobar() | ||
{Foobar} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "foobar"], ["punctuation", "("], ["punctuation", ")"], | ||
["punctuation", "{"], ["function", "Foobar"], ["punctuation", "}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for functions and procedures. |
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,103 @@ | ||
$ | ||
_ | ||
[] | ||
at | ||
attr | ||
case | ||
catch | ||
choice | ||
class | ||
cond | ||
declare | ||
define | ||
dis | ||
else | ||
elsecase | ||
elseif | ||
end | ||
export | ||
fail | ||
false | ||
feat | ||
finally | ||
from | ||
fun | ||
functor | ||
if | ||
import | ||
in | ||
local | ||
lock | ||
meth | ||
nil | ||
not | ||
of | ||
or | ||
prepare | ||
proc | ||
prop | ||
raise | ||
require | ||
self | ||
skip | ||
then | ||
thread | ||
true | ||
try | ||
unit | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "$"], | ||
["keyword", "_"], | ||
["keyword", "[]"], | ||
["keyword", "at"], | ||
["keyword", "attr"], | ||
["keyword", "case"], | ||
["keyword", "catch"], | ||
["keyword", "choice"], | ||
["keyword", "class"], | ||
["keyword", "cond"], | ||
["keyword", "declare"], | ||
["keyword", "define"], | ||
["keyword", "dis"], | ||
["keyword", "else"], | ||
["keyword", "elsecase"], | ||
["keyword", "elseif"], | ||
["keyword", "end"], | ||
["keyword", "export"], | ||
["keyword", "fail"], | ||
["keyword", "false"], | ||
["keyword", "feat"], | ||
["keyword", "finally"], | ||
["keyword", "from"], | ||
["keyword", "fun"], | ||
["keyword", "functor"], | ||
["keyword", "if"], | ||
["keyword", "import"], | ||
["keyword", "in"], | ||
["keyword", "local"], | ||
["keyword", "lock"], | ||
["keyword", "meth"], | ||
["keyword", "nil"], | ||
["keyword", "not"], | ||
["keyword", "of"], | ||
["keyword", "or"], | ||
["keyword", "prepare"], | ||
["keyword", "proc"], | ||
["keyword", "prop"], | ||
["keyword", "raise"], | ||
["keyword", "require"], | ||
["keyword", "self"], | ||
["keyword", "skip"], | ||
["keyword", "then"], | ||
["keyword", "thread"], | ||
["keyword", "true"], | ||
["keyword", "try"], | ||
["keyword", "unit"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for 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,35 @@ | ||
0 | ||
42 | ||
0154 | ||
0xBadFace | ||
0B0101 | ||
3.14159 | ||
2e8 | ||
3.E~7 | ||
4.8E12 | ||
&0 | ||
&a | ||
&\n | ||
&\124 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["number", "0"], | ||
["number", "42"], | ||
["number", "0154"], | ||
["number", "0xBadFace"], | ||
["number", "0B0101"], | ||
["number", "3.14159"], | ||
["number", "2e8"], | ||
["number", "3.E~7"], | ||
["number", "4.8E12"], | ||
["number", "&0"], | ||
["number", "&a"], | ||
["number", "&\\n"], | ||
["number", "&\\124"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for 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,35 @@ | ||
:= :: ::: | ||
< <- <: <= | ||
= == =: =< =<: | ||
> >= >: >=: | ||
\= \=: | ||
! !! | ||
| # + - | ||
* / , ~ | ||
^ @ | ||
andthen | ||
div | ||
mod | ||
orelse | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["operator", ":="], ["operator", "::"], ["operator", ":::"], | ||
["operator", "<"], ["operator", "<-"], ["operator", "<:"], ["operator", "<="], | ||
["operator", "="], ["operator", "=="], ["operator", "=:"], ["operator", "=<"], ["operator", "=<:"], | ||
["operator", ">"], ["operator", ">="], ["operator", ">:"], ["operator", ">=:"], | ||
["operator", "\\="], ["operator", "\\=:"], | ||
["operator", "!"], ["operator", "!!"], | ||
["operator", "|"], ["operator", "#"], ["operator", "+"], ["operator", "-"], | ||
["operator", "*"], ["operator", "/"], ["operator", ","], ["operator", "~"], | ||
["operator", "^"], ["operator", "@"], | ||
["operator", "andthen"], | ||
["operator", "div"], | ||
["operator", "mod"], | ||
["operator", "orelse"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for operators. |
Oops, something went wrong.