diff --git a/components.js b/components.js index b2adddfdf9..596e73ceeb 100644 --- a/components.js +++ b/components.js @@ -333,6 +333,10 @@ var components = { "title": "OCaml", "owner": "Golmote" }, + "oz": { + "title": "Oz", + "owner": "Golmote" + }, "parigp": { "title": "PARI/GP", "owner": "Golmote" diff --git a/components/prism-oz.js b/components/prism-oz.js new file mode 100644 index 0000000000..f0fddea8cf --- /dev/null +++ b/components/prism-oz.js @@ -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': /[\[\](){}.:;?]/ +}; \ No newline at end of file diff --git a/components/prism-oz.min.js b/components/prism-oz.min.js new file mode 100644 index 0000000000..fb4327218f --- /dev/null +++ b/components/prism-oz.min.js @@ -0,0 +1 @@ +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:!0}],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:/[\[\](){}.:;?]/}; \ No newline at end of file diff --git a/examples/prism-oz.html b/examples/prism-oz.html new file mode 100644 index 0000000000..732821a9bb --- /dev/null +++ b/examples/prism-oz.html @@ -0,0 +1,107 @@ +
To use this language, use the class "language-oz".
+ +%
+% Foobar
+
+/* Foo
+bar */
+
+""
+"Foo \"bar\" baz"
+
+0
+42
+0154
+0xBadFace
+0B0101
+3.14159
+2e8
+3.E~7
+4.8E12
+&0
+&a
+&\n
+&\124
+
+proc {Max X Y Z}
+{Browse Z}
+f(M Y)
+
+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
+}
+
+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. +
+ +"foo /* bar */ baz"
+"foo % bar"
+
+'foo /* bar */ baz'
+'foo % bar'
\ No newline at end of file
diff --git a/tests/languages/oz/atom_feature.test b/tests/languages/oz/atom_feature.test
new file mode 100644
index 0000000000..b249537e00
--- /dev/null
+++ b/tests/languages/oz/atom_feature.test
@@ -0,0 +1,16 @@
+''
+'fo\'obar'
+'foo
+bar'
+
+----------------------------------------------------
+
+[
+ ["atom", "''"],
+ ["atom", "'fo\\'obar'"],
+ ["atom", "'foo\r\nbar'"]
+]
+
+----------------------------------------------------
+
+Checks for atoms.
\ No newline at end of file
diff --git a/tests/languages/oz/attr-name_feature.test b/tests/languages/oz/attr-name_feature.test
new file mode 100644
index 0000000000..46dc2221e2
--- /dev/null
+++ b/tests/languages/oz/attr-name_feature.test
@@ -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.
\ No newline at end of file
diff --git a/tests/languages/oz/comment_feature.test b/tests/languages/oz/comment_feature.test
new file mode 100644
index 0000000000..736eba24da
--- /dev/null
+++ b/tests/languages/oz/comment_feature.test
@@ -0,0 +1,18 @@
+%
+% Foobar
+/**/
+/* Foo
+bar */
+
+----------------------------------------------------
+
+[
+ ["comment", "%"],
+ ["comment", "% Foobar"],
+ ["comment", "/**/"],
+ ["comment", "/* Foo\r\nbar */"]
+]
+
+----------------------------------------------------
+
+Checks for comments.
\ No newline at end of file
diff --git a/tests/languages/oz/function_feature.test b/tests/languages/oz/function_feature.test
new file mode 100644
index 0000000000..05e256890e
--- /dev/null
+++ b/tests/languages/oz/function_feature.test
@@ -0,0 +1,13 @@
+foobar()
+{Foobar}
+
+----------------------------------------------------
+
+[
+ ["function", "foobar"], ["punctuation", "("], ["punctuation", ")"],
+ ["punctuation", "{"], ["function", "Foobar"], ["punctuation", "}"]
+]
+
+----------------------------------------------------
+
+Checks for functions and procedures.
\ No newline at end of file
diff --git a/tests/languages/oz/keyword_feature.test b/tests/languages/oz/keyword_feature.test
new file mode 100644
index 0000000000..2fdc28accb
--- /dev/null
+++ b/tests/languages/oz/keyword_feature.test
@@ -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.
\ No newline at end of file
diff --git a/tests/languages/oz/number_feature.test b/tests/languages/oz/number_feature.test
new file mode 100644
index 0000000000..d7b2ff97fa
--- /dev/null
+++ b/tests/languages/oz/number_feature.test
@@ -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.
\ No newline at end of file
diff --git a/tests/languages/oz/operator_feature.test b/tests/languages/oz/operator_feature.test
new file mode 100644
index 0000000000..b1baf3711e
--- /dev/null
+++ b/tests/languages/oz/operator_feature.test
@@ -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.
\ No newline at end of file
diff --git a/tests/languages/oz/string_feature.test b/tests/languages/oz/string_feature.test
new file mode 100644
index 0000000000..a7550e8dc3
--- /dev/null
+++ b/tests/languages/oz/string_feature.test
@@ -0,0 +1,16 @@
+""
+"Fo\"obar"
+"Foo
+bar"
+
+----------------------------------------------------
+
+[
+ ["string", "\"\""],
+ ["string", "\"Fo\\\"obar\""],
+ ["string", "\"Foo\r\nbar\""]
+]
+
+----------------------------------------------------
+
+Checks for strings.
\ No newline at end of file
diff --git a/tests/languages/oz/variable_feature.test b/tests/languages/oz/variable_feature.test
new file mode 100644
index 0000000000..51274d6637
--- /dev/null
+++ b/tests/languages/oz/variable_feature.test
@@ -0,0 +1,15 @@
+A
+Foobar
+Foo42
+
+----------------------------------------------------
+
+[
+ ["variable", "A"],
+ ["variable", "Foobar"],
+ ["variable", "Foo42"]
+]
+
+----------------------------------------------------
+
+Checks for variables.
\ No newline at end of file