Added support for Dhall (#2473)
This commit is contained in:
parent
453079bf96
commit
649e51e562
File diff suppressed because one or more lines are too long
|
@ -275,6 +275,10 @@
|
|||
"title": "DAX",
|
||||
"owner": "peterbud"
|
||||
},
|
||||
"dhall": {
|
||||
"title": "Dhall",
|
||||
"owner": "RunDevelopment"
|
||||
},
|
||||
"diff": {
|
||||
"title": "Diff",
|
||||
"owner": "uranusjr"
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
// ABNF grammar:
|
||||
// https://github.com/dhall-lang/dhall-lang/blob/master/standard/dhall.abnf
|
||||
|
||||
Prism.languages.dhall = {
|
||||
// Multi-line comments can be nested. E.g. {- foo {- bar -} -}
|
||||
// The multi-line pattern is essentially this:
|
||||
// \{-(?:[^-{]|-(?!\})|\{(?!-)|<SELF>)*-\}
|
||||
'comment': /--.*|\{-(?:[^-{]|-(?!\})|\{(?!-)|\{-(?:[^-{]|-(?!\})|\{(?!-))*-\})*-\}/,
|
||||
'string': {
|
||||
pattern: /"(?:[^"\\]|\\.)*"|''(?:[^']|'(?!')|'''|''\$\{)*''(?!'|\$)/,
|
||||
greedy: true,
|
||||
inside: {
|
||||
'interpolation': {
|
||||
pattern: /\$\{[^{}]*\}/,
|
||||
inside: {
|
||||
'expression': {
|
||||
pattern: /(^\$\{)[\s\S]+(?=\}$)/,
|
||||
lookbehind: true,
|
||||
alias: 'language-dhall',
|
||||
inside: null // see blow
|
||||
},
|
||||
'punctuation': /\$\{|\}/
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'label': {
|
||||
pattern: /`[^`]*`/,
|
||||
greedy: true
|
||||
},
|
||||
'url': {
|
||||
// https://github.com/dhall-lang/dhall-lang/blob/5fde8ef1bead6fb4e999d3c1ffe7044cd019d63a/standard/dhall.abnf#L596
|
||||
pattern: /\bhttps?:\/\/[\w.:%!$&'*+;=@~-]+(?:\/[\w.:%!$&'*+;=@~-]*)*(?:\?[/?\w.:%!$&'*+;=@~-]*)?/,
|
||||
greedy: true
|
||||
},
|
||||
'env': {
|
||||
// https://github.com/dhall-lang/dhall-lang/blob/5fde8ef1bead6fb4e999d3c1ffe7044cd019d63a/standard/dhall.abnf#L661
|
||||
pattern: /\benv:(?:(?!\d)\w+|"(?:[^"\\=]|\\.)*")/,
|
||||
greedy: true,
|
||||
inside: {
|
||||
'function': /^env/,
|
||||
'operator': /^:/,
|
||||
'variable': /[\s\S]+/
|
||||
}
|
||||
},
|
||||
'hash': {
|
||||
// https://github.com/dhall-lang/dhall-lang/blob/5fde8ef1bead6fb4e999d3c1ffe7044cd019d63a/standard/dhall.abnf#L725
|
||||
pattern: /\bsha256:[\da-fA-F]{64}\b/,
|
||||
inside: {
|
||||
'function': /sha256/,
|
||||
'operator': /:/,
|
||||
'number': /[\da-fA-F]{64}/
|
||||
}
|
||||
},
|
||||
|
||||
// https://github.com/dhall-lang/dhall-lang/blob/5fde8ef1bead6fb4e999d3c1ffe7044cd019d63a/standard/dhall.abnf#L359
|
||||
'keyword': /\b(?:as|assert|else|forall|if|in|let|merge|missing|then|toMap|using|with)\b|\u2200/,
|
||||
'builtin': /\b(?:Some|None)\b/,
|
||||
|
||||
'boolean': /\b(?:False|True)\b/,
|
||||
'number': /\bNaN\b|-?\bInfinity\b|[+-]?\b(?:0x[\da-fA-F]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/,
|
||||
'operator': /\/\\|\/\/\\\\|&&|\|\||[!=]=|===|\/\/|->|\+\+|::|[+*#@=:?<>|\\\u2227\u2a53\u2261\u2afd\u03bb\u2192]/,
|
||||
'punctuation': /\.\.|[{}\[\](),./]/,
|
||||
|
||||
// we'll just assume that every capital word left is a type name
|
||||
'class-name': /\b[A-Z]\w*\b/
|
||||
};
|
||||
|
||||
Prism.languages.dhall.string.inside.interpolation.inside.expression.inside = Prism.languages.dhall;
|
|
@ -0,0 +1 @@
|
|||
Prism.languages.dhall={comment:/--.*|\{-(?:[^-{]|-(?!\})|\{(?!-)|\{-(?:[^-{]|-(?!\})|\{(?!-))*-\})*-\}/,string:{pattern:/"(?:[^"\\]|\\.)*"|''(?:[^']|'(?!')|'''|''\$\{)*''(?!'|\$)/,greedy:!0,inside:{interpolation:{pattern:/\$\{[^{}]*\}/,inside:{expression:{pattern:/(^\$\{)[\s\S]+(?=\}$)/,lookbehind:!0,alias:"language-dhall",inside:null},punctuation:/\$\{|\}/}}}},label:{pattern:/`[^`]*`/,greedy:!0},url:{pattern:/\bhttps?:\/\/[\w.:%!$&'*+;=@~-]+(?:\/[\w.:%!$&'*+;=@~-]*)*(?:\?[/?\w.:%!$&'*+;=@~-]*)?/,greedy:!0},env:{pattern:/\benv:(?:(?!\d)\w+|"(?:[^"\\=]|\\.)*")/,greedy:!0,inside:{function:/^env/,operator:/^:/,variable:/[\s\S]+/}},hash:{pattern:/\bsha256:[\da-fA-F]{64}\b/,inside:{function:/sha256/,operator:/:/,number:/[\da-fA-F]{64}/}},keyword:/\b(?:as|assert|else|forall|if|in|let|merge|missing|then|toMap|using|with)\b|\u2200/,builtin:/\b(?:Some|None)\b/,boolean:/\b(?:False|True)\b/,number:/\bNaN\b|-?\bInfinity\b|[+-]?\b(?:0x[\da-fA-F]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/,operator:/\/\\|\/\/\\\\|&&|\|\||[!=]=|===|\/\/|->|\+\+|::|[+*#@=:?<>|\\\u2227\u2a53\u2261\u2afd\u03bb\u2192]/,punctuation:/\.\.|[{}\[\](),./]/,"class-name":/\b[A-Z]\w*\b/},Prism.languages.dhall.string.inside.interpolation.inside.expression.inside=Prism.languages.dhall;
|
|
@ -0,0 +1,30 @@
|
|||
<h2>Full example</h2>
|
||||
<pre><code>
|
||||
-- source: https://github.com/dhall-lang/dhall-lang/blob/master/Prelude/Optional/head.dhall
|
||||
|
||||
{-
|
||||
Returns the first non-empty `Optional` value in a `List`
|
||||
-}
|
||||
let head
|
||||
: ∀(a : Type) → List (Optional a) → Optional a
|
||||
= λ(a : Type) →
|
||||
λ(xs : List (Optional a)) →
|
||||
List/fold
|
||||
(Optional a)
|
||||
xs
|
||||
(Optional a)
|
||||
( λ(l : Optional a) →
|
||||
λ(r : Optional a) →
|
||||
merge { Some = λ(x : a) → Some x, None = r } l
|
||||
)
|
||||
(None a)
|
||||
|
||||
let example0 = assert : head Natural [ None Natural, Some 1, Some 2 ] ≡ Some 1
|
||||
|
||||
let example1 =
|
||||
assert : head Natural [ None Natural, None Natural ] ≡ None Natural
|
||||
|
||||
let example2 =
|
||||
assert : head Natural ([] : List (Optional Natural)) ≡ None Natural
|
||||
|
||||
in head</code></pre>
|
|
@ -0,0 +1,13 @@
|
|||
False
|
||||
True
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["boolean", "False"],
|
||||
["boolean", "True"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for Bool literals.
|
|
@ -0,0 +1,20 @@
|
|||
-- comment
|
||||
|
||||
{-
|
||||
comment
|
||||
{-
|
||||
nested comment
|
||||
-}
|
||||
-}
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["comment", "-- comment"],
|
||||
|
||||
["comment", "{-\n\tcomment\n\t{-\n\t\tnested comment\n\t-}\n-}"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for comments.
|
|
@ -0,0 +1,21 @@
|
|||
env:DHALL_PRELUDE
|
||||
env:"Quotes variable"
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["env", [
|
||||
["function", "env"],
|
||||
["operator", ":"],
|
||||
["variable", "DHALL_PRELUDE"]
|
||||
]],
|
||||
["env", [
|
||||
["function", "env"],
|
||||
["operator", ":"],
|
||||
["variable", "\"Quotes variable\""]
|
||||
]]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for environment variables.
|
|
@ -0,0 +1,15 @@
|
|||
sha256:33f7f4c3aff62e5ecf4848f964363133452d420dcde045784518fb59fa970037
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["hash", [
|
||||
["function", "sha256"],
|
||||
["operator", ":"],
|
||||
["number", "33f7f4c3aff62e5ecf4848f964363133452d420dcde045784518fb59fa970037"]
|
||||
]]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for sha256 hashes.
|
|
@ -0,0 +1,39 @@
|
|||
as
|
||||
assert
|
||||
else
|
||||
forall
|
||||
if
|
||||
in
|
||||
let
|
||||
merge
|
||||
missing
|
||||
then
|
||||
toMap
|
||||
using
|
||||
with
|
||||
|
||||
∀
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["keyword", "as"],
|
||||
["keyword", "assert"],
|
||||
["keyword", "else"],
|
||||
["keyword", "forall"],
|
||||
["keyword", "if"],
|
||||
["keyword", "in"],
|
||||
["keyword", "let"],
|
||||
["keyword", "merge"],
|
||||
["keyword", "missing"],
|
||||
["keyword", "then"],
|
||||
["keyword", "toMap"],
|
||||
["keyword", "using"],
|
||||
["keyword", "with"],
|
||||
|
||||
["keyword", "∀"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for keywords.
|
|
@ -0,0 +1,11 @@
|
|||
`"foo"'s 123`
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["label", "`\"foo\"'s 123`"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for escaped labels.
|
|
@ -0,0 +1,35 @@
|
|||
0
|
||||
123
|
||||
123e-5
|
||||
-123e+2
|
||||
123.456
|
||||
+123.456e-7
|
||||
0xFF
|
||||
-0xFF
|
||||
+0xFF
|
||||
|
||||
Infinity
|
||||
-Infinity
|
||||
NaN
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["number", "0"],
|
||||
["number", "123"],
|
||||
["number", "123e-5"],
|
||||
["number", "-123e+2"],
|
||||
["number", "123.456"],
|
||||
["number", "+123.456e-7"],
|
||||
["number", "0xFF"],
|
||||
["number", "-0xFF"],
|
||||
["number", "+0xFF"],
|
||||
|
||||
["number", "Infinity"],
|
||||
["number", "-Infinity"],
|
||||
["number", "NaN"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for numeric literals.
|
|
@ -0,0 +1,44 @@
|
|||
/\ //\\ && || != == == // -> ++ ::
|
||||
|
||||
+ * # | = : ? < > | \
|
||||
|
||||
∧ ⩓ ≡ ⫽ λ →
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["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", "→"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for operators.
|
|
@ -0,0 +1,23 @@
|
|||
. .. /
|
||||
|
||||
{ } [ ] ( ) ,
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["punctuation", "."],
|
||||
["punctuation", ".."],
|
||||
["punctuation", "/"],
|
||||
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", "["],
|
||||
["punctuation", "]"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["punctuation", ","]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for punctuation.
|
|
@ -0,0 +1,61 @@
|
|||
""
|
||||
"foo"
|
||||
"\""
|
||||
|
||||
"foo/${bar}"
|
||||
|
||||
''foo''
|
||||
''bar'''baz''
|
||||
|
||||
''
|
||||
foo/${bar}
|
||||
''
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["string", [
|
||||
"\"\""
|
||||
]],
|
||||
["string", [
|
||||
"\"foo\""
|
||||
]],
|
||||
["string", [
|
||||
"\"\\\"\""
|
||||
]],
|
||||
|
||||
["string", [
|
||||
"\"foo/",
|
||||
["interpolation", [
|
||||
["punctuation", "${"],
|
||||
["expression", [
|
||||
"bar"
|
||||
]],
|
||||
["punctuation", "}"]
|
||||
]],
|
||||
"\""
|
||||
]],
|
||||
|
||||
["string", [
|
||||
"''foo''"
|
||||
]],
|
||||
["string", [
|
||||
"''bar'''baz''"
|
||||
]],
|
||||
|
||||
["string", [
|
||||
"''\nfoo/",
|
||||
["interpolation", [
|
||||
["punctuation", "${"],
|
||||
["expression", [
|
||||
"bar"
|
||||
]],
|
||||
["punctuation", "}"]
|
||||
]],
|
||||
"\n''"
|
||||
]]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for strings.
|
|
@ -0,0 +1,11 @@
|
|||
https://prelude.dhall-lang.org/Natural/sum
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["url", "https://prelude.dhall-lang.org/Natural/sum"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for URL literals.
|
Loading…
Reference in New Issue