-
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
Showing
14 changed files
with
305 additions
and
2 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,32 @@ | ||
Prism.languages.reason = Prism.languages.extend('clike', { | ||
'comment': { | ||
pattern: /(^|[^\\])\/\*[\w\W]*?\*\//, | ||
lookbehind: true | ||
}, | ||
'string': { | ||
pattern: /"(\\(?:\r\n|[\s\S])|[^\\\r\n"])*"/, | ||
greedy: true | ||
}, | ||
// 'class-name' must be matched *after* 'constructor' defined below | ||
'class-name': /\b[A-Z]\w*/, | ||
'keyword': /\b(?:and|as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|method|module|mutable|new|nonrec|object|of|open|or|private|rec|sig|struct|switch|then|to|try|type|val|virtual|when|while|with)\b/, | ||
'operator': /\.{3}|:[:=]|=(?:==?|>)?|<=?|>=?|[|^?'#!~`]|[+\-*\/]\.?|\b(?:mod|land|lor|lxor|lsl|lsr|asr)\b/ | ||
}); | ||
Prism.languages.insertBefore('reason', 'class-name', { | ||
'character': { | ||
pattern: /'(?:\\x[\da-f]{2}|\\o[0-3][0-7][0-7]|\\\d{3}|\\.|[^'])'/, | ||
alias: 'string' | ||
}, | ||
'constructor': { | ||
// Negative look-ahead prevents from matching things like String.capitalize | ||
pattern: /\b[A-Z]\w*\b(?!\s*\.)/, | ||
alias: 'variable' | ||
}, | ||
'label': { | ||
pattern: /\b[a-z]\w*(?=::)/, | ||
alias: 'symbol' | ||
} | ||
}); | ||
|
||
// We can't match functions property, so let's not even try. | ||
delete Prism.languages.reason.function; |
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,38 @@ | ||
<h1>Reason</h1> | ||
<p>To use this language, use the class "language-reason".</p> | ||
|
||
<h2>Comments</h2> | ||
<pre><code>/* This is a comment */</code></pre> | ||
|
||
<h2>Strings and characters</h2> | ||
<pre><code>"This is a \"string\"" | ||
'a' | ||
'\\' | ||
'\o123' | ||
'\x4a'</code></pre> | ||
|
||
<h2>Constructors</h2> | ||
<pre><code>type response = | ||
| Yes | ||
| No | ||
| PrettyMuch;</code></pre> | ||
|
||
<h2>Example</h2> | ||
<pre><code>type car = {maker: string, model: string}; | ||
type carList = | ||
| List car carList | ||
| NoMore; | ||
|
||
let chevy = {maker: "Chevy", model: "Suburban"}; | ||
let toyota = {maker: "Toyota", model: "Tacoma"}; | ||
let myCarList = List chevy (List toyota NoMore); | ||
|
||
let hasExactlyTwoCars = fun lst => | ||
switch lst { | ||
| NoMore => false /* 0 */ | ||
| List p NoMore => false /* 1 */ | ||
| List p (List p2 NoMore) => true /* 2 */ | ||
| List p (List p2 (List p3 theRest)) => false /* 3+ */ | ||
}; | ||
|
||
let justTwo = hasExactlyTwoCars myCarList; /* true! */</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
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,19 @@ | ||
'a' | ||
'\'' | ||
'\\' | ||
'\xff' | ||
'\o214' | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["character", "'a'"], | ||
["character", "'\\''"], | ||
["character", "'\\\\'"], | ||
["character", "'\\xff'"], | ||
["character", "'\\o214'"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for 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,15 @@ | ||
String.foo | ||
Foo_bar.baz | ||
A.bar | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["class-name", "String"], ["punctuation", "."], "foo\r\n", | ||
["class-name", "Foo_bar"], ["punctuation", "."], "baz\r\n", | ||
["class-name", "A"], ["punctuation", "."], "bar" | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for class 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,20 @@ | ||
/**/ | ||
/* Single line comment */ | ||
/* Multiline | ||
comment */ | ||
/** | ||
Doc comment | ||
*/ | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "/**/"], | ||
["comment", "/* Single line comment */"], | ||
["comment", "/* Multiline\r\ncomment */"], | ||
["comment", "/**\r\nDoc comment\r\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,15 @@ | ||
Yes | ||
Foo_bar | ||
A | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["constructor", "Yes"], | ||
["constructor", "Foo_bar"], | ||
["constructor", "A"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for constructors. |
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 @@ | ||
and | ||
as | ||
assert | ||
begin | ||
class | ||
constraint | ||
do | ||
done | ||
downto | ||
else | ||
end | ||
exception | ||
external | ||
for | ||
fun | ||
function | ||
functor | ||
if | ||
in | ||
include | ||
inherit | ||
initializer | ||
lazy | ||
let | ||
method | ||
module | ||
mutable | ||
new | ||
nonrec | ||
object | ||
of | ||
open | ||
or | ||
private | ||
rec | ||
sig | ||
struct | ||
switch | ||
then | ||
to | ||
try | ||
type | ||
val | ||
virtual | ||
when | ||
while | ||
with | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "and"], | ||
["keyword", "as"], | ||
["keyword", "assert"], | ||
["keyword", "begin"], | ||
["keyword", "class"], | ||
["keyword", "constraint"], | ||
["keyword", "do"], | ||
["keyword", "done"], | ||
["keyword", "downto"], | ||
["keyword", "else"], | ||
["keyword", "end"], | ||
["keyword", "exception"], | ||
["keyword", "external"], | ||
["keyword", "for"], | ||
["keyword", "fun"], | ||
["keyword", "function"], | ||
["keyword", "functor"], | ||
["keyword", "if"], | ||
["keyword", "in"], | ||
["keyword", "include"], | ||
["keyword", "inherit"], | ||
["keyword", "initializer"], | ||
["keyword", "lazy"], | ||
["keyword", "let"], | ||
["keyword", "method"], | ||
["keyword", "module"], | ||
["keyword", "mutable"], | ||
["keyword", "new"], | ||
["keyword", "nonrec"], | ||
["keyword", "object"], | ||
["keyword", "of"], | ||
["keyword", "open"], | ||
["keyword", "or"], | ||
["keyword", "private"], | ||
["keyword", "rec"], | ||
["keyword", "sig"], | ||
["keyword", "struct"], | ||
["keyword", "switch"], | ||
["keyword", "then"], | ||
["keyword", "to"], | ||
["keyword", "try"], | ||
["keyword", "type"], | ||
["keyword", "val"], | ||
["keyword", "virtual"], | ||
["keyword", "when"], | ||
["keyword", "while"], | ||
["keyword", "with"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
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,13 @@ | ||
foo::bar | ||
a::baz | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["label", "foo"], ["operator", "::"], "bar\r\n", | ||
["label", "a"], ["operator", "::"], "baz" | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for 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,29 @@ | ||
... | ||
:: := | ||
= == === | ||
< <= > >= | ||
| ^ ? ' | ||
# ! ~ ` | ||
+ - * / | ||
+. -. *. /. | ||
mod land lor lxor | ||
lsl lsr asr | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["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", "mod"], ["operator", "land"], ["operator", "lor"], ["operator", "lxor"], | ||
["operator", "lsl"], ["operator", "lsr"], ["operator", "asr"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
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,13 @@ | ||
"" | ||
"foo\"bar" | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["string", "\"\""], | ||
["string", "\"foo\\\"bar\""] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for strings. |