Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language Nevod #2798

Merged
merged 25 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fb3e15f
Add Nevod language regexp patterns.
dmitry-surkov Mar 3, 2021
273e5c9
Update regexp patterns and add language description.
dmitry-surkov Mar 4, 2021
c448cae
Update Nevod language patterns.
dmitry-surkov Mar 4, 2021
ee9bedb
square-bracket -> repetition, curly-bracket -> variation.
dmitry-surkov Mar 4, 2021
62f3e69
Add tests for Nevod language.
dmitry-surkov Mar 5, 2021
516076e
prism-nevod.min.js generated by build.
dmitry-surkov Mar 9, 2021
0ac30f2
Minor fix of test description.
dmitry-surkov Mar 9, 2021
7273883
Add nevod to components.json.
dmitry-surkov Mar 9, 2021
801790e
Fix operator_feature.test for nevod language.
dmitry-surkov Mar 9, 2021
6f92e25
WIP: fixing string_feature.test for nevod language.
dmitry-surkov Mar 9, 2021
d325380
Fix string_feature.test for nevod language.
dmitry-surkov Mar 9, 2021
3b401b9
WIP: fixing string_feature test for nevod language.
dmitry-surkov Mar 9, 2021
7298483
Fix Nevod patterns and tests.
dmitry-surkov Mar 10, 2021
0b01d4c
Fix components.js.
dmitry-surkov Mar 10, 2021
f394400
Update components/prism-nevod.js
dmitry-surkov Mar 10, 2021
9d24072
Update components/prism-nevod.js
dmitry-surkov Mar 10, 2021
c925a5e
Fixing patterns for Nevod language.
dmitry-surkov Mar 10, 2021
2ebaae1
Fixing 'search' pattern.
dmitry-surkov Mar 10, 2021
c54eeb8
Improve regexp patterns for Nevod language. Update operator_feature.t…
dmitry-surkov Mar 11, 2021
c10ff32
Improve patterns for Nevod language.
dmitry-surkov Mar 12, 2021
4cdaae9
Fix regexp patterns for Nevod language.
dmitry-surkov Mar 15, 2021
1e009ec
Fix regexp patterns for Nevod language.
dmitry-surkov Mar 15, 2021
0c23fbe
Fix regexp patterns for Nevod language.
dmitry-surkov Mar 15, 2021
f971bae
Change pattern names for Nevod language.
dmitry-surkov Mar 15, 2021
66037d9
Fix regexp patterns and tests for Nevod language.
dmitry-surkov Mar 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,10 @@
"title": "NEON",
"owner": "nette"
},
"nevod": {
"title": "Nevod",
"owner": "nezaboodka"
},
"nginx": {
"title": "nginx",
"owner": "volado"
Expand Down
125 changes: 125 additions & 0 deletions components/prism-nevod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
Prism.languages.nevod = {
'comment': /\/\/.*|(?:\/\*[\s\S]*?(?:\*\/|$))/,
'string': {
pattern: /(?:"(?:""|[^"])*"(?!")|'(?:''|[^'])*'(?!'))!?\*?/,
greedy: true,
inside: {
'string-attrs': /!$|!\*$|\*$/,
},
},
'namespace': {
pattern: /(@namespace\s+)[a-zA-Z0-9\-.]+(?=\s*{)/,
lookbehind: true,
},
'pattern': {
pattern: /(@pattern\s+)?#?[a-zA-Z0-9\-.]+(?:\s*[(]\s*(?:~\s*)?[a-zA-Z0-9\-.]+\s*(?:,\s*(?:~\s*)?[a-zA-Z0-9\-.]*)*[)])?(?=\s*=)/,
lookbehind: true,
inside: {
'pattern-name': {
pattern: /^#?[a-zA-Z0-9\-.]+/,
alias: 'class-name',
},
'fields': {
pattern: /\(.*\)/,
inside: {
'field-name': {
pattern: /[a-zA-Z0-9\-.]+/,
alias: 'variable',
},
'punctuation': /[,()]/,
'operator': {
pattern: /~/,
alias: 'field-hidden-mark',
},
},
},
},
},
'search': {
pattern: /(@search\s+|#)[a-zA-Z0-9\-.]+(?:\.\*)?(?=\s*;)/,
dmitry-surkov marked this conversation as resolved.
Show resolved Hide resolved
alias: 'function',
lookbehind: true,
},
'keyword': /@(?:require|namespace|pattern|search|inside|outside|having|where)\b/,
'standard-pattern': {
pattern: /\b(?:Word|Punct|Symbol|Space|LineBreak|Start|End|Alpha|AlphaNum|Num|NumAlpha|Blank|WordBreak|Any)(?:\([a-zA-Z0-9\-.,\s+]*\))?/,
inside: {
'standard-pattern-name': {
pattern: /^[a-zA-Z0-9\-.]+/,
alias: 'builtin',
},
'quantifier': {
pattern: /\b\d+(?:\s*\+|\s*-\s*\d+)?(?!\w)/,
alias: 'number',
},
'standard-pattern-attr': {
pattern: /[a-zA-Z0-9\-.]+/,
alias: 'builtin',
},
'punctuation': /[,()]/,
},
},
'quantifier': {
pattern: /\b\d+(?:\s*\+|\s*-\s*\d+)?(?!\w)/,
alias: 'number',
},
'operator': [
{
pattern: /=/,
alias: 'pattern-def',
},
{
pattern: /&/,
alias: 'conjunction',
},
{
pattern: /~/,
alias: 'exception',
},
{
pattern: /\?/,
alias: 'optionality',
},
{
pattern: /[[\]]/,
alias: 'repetition',
},
{
pattern: /[{}]/,
alias: 'variation',
},
{
pattern: /[+_]/,
alias: 'sequence',
},
{
pattern: /\.{2,3}/,
alias: 'span',
},
],
'field-capture': [
{
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*\))/,
lookbehind: true,
inside: {
'field-name': {
pattern: /[a-zA-Z0-9\-.]+/,
alias: 'variable',
},
'colon': /:/,
},
},
{
pattern: /[a-zA-Z0-9\-.]+\s*:/,
inside: {
'field-name': {
pattern: /[a-zA-Z0-9\-.]+/,
alias: 'variable',
},
'colon': /:/,
},
},
],
'punctuation': /[:;,()]/,
'name': /[a-zA-Z0-9\-.]+/
}
1 change: 1 addition & 0 deletions components/prism-nevod.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions examples/prism-nevod.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<h2>Comment</h2>
<pre><code>/* This is
multi-line
comment */
// This is single-line comment</code></pre>

