main
Last change
on this file since 748b7f6 was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
989 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | /*
|
---|
| 2 | Language: Extended Backus-Naur Form
|
---|
| 3 | Author: Alex McKibben <alex@nullscope.net>
|
---|
| 4 | Website: https://en.wikipedia.org/wiki/Extended_Backus–Naur_form
|
---|
| 5 | */
|
---|
| 6 |
|
---|
| 7 | /** @type LanguageFn */
|
---|
| 8 | function ebnf(hljs) {
|
---|
| 9 | const commentMode = hljs.COMMENT(/\(\*/, /\*\)/);
|
---|
| 10 |
|
---|
| 11 | const nonTerminalMode = {
|
---|
| 12 | className: "attribute",
|
---|
| 13 | begin: /^[ ]*[a-zA-Z]+([\s_-]+[a-zA-Z]+)*/
|
---|
| 14 | };
|
---|
| 15 |
|
---|
| 16 | const specialSequenceMode = {
|
---|
| 17 | className: "meta",
|
---|
| 18 | begin: /\?.*\?/
|
---|
| 19 | };
|
---|
| 20 |
|
---|
| 21 | const ruleBodyMode = {
|
---|
| 22 | begin: /=/,
|
---|
| 23 | end: /[.;]/,
|
---|
| 24 | contains: [
|
---|
| 25 | commentMode,
|
---|
| 26 | specialSequenceMode,
|
---|
| 27 | {
|
---|
| 28 | // terminals
|
---|
| 29 | className: 'string',
|
---|
| 30 | variants: [
|
---|
| 31 | hljs.APOS_STRING_MODE,
|
---|
| 32 | hljs.QUOTE_STRING_MODE,
|
---|
| 33 | {
|
---|
| 34 | begin: '`',
|
---|
| 35 | end: '`'
|
---|
| 36 | }
|
---|
| 37 | ]
|
---|
| 38 | }
|
---|
| 39 | ]
|
---|
| 40 | };
|
---|
| 41 |
|
---|
| 42 | return {
|
---|
| 43 | name: 'Extended Backus-Naur Form',
|
---|
| 44 | illegal: /\S/,
|
---|
| 45 | contains: [
|
---|
| 46 | commentMode,
|
---|
| 47 | nonTerminalMode,
|
---|
| 48 | ruleBodyMode
|
---|
| 49 | ]
|
---|
| 50 | };
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | module.exports = ebnf;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.