-
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.
Showing
14 changed files
with
208 additions
and
3 deletions.
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,22 @@ | ||
Prism.languages.ebnf = { | ||
'comment': /\(\*[\s\S]*?\*\)/, | ||
'string': { | ||
pattern: /"[^"\r\n]*"|'[^'\r\n]*'/, | ||
greedy: true | ||
}, | ||
'special': { | ||
pattern: /\?[^?\r\n]*\?/, | ||
greedy: true, | ||
alias: 'class-name' | ||
}, | ||
|
||
'definition': { | ||
pattern: /^(\s*)[a-z]\w*(?:[ \t]+[a-z]\w*)*(?=\s*=)/im, | ||
lookbehind: true, | ||
alias: ['rule', 'keyword'] | ||
}, | ||
'rule': /[a-z]\w*(?:[ \t]+[a-z]\w*)*/i, | ||
|
||
'punctuation': /\([:/]|[:/]\)|[.,;()[\]{}]/, | ||
'operator': /[-=|*/!]/ | ||
}; |
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,63 @@ | ||
<h2>Full example</h2> | ||
<pre><code>SYNTAX = SYNTAX RULE, { SYNTAX RULE } ; | ||
SYNTAX RULE | ||
= META IDENTIFIER, '=', DEFINITIONS LIST, ' ;' ; | ||
DEFINITIONS LIST | ||
= SINGLE DEFINITION, | ||
{ '|', SINGLE DEFINITION } ; | ||
SINGLE DEFINITION = TERM, { ',', TERM } ; | ||
TERM = FACTOR, [ '-', EXCEPTION ] ; | ||
EXCEPTION = FACTOR ; | ||
FACTOR = [ INTEGER, '*' ], PRIMARY ; | ||
PRIMARY | ||
= OPTIONAL SEQUENCE | REPEATED SEQUENCE | ||
| SPECIAL SEQUENCE | GROUPED SEQUENCE | ||
| META IDENTIFIER | TERMINAL | EMPTY ; | ||
EMPTY = ; | ||
OPTIONAL SEQUENCE = '[', DEFINITIONS LIST, ']' ; | ||
REPEATED SEQUENCE = '{', DEFINITIONS LIST, '}' ; | ||
GROUPED SEQUENCE = '(', DEFINITIONS LIST, ')' ; | ||
TERMINAL | ||
= "'", CHARACTER - "'", | ||
{ CHARACTER - "'" }, "'" | ||
| '"', CHARACTER - '"', | ||
{ CHARACTER - '"' }, '"' ; | ||
META IDENTIFIER = LETTER, { LETTER | DIGIT } ; | ||
INTEGER = DIGIT, { DIGIT } ; | ||
SPECIAL SEQUENCE = '?', { CHARACTER - '?' }, '?' ; | ||
COMMENT = '(*', { COMMENT SYMBOL }, '*)' ; | ||
COMMENT SYMBOL | ||
= COMMENT | TERMINAL | SPECIAL SEQUENCE | ||
| CHARACTER ;</code></pre> | ||
|
||
<h2>Full example with alternative syntax</h2> | ||
<pre><code>SYNTAX = SYNTAX RULE, (: SYNTAX RULE :). | ||
SYNTAX RULE | ||
= META IDENTIFIER, '=', DEFINITIONS LIST, '.'. (* '.' instead of ';' *) | ||
DEFINITIONS LIST | ||
= SINGLE DEFINITION, | ||
(: '/', SINGLE DEFINITION :). | ||
SINGLE DEFINITION = TERM, (: ',', TERM :). | ||
TERM = FACTOR, (/ '-', EXCEPTION /). | ||
EXCEPTION = FACTOR. | ||
FACTOR = (/ INTEGER, '*' /), PRIMARY. | ||
PRIMARY | ||
= OPTIONAL SEQUENCE / REPEATED SEQUENCE (* / is the same as | *) | ||
/ SPECIAL SEQUENCE / GROUPED SEQUENCE | ||
/ META IDENTIFIER / TERMINAL / EMPTY. | ||
EMPTY = . | ||
OPTIONAL SEQUENCE = '(/', DEFINITIONS LIST, '/)'. | ||
REPEATED SEQUENCE = '(:', DEFINITIONS LIST, ':)'. | ||
GROUPED SEQUENCE = '(', DEFINITIONS LIST, ')'. | ||
TERMINAL | ||
= "'", CHARACTER - "'", | ||
(: CHARACTER - "'" :), "'" | ||
/ '"', CHARACTER - '"', | ||
(: CHARACTER - '"' :), '"'. | ||
META IDENTIFIER = LETTER, (: LETTER / DIGIT :). | ||
INTEGER = DIGIT, (: DIGIT :). | ||
SPECIAL SEQUENCE = '?', (: CHARACTER - '?' :), '?'. | ||
COMMENT = '(*', (: COMMENT SYMBOL :), '*)'. | ||
COMMENT SYMBOL | ||
= COMMENT / TERMINAL / SPECIAL SEQUENCE | ||
/ CHARACTER.</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,11 @@ | ||
(* comment *) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "(* comment *)"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
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,14 @@ | ||
foo bar = 'a' ; | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["definition", "foo bar"], | ||
["operator", "="], | ||
["string", "'a'"], | ||
["punctuation", ";"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for rules. |
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 @@ | ||
| / ! | ||
* | ||
- | ||
= | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["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,31 @@ | ||
; . | ||
, | ||
() | ||
[] (//) | ||
{} (::) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["punctuation", ";"], | ||
["punctuation", "."], | ||
|
||
["punctuation", ","], | ||
|
||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
["punctuation", "["], | ||
["punctuation", "]"], | ||
["punctuation", "(/"], | ||
["punctuation", "/)"], | ||
|
||
["punctuation", "{"], | ||
["punctuation", "}"], | ||
["punctuation", "(:"], | ||
["punctuation", ":)"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for punctuation. |
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,12 @@ | ||
foo bar; | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["rule", "foo bar"], | ||
["punctuation", ";"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for rules. |
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 @@ | ||
? special characters ? | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["special", "? special characters ?"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for special sequences. |
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,17 @@ | ||
"" | ||
'' | ||
"foo's" | ||
'"bar;' | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["string", "\"\""], | ||
["string", "''"], | ||
["string", "\"foo's\""], | ||
["string", "'\"bar;'"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for strings. |