<h2>String</h2>
<pre><code>"text in double quotes"
'text in single quotes'
'case-sensitive text'!
'text ''Nevod'' in quotes'
"text ""Nevod"" in double quotes"
'text prefix'*
'case-sensitive text prefix'!*</code></pre>

<h2>Keyword</h2>
<pre><code>@inside
@outside
@having
@search
@where</code></pre>

<h2>Package Import</h2>
<pre><code>@require "Common/DateTime.np"
@require "Common/Url.np"</code></pre>

<h2>Namespace</h2>
<pre><code>@namespace My { }
@namespace My.Domain { }</code></pre>

<h2>Pattern</h2>
<pre><code>@pattern #Percentage = Num + ?Space + {'%', 'pct.', 'pct', 'percent'};
@pattern #GUID = Word(8) + [3 '-' + Word(4)] + '-' + Word(12);
@pattern #HashTag = '#' + {AlphaNum, Alpha, '_'} + [0+ {Word, '_'}];</code></pre>

<h2>Full Example</h2>
<pre><code>@namespace Common
{
@search @pattern Url(Domain, Path, Query, Anchor) =
Method + Domain:Url.Domain + ?Port + ?Path:Url.Path +
?Query:Url.Query + ?Anchor:Url.Anchor
@where
{
Method = {'http', 'https' , 'ftp', 'mailto', 'file', 'data', 'irc'} + '://';
Domain = Word + [1+ '.' + Word + [0+ {Word, '_', '-'}]];
Port = ':' + Num;
Path = ?'/' + [0+ {Word, '/', '_', '+', '-', '%', '.'}];
Query = '?' + ?(Param + [0+ '&' + Param])
@where
{
Param = Identifier + '=' + Identifier
@where
{
Identifier = {Alpha, AlphaNum, '_'} + [0+ {Word, '_'}];
};
};
Anchor(Value) = '#' + Value:{Word};
};
}</code></pre>
6 changes: 6 additions & 0 deletions tests/identifier-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ const testOptions = {
number: false,
template: false,
},

// Nevod uses underscore symbol as operator and allows hyphen to be part of identifier
'nevod': {
word: false,
template: false,
},
};

/** @type {Record<keyof IdentifierTestOptions, string[]>} */
Expand Down
20 changes: 20 additions & 0 deletions tests/languages/nevod/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* Comment */
/* Multi-line
comment */
/**/
//
// Single-line comment

----------------------------------------------------

[
["comment", "/* Comment */"],
["comment", "/* Multi-line\r\ncomment */"],
["comment", "/**/"],
["comment", "//"],
["comment", "// Single-line comment"]
]

----------------------------------------------------

Checks for comments.
15 changes: 15 additions & 0 deletions tests/languages/nevod/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@require @namespace @pattern @search
@inside @outside @having
@where

----------------------------------------------------

[
["keyword", "@require"], ["keyword", "@namespace"], ["keyword", "@pattern"], ["keyword", "@search"],
["keyword", "@inside"], ["keyword", "@outside"], ["keyword", "@having"],
["keyword", "@where"]
]

----------------------------------------------------

Checks for all keywords.
25 changes: 25 additions & 0 deletions tests/languages/nevod/operator_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
( , ) ;
+ _
.. ...
[ 0-5 ]
&
~
?
{}

----------------------------------------------------

[
["punctuation", "("], ["punctuation", ","], ["punctuation", ")"], ["punctuation", ";"],
["operator", "+"], ["operator", "_"],
["operator", ".."], ["operator", "..."],
["operator", "["], ["quantifier", "0-5"], ["operator", "]"],
["operator", "&"],
["operator", "~"],
["operator", "?"],
["operator", "{"], ["operator", "}"]
]

----------------------------------------------------

Checks for operators.
27 changes: 27 additions & 0 deletions tests/languages/nevod/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"text in double quotes"
""
'text in single quotes'
'case-sensitive text'!
'text ''Nevod'' in quotes'
"text ""Nevod"" in double quotes"
'text prefix'*
'case-sensitive text prefix'!*
''

----------------------------------------------------

[
["string", ["\"text in double quotes\""]],
["string", ["\"\""]],
["string", ["'text in single quotes'"]],
["string", ["'case-sensitive text'", ["string-attrs", "!"]]],
["string", ["'text ''Nevod'' in quotes'"]],
["string", ["\"text \"\"Nevod\"\" in double quotes\""]],
["string", ["'text prefix'", ["string-attrs", "*"]]],
["string", ["'case-sensitive text prefix'", ["string-attrs", "!*"]]],
["string", ["''"]]
]

----------------------------------------------------

Checks for various text strings.