vscode-ebnf

EBNF for Visual Studio Code
Mirror of https://github.com/Jamozed/vscode-ebnf
git clone http://git.omkov.net/vscode-ebnf
Log | Tree | Refs | README | LICENCE | Download

AuthorJamozed <[email protected]>
Date2021-06-13 09:07:36
Commit3dfb2ccbb33a25d26d3d691c689a92c66343c9e6
Parent0075a43b8ba10239891db080d98f15c7047243fb

Add syntax highlihting

Diffstat

A .vscode/launch.json | 11 +++++++++++
M README.md | 2 +-
A language-configuration.json | 24 ++++++++++++++++++++++++
A package.json | 29 +++++++++++++++++++++++++++++
A syntaxes/ebnf.tmLanguage.json | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

5 files changed, 145 insertions, 1 deletions

diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..622b645
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,11 @@
+{
+	"version": "0.2.0",
+	"configurations": [
+		{
+			"name": "Extension",
+			"type": "extensionHost",
+			"request": "launch",
+			"args": [ "--extensionDevelopmentPath=${workspaceFolder}" ],
+		}
+	]
+}
diff --git a/README.md b/README.md
index 1420ee5..448939c 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
 EBNF for Visual Studio Code provides EBNF syntax highlihting for Visual Studio
 Code. Files with the extension `.ebnf` will automatically be affected.
 
-![Syntax Highlighting](screenshot.png)
+![Syntax Highlighting](./screenshot.png)
 
 ## Meta
 
diff --git a/language-configuration.json b/language-configuration.json
new file mode 100644
index 0000000..f71fa2a
--- /dev/null
+++ b/language-configuration.json
@@ -0,0 +1,24 @@
+{
+	"comments": {
+		"blockComment": [ "(*", "*)" ]
+	},
+	"brackets": [
+		[ "[", "]" ],
+		[ "{", "}" ],
+		[ "(", ")" ]
+	],
+	"autoClosingPairs": [
+		[ "[", "]" ],
+		[ "{", "}" ],
+		[ "(", ")" ],
+		[ "'", "'" ],
+		[ "\"", "\"" ]
+	],
+	"surroundingPairs": [
+		[ "[", "]" ],
+		[ "{", "}" ],
+		[ "(", ")" ],
+		[ "'", "'" ],
+		[ "\"", "\"" ]
+	]
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..fb2227e
--- /dev/null
+++ b/package.json
@@ -0,0 +1,29 @@
+{
+	"name": "vscode-ebnf",
+	"version": "1.0.0",
+	"publisher": "OMKOV",
+	"engines": { "vscode": "^1.0.0" },
+	"license": "OLPE",
+	"displayName": "EBNF",
+	"description": "EBNF Highlighting",
+	"categories": [ "Programming Languages" ],
+	"keywords": [ "ebnf" ],
+	"contributes": {
+		"languages": [
+			{
+				"id": "ebnf",
+				"extensions": [ ".ebnf" ],
+				"aliases": [ "EBNF" ],
+				"configuration": "./language-configuration.json"
+			}
+		],
+		"grammars": [
+			{
+				"language": "ebnf",
+				"scopeName": "text.ebnf",
+				"path": "./syntaxes/ebnf.tmLanguage.json"
+			}
+		]
+	},
+	"repository": "https://github.com/Jamozed/vscode-ebnf"
+}
diff --git a/syntaxes/ebnf.tmLanguage.json b/syntaxes/ebnf.tmLanguage.json
new file mode 100644
index 0000000..fc14c64
--- /dev/null
+++ b/syntaxes/ebnf.tmLanguage.json
@@ -0,0 +1,80 @@
+{
+	"name": "EBNF",
+	"scopeName": "text.ebnf",
+	"patterns": [
+		{ "include": "#comment" },
+		{ "include": "#rule" }
+	],
+	"repository": {
+		"comment": {
+			"name": "comment.block.ebnf",
+			"begin": "\\(\\*",
+			"end": "\\*\\)",
+			"patterns": [
+				{
+					"name": "keyword.other.ebnf",
+					"match": "\\b(?:TODO|FIXME)\\b"
+				}
+			]
+		},
+		"rule": {
+			"begin": "([\\w]+)\\s*(=)\\s*",
+			"end": "(;)",
+			"beginCaptures": {
+				"1": { "name": "entity.name.class.ebnf" },
+				"2": { "name": "keyword.other.ebnf" }
+			},
+			"endCaptures": {
+				"1": { "name": "keyword.other.ebnf" }
+			},
+			"patterns": [
+				{ "include": "#comment" },
+				{ "include": "#symbol" },
+				{ "include": "#operator" },
+				{ "include": "#string" }
+			]
+		},
+		"symbol": {
+			"patterns": [
+				{
+					"name": "support.variable.ebnf",
+					"match": "\\b[A-Z][A-Z0-9_]*\\b"
+				},
+				{
+					"name": "entity.name.class.ebnf",
+					"match": "\\b[a-zA-Z_][a-zA-Z0-9_]*\\b"
+				}
+			]
+		},
+		"operator": {
+			"name": "keyword.control.ebnf",
+			"match": "[,|\\[\\]{}()*?-]"
+		},
+		"string": {
+			"patterns": [
+				{
+					"name": "string.quoted.single.ebnf",
+					"begin": "'",
+					"end": "'",
+					"patterns": [
+						{
+							"name": "constant.character.escape.ebnf",
+							"match": "\\\\."
+						}
+					]
+				},
+				{
+					"name": "string.quoted.double.ebnf",
+					"begin": "\"",
+					"end": "\"",
+					"patterns": [
+						{
+							"name": "constant.character.escape.ebnf",
+							"match": "\\\\."
+						}
+					]
+				}
+			]
+		}
+	}
+}