Skip to content

Commit

Permalink
Added support for NEON
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 19, 2019
1 parent dae536c commit 488d7ac
Show file tree
Hide file tree
Showing 15 changed files with 248 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Expand Up @@ -655,6 +655,10 @@
"title": "NASM",
"owner": "rbmj"
},
"neon": {
"title": "NEON",
"owner": "nette"
},
"nginx": {
"title": "nginx",
"owner": "westonganger",
Expand Down
39 changes: 39 additions & 0 deletions components/prism-neon.js
@@ -0,0 +1,39 @@
Prism.languages.neon = {
'comment': {
pattern: /#.*/,
greedy: true
},
'datetime': {
pattern: /(^|[[{(=,\s])\d\d\d\d-\d\d?-\d\d?(?:(?:[Tt]| +)\d\d?:\d\d:\d\d(?:\.\d*)? *(?:Z|[-+]\d\d?(?::?\d\d)?)?)?(?=$|[\]}),\s])/,
lookbehind: true,
alias: 'number'
},
'key': {
pattern: /(^|[[{(,\s])[^,:=[\]{}()'"\s]+(?=\s*:(?:$|[\]}),\s])|\s*=)/,
lookbehind: true,
alias: 'atrule'
},
'number': {
pattern: /(^|[[{(=,\s])[+-]?(?:0x[\da-fA-F]+|0o[0-7]+|0b[01]+|(?:\d+\.?\d*|\.?\d+)(?:[eE][+-]?\d+)?)(?=$|[\]}),\s])/,
lookbehind: true
},
'boolean': {
pattern: /(^|[[{(=,\s])(?:true|false|yes|no)(?=$|[\]}),\s])/i,
lookbehind: true
},
'null': {
pattern: /(^|[[{(=,\s])(?:null)(?=$|[\]}),\s])/i,
lookbehind: true
},
'string': {
pattern: /(^|[[{(=,\s])(?:'''\r?\n(?:(?:[^\r\n]|\r?\n(?![\t\ ]*'''))*\r?\n)?[\t\ ]*'''|"""\r?\n(?:(?:[^\r\n]|\r?\n(?![\t\ ]*"""))*\r?\n)?[\t\ ]*"""|'[^'\n]*'|"(?:\\.|[^"\n])*")(?=$|[\]}),\s])/m,
lookbehind: true,
greedy: true
},
'literal': {
pattern: /(?:[^#"\',:=[\]{}()\x00-\x20`-]|[:-][^"\',\]})\s])(?:[^,:=\]})(\x00-\x20]+|:(?![\s,\]})]|$)|[\ \t]+[^#,:=\]})(\x00-\x20])*/,
alias: 'string',
},
'punctuation': /[,:=[\]{}()-]/,
};

1 change: 1 addition & 0 deletions components/prism-neon.min.js

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

1 change: 1 addition & 0 deletions plugins/show-language/prism-show-language.js
Expand Up @@ -102,6 +102,7 @@
"n4jsd": "N4JS",
"nand2tetris-hdl": "Nand To Tetris HDL",
"nasm": "NASM",
"neon": "NEON",
"nginx": "nginx",
"nsis": "NSIS",
"objectivec": "Objective-C",
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

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

21 changes: 21 additions & 0 deletions tests/languages/neon/boolean_feature.test
@@ -0,0 +1,21 @@
foo: true
bar: false
alt: [yes, no, YES, NO, TRUE, FALSE]

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

[
["key", "foo"], ["punctuation", ":"],
["boolean", "true"],
["key", "bar"], ["punctuation", ":"],
["boolean", "false"],
["key", "alt"], ["punctuation", ":"], ["punctuation", "["],
["boolean", "yes"], ["punctuation", ","], ["boolean", "no"], ["punctuation", ","], ["boolean", "YES"], ["punctuation", ","], ["boolean", "NO"], ["punctuation", ","], ["boolean", "TRUE"], ["punctuation", ","], ["boolean", "FALSE"],
["punctuation", "]"]
]

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

Checks for booleans.


13 changes: 13 additions & 0 deletions tests/languages/neon/comment_feature.test
@@ -0,0 +1,13 @@
#
# foobar

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

[
["comment", "#"],
["comment", "# foobar"]
]

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

Checks for comments.
25 changes: 25 additions & 0 deletions tests/languages/neon/composite.test
@@ -0,0 +1,25 @@
phones: {home: 555-6528,work: 555-7334 }

children: # this is a comment
- -50.5

entity: Column(type=int, nulls=yes)

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

[
["key", "phones"], ["punctuation", ":"], ["punctuation", "{"],
["key", "home"], ["punctuation", ":"],
["literal", "555-6528"], ["punctuation", ","],
["key", "work"], ["punctuation", ":"],
["literal", "555-7334"], ["punctuation", "}"],
["key", "children"], ["punctuation", ":"],
["comment", "# this is a comment"],
["punctuation", "-"], ["number", "-50.5"],
["key", "entity"], ["punctuation", ":"],
["literal", "Column"], ["punctuation", "("], ["key", "type"], ["punctuation", "="], ["literal", "int"], ["punctuation", ","], ["key", "nulls"], ["punctuation", "="], ["boolean", "yes"], ["punctuation", ")"]
]

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

Overall test
24 changes: 24 additions & 0 deletions tests/languages/neon/datetime_feature.test
@@ -0,0 +1,24 @@
canonical: 2001-12-15T02:59:43.1Z
iso8601: 2001-12-14t21:59:43.10-05:00
spaced: 2001-12-14 21:59:43.10 -5
date: 2002-12-14
short: 2002-1-1

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

[
["key", "canonical"], ["punctuation", ":"],
["datetime", "2001-12-15T02:59:43.1Z"],
["key", "iso8601"], ["punctuation", ":"],
["datetime", "2001-12-14t21:59:43.10-05:00"],
["key", "spaced"], ["punctuation", ":"],
["datetime", "2001-12-14 21:59:43.10 -5"],
["key", "date"], ["punctuation", ":"],
["datetime", "2002-12-14"],
["key", "short"], ["punctuation", ":"],
["datetime", "2002-1-1"]
]

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

Checks for dates and datetimes.
17 changes: 17 additions & 0 deletions tests/languages/neon/key_feature.test
@@ -0,0 +1,17 @@
foo: 4
FooBar : 5
alt=6
alt2 = 7

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

[
["key", "foo"], ["punctuation", ":"], ["number", "4"],
["key", "FooBar"], ["punctuation", ":"], ["number", "5"],
["key", "alt"], ["punctuation", "="], ["number", "6"],
["key", "alt2"], ["punctuation", "="], ["number", "7"]
]

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

Checks for keys.
15 changes: 15 additions & 0 deletions tests/languages/neon/literal_feature.test
@@ -0,0 +1,15 @@
foo: hello:abc
bar: @test\x\b

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

[
["key", "foo"], ["punctuation", ":"],
["literal","hello:abc"],
["key", "bar"], ["punctuation", ":"],
["literal","@test\\x\\b"]
]

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

Checks for literals.
12 changes: 12 additions & 0 deletions tests/languages/neon/null_feature.test
@@ -0,0 +1,12 @@
foo: null

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

[
["key", "foo"], ["punctuation", ":"],
["null", "null"]
]

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

Checks for null.
36 changes: 36 additions & 0 deletions tests/languages/neon/number_feature.test
@@ -0,0 +1,36 @@
foo: 0xBadFace
bar: 0o754
baz: 42
foo: 3.14159
bar: 4e8
baz: 3.1E-7
foo: 0.4e+2
bar: -0xFF
baz: +0o123

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

[
["key", "foo"], ["punctuation", ":"],
["number", "0xBadFace"],
["key", "bar"], ["punctuation", ":"],
["number", "0o754"],
["key", "baz"], ["punctuation", ":"],
["number", "42"],
["key", "foo"], ["punctuation", ":"],
["number", "3.14159"],
["key", "bar"], ["punctuation", ":"],
["number", "4e8"],
["key", "baz"], ["punctuation", ":"],
["number", "3.1E-7"],
["key", "foo"], ["punctuation", ":"],
["number", "0.4e+2"],
["key", "bar"], ["punctuation", ":"],
["number", "-0xFF"],
["key", "baz"], ["punctuation", ":"],
["number", "+0o123"]
]

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

Checks for numbers.
38 changes: 38 additions & 0 deletions tests/languages/neon/string_feature.test
@@ -0,0 +1,38 @@
foo: ""
bar: "fo\"obar"
foo: ''
foo: "foo" # bar
bar: 'bar' # foo
multi: '''
one line
second line
third line
'''
multi: """
one line
second line
third line
"""

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

[
["key", "foo"], ["punctuation", ":"],
["string", "\"\""],
["key", "bar"], ["punctuation", ":"],
["string", "\"fo\\\"obar\""],
["key", "foo"], ["punctuation", ":"],
["string", "''"],
["key", "foo"], ["punctuation", ":"],
["string", "\"foo\""], ["comment", "# bar"],
["key", "bar"], ["punctuation", ":"],
["string", "'bar'"], ["comment", "# foo"],
["key", "multi"], ["punctuation", ":"],
["string", "'''\r\n\tone line\r\n\tsecond line\r\n\tthird line\r\n'''"],
["key", "multi"], ["punctuation", ":"],
["string", "\"\"\"\r\n\tone line\r\n\tsecond line\r\n\tthird line\r\n\"\"\""]
]

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

Checks for strings.

0 comments on commit 488d7ac

Please sign in to comment.