-
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.
- Loading branch information
1 parent
453079b
commit 649e51e
Showing
16 changed files
with
398 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,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; |
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,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> |
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 @@ | ||
False | ||
True | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["boolean", "False"], | ||
["boolean", "True"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for Bool literals. |
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,20 @@ | ||
-- comment | ||
|
||
{- | ||
comment | ||
{- | ||
nested comment | ||
-} | ||
-} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "-- comment"], | ||
|
||
["comment", "{-\n\tcomment\n\t{-\n\t\tnested comment\n\t-}\n-}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
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,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. |
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,15 @@ | ||
sha256:33f7f4c3aff62e5ecf4848f964363133452d420dcde045784518fb59fa970037 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["hash", [ | ||
["function", "sha256"], | ||
["operator", ":"], | ||
["number", "33f7f4c3aff62e5ecf4848f964363133452d420dcde045784518fb59fa970037"] | ||
]] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for sha256 hashes. |
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,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. |
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,11 @@ | ||
`"foo"'s 123` | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["label", "`\"foo\"'s 123`"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for escaped labels. |
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 | ||
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. |
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,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. |
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,23 @@ | ||
. .. / | ||
|
||
{ } [ ] ( ) , | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["punctuation", "."], | ||
["punctuation", ".."], | ||
["punctuation", "/"], | ||
|
||
["punctuation", "{"], | ||
["punctuation", "}"], | ||
["punctuation", "["], | ||
["punctuation", "]"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
["punctuation", ","] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for punctuation. |
Oops, something went wrong.