Skip to content

Commit f84c49c

Browse files
Added support for Nevod (#2798)
1 parent e32e043 commit f84c49c

10 files changed

+283
-1
lines changed

components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

+4
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,10 @@
807807
"title": "NEON",
808808
"owner": "nette"
809809
},
810+
"nevod": {
811+
"title": "Nevod",
812+
"owner": "nezaboodka"
813+
},
810814
"nginx": {
811815
"title": "nginx",
812816
"owner": "volado"

components/prism-nevod.js

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
Prism.languages.nevod = {
2+
'comment': /\/\/.*|(?:\/\*[\s\S]*?(?:\*\/|$))/,
3+
'string': {
4+
pattern: /(?:"(?:""|[^"])*"(?!")|'(?:''|[^'])*'(?!'))!?\*?/,
5+
greedy: true,
6+
inside: {
7+
'string-attrs': /!$|!\*$|\*$/,
8+
},
9+
},
10+
'namespace': {
11+
pattern: /(@namespace\s+)[a-zA-Z0-9\-.]+(?=\s*{)/,
12+
lookbehind: true,
13+
},
14+
'pattern': {
15+
pattern: /(@pattern\s+)?#?[a-zA-Z0-9\-.]+(?:\s*[(]\s*(?:~\s*)?[a-zA-Z0-9\-.]+\s*(?:,\s*(?:~\s*)?[a-zA-Z0-9\-.]*)*[)])?(?=\s*=)/,
16+
lookbehind: true,
17+
inside: {
18+
'pattern-name': {
19+
pattern: /^#?[a-zA-Z0-9\-.]+/,
20+
alias: 'class-name',
21+
},
22+
'fields': {
23+
pattern: /\(.*\)/,
24+
inside: {
25+
'field-name': {
26+
pattern: /[a-zA-Z0-9\-.]+/,
27+
alias: 'variable',
28+
},
29+
'punctuation': /[,()]/,
30+
'operator': {
31+
pattern: /~/,
32+
alias: 'field-hidden-mark',
33+
},
34+
},
35+
},
36+
},
37+
},
38+
'search': {
39+
pattern: /(@search\s+|#)[a-zA-Z0-9\-.]+(?:\.\*)?(?=\s*;)/,
40+
alias: 'function',
41+
lookbehind: true,
42+
},
43+
'keyword': /@(?:require|namespace|pattern|search|inside|outside|having|where)\b/,
44+
'standard-pattern': {
45+
pattern: /\b(?:Word|Punct|Symbol|Space|LineBreak|Start|End|Alpha|AlphaNum|Num|NumAlpha|Blank|WordBreak|Any)(?:\([a-zA-Z0-9\-.,\s+]*\))?/,
46+
inside: {
47+
'standard-pattern-name': {
48+
pattern: /^[a-zA-Z0-9\-.]+/,
49+
alias: 'builtin',
50+
},
51+
'quantifier': {
52+
pattern: /\b\d+(?:\s*\+|\s*-\s*\d+)?(?!\w)/,
53+
alias: 'number',
54+
},
55+
'standard-pattern-attr': {
56+
pattern: /[a-zA-Z0-9\-.]+/,
57+
alias: 'builtin',
58+
},
59+
'punctuation': /[,()]/,
60+
},
61+
},
62+
'quantifier': {
63+
pattern: /\b\d+(?:\s*\+|\s*-\s*\d+)?(?!\w)/,
64+
alias: 'number',
65+
},
66+
'operator': [
67+
{
68+
pattern: /=/,
69+
alias: 'pattern-def',
70+
},
71+
{
72+
pattern: /&/,
73+
alias: 'conjunction',
74+
},
75+
{
76+
pattern: /~/,
77+
alias: 'exception',
78+
},
79+
{
80+
pattern: /\?/,
81+
alias: 'optionality',
82+
},
83+
{
84+
pattern: /[[\]]/,
85+
alias: 'repetition',
86+
},
87+
{
88+
pattern: /[{}]/,
89+
alias: 'variation',
90+
},
91+
{
92+
pattern: /[+_]/,
93+
alias: 'sequence',
94+
},
95+
{
96+
pattern: /\.{2,3}/,
97+
alias: 'span',
98+
},
99+
],
100+
'field-capture': [
101+
{
102+
pattern: /([a-zA-Z0-9\-.]+\s*\()\s*[a-zA-Z0-9\-.]+\s*:\s*[a-zA-Z0-9\-.]+(?:\s*,\s*[a-zA-Z0-9\-.]+\s*:\s*[a-zA-Z0-9\-.]+)*(?=\s*\))/,
103+
lookbehind: true,
104+
inside: {
105+
'field-name': {
106+
pattern: /[a-zA-Z0-9\-.]+/,
107+
alias: 'variable',
108+
},
109+
'colon': /:/,
110+
},
111+
},
112+
{
113+
pattern: /[a-zA-Z0-9\-.]+\s*:/,
114+
inside: {
115+
'field-name': {
116+
pattern: /[a-zA-Z0-9\-.]+/,
117+
alias: 'variable',
118+
},
119+
'colon': /:/,
120+
},
121+
},
122+
],
123+
'punctuation': /[:;,()]/,
124+
'name': /[a-zA-Z0-9\-.]+/
125+
}

components/prism-nevod.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-nevod.html

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<h2>Comment</h2>
2+
<pre><code>/* This is
3+
multi-line
4+
comment */
5+
// This is single-line comment</code></pre>
6+
7+
<h2>String</h2>
8+
<pre><code>"text in double quotes"
9+
'text in single quotes'
10+
'case-sensitive text'!
11+
'text ''Nevod'' in quotes'
12+
"text ""Nevod"" in double quotes"
13+
'text prefix'*
14+
'case-sensitive text prefix'!*</code></pre>
15+
16+
<h2>Keyword</h2>
17+
<pre><code>@inside
18+
@outside
19+
@having
20+
@search
21+
@where</code></pre>
22+
23+
<h2>Package Import</h2>
24+
<pre><code>@require "Common/DateTime.np"
25+
@require "Common/Url.np"</code></pre>
26+
27+
<h2>Namespace</h2>
28+
<pre><code>@namespace My { }
29+
@namespace My.Domain { }</code></pre>
30+
31+
<h2>Pattern</h2>
32+
<pre><code>@pattern #Percentage = Num + ?Space + {'%', 'pct.', 'pct', 'percent'};
33+
@pattern #GUID = Word(8) + [3 '-' + Word(4)] + '-' + Word(12);
34+
@pattern #HashTag = '#' + {AlphaNum, Alpha, '_'} + [0+ {Word, '_'}];</code></pre>
35+
36+
<h2>Full Example</h2>
37+
<pre><code>@namespace Common
38+
{
39+
@search @pattern Url(Domain, Path, Query, Anchor) =
40+
Method + Domain:Url.Domain + ?Port + ?Path:Url.Path +
41+
?Query:Url.Query + ?Anchor:Url.Anchor
42+
@where
43+
{
44+
Method = {'http', 'https' , 'ftp', 'mailto', 'file', 'data', 'irc'} + '://';
45+
Domain = Word + [1+ '.' + Word + [0+ {Word, '_', '-'}]];
46+
Port = ':' + Num;
47+
Path = ?'/' + [0+ {Word, '/', '_', '+', '-', '%', '.'}];
48+
Query = '?' + ?(Param + [0+ '&' + Param])
49+
@where
50+
{
51+
Param = Identifier + '=' + Identifier
52+
@where
53+
{
54+
Identifier = {Alpha, AlphaNum, '_'} + [0+ {Word, '_'}];
55+
};
56+
};
57+
Anchor(Value) = '#' + Value:{Word};
58+
};
59+
}</code></pre>

tests/identifier-test.js

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ const testOptions = {
4646
number: false,
4747
template: false,
4848
},
49+
50+
// Nevod uses underscore symbol as operator and allows hyphen to be part of identifier
51+
'nevod': {
52+
word: false,
53+
template: false,
54+
},
4955
};
5056

5157
/** @type {Record<keyof IdentifierTestOptions, string[]>} */
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* Comment */
2+
/* Multi-line
3+
comment */
4+
/**/
5+
//
6+
// Single-line comment
7+
8+
----------------------------------------------------
9+
10+
[
11+
["comment", "/* Comment */"],
12+
["comment", "/* Multi-line\r\ncomment */"],
13+
["comment", "/**/"],
14+
["comment", "//"],
15+
["comment", "// Single-line comment"]
16+
]
17+
18+
----------------------------------------------------
19+
20+
Checks for comments.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@require @namespace @pattern @search
2+
@inside @outside @having
3+
@where
4+
5+
----------------------------------------------------
6+
7+
[
8+
["keyword", "@require"], ["keyword", "@namespace"], ["keyword", "@pattern"], ["keyword", "@search"],
9+
["keyword", "@inside"], ["keyword", "@outside"], ["keyword", "@having"],
10+
["keyword", "@where"]
11+
]
12+
13+
----------------------------------------------------
14+
15+
Checks for all keywords.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
( , ) ;
2+
+ _
3+
.. ...
4+
[ 0-5 ]
5+
&
6+
~
7+
?
8+
{}
9+
10+
----------------------------------------------------
11+
12+
[
13+
["punctuation", "("], ["punctuation", ","], ["punctuation", ")"], ["punctuation", ";"],
14+
["operator", "+"], ["operator", "_"],
15+
["operator", ".."], ["operator", "..."],
16+
["operator", "["], ["quantifier", "0-5"], ["operator", "]"],
17+
["operator", "&"],
18+
["operator", "~"],
19+
["operator", "?"],
20+
["operator", "{"], ["operator", "}"]
21+
]
22+
23+
----------------------------------------------------
24+
25+
Checks for operators.
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"text in double quotes"
2+
""
3+
'text in single quotes'
4+
'case-sensitive text'!
5+
'text ''Nevod'' in quotes'
6+
"text ""Nevod"" in double quotes"
7+
'text prefix'*
8+
'case-sensitive text prefix'!*
9+
''
10+
11+
----------------------------------------------------
12+
13+
[
14+
["string", ["\"text in double quotes\""]],
15+
["string", ["\"\""]],
16+
["string", ["'text in single quotes'"]],
17+
["string", ["'case-sensitive text'", ["string-attrs", "!"]]],
18+
["string", ["'text ''Nevod'' in quotes'"]],
19+
["string", ["\"text \"\"Nevod\"\" in double quotes\""]],
20+
["string", ["'text prefix'", ["string-attrs", "*"]]],
21+
["string", ["'case-sensitive text prefix'", ["string-attrs", "!*"]]],
22+
["string", ["''"]]
23+
]
24+
25+
----------------------------------------------------
26+
27+
Checks for various text strings.

0 commit comments

Comments
 (0)