Browse Source

[changed] Update to the syntax for vscode from Xorgroth

Kevin_Smarts 2 years ago
parent
commit
77f57b693c

+ 30 - 1
tools/syntax/VSCode/qsrc/CHANGELOG.md

@@ -7,4 +7,33 @@ All notable changes to the "qsrc" extension will be documented in this file.
 
 
 ## 0.2.1
 ## 0.2.1
 - Added missing file
 - Added missing file
-- Updated extension to work with newer VS Code.
+- Updated extension to work with newer VS Code.
+
+### 0.2.2
+- Added whitespace matching for !{ and :
+
+### 0.2.3
+- Added more keywords from QGen.
+
+### 0.2.4
+- Fix for "" strings.
+
+### 0.2.5
+- Added indentation rules
+
+### 0.2.6
+- Fixes for indent rules
+
+### 0.2.7
+- Fix for system variables not highlighting '$' also.
+
+### 0.2.8
+- Fix line comments that start with '&!'
+- Reformatted the syntax file to fit with VSCode better.
+- Fixed the '*' not highlighting with clear, clr, cls, nl, pl and p variables.
+- Fixed 'p' variables not highlighting at all.
+- Fixed indentation rules to not apply for single line if statements.
+
+### 0.2.9
+- Added '/' '!' '*' to support functions.
+- Added multiline comments regex from slanon. So "!'" "!{" "}" comments now work.

+ 4 - 13
tools/syntax/VSCode/qsrc/README.md

@@ -2,24 +2,15 @@
 
 
 ## Known Issues
 ## Known Issues
 
 
-Currently multi-line block comments that start with "!'" don't work and line comments that use "!&"
-
-## Installation
-Extract into your .vscode/packages folder.
-On Linux it's probably in the home folder.
-On Windows it's usually located in your user folder.
+Currently block comments only work with "!{" "}!" beginning and end.
 
 
 ## Release Notes
 ## Release Notes
 
 
 Ported grammars from Atom to VS Code. Syntax highlighting for QSP code including Quest navigator.
 Ported grammars from Atom to VS Code. Syntax highlighting for QSP code including Quest navigator.
+Uses the qsrc file extension.
 
 
-### 0.2.0
-
-Initial release
-Ported from Atom
+## Installation
 
 
-### 0.2.1
-Missing file added
-Updated for newer versions of VS Code.
+Extract into your .vscode/packages folder. On Linux it's probably in the home folder. On Windows it's usually located in your user folder.
 
 
 -----------------------------------------------------------------------------------------------------------
 -----------------------------------------------------------------------------------------------------------

+ 16 - 12
tools/syntax/VSCode/qsrc/language-configuration.json

@@ -1,8 +1,4 @@
 {
 {
-    "comments": {
-        "lineComment": "!",
-        "blockComment": ["!{", "}"]
-    },
     // symbols used as brackets
     // symbols used as brackets
     "brackets": [
     "brackets": [
         ["{", "}"],
         ["{", "}"],
@@ -11,11 +7,11 @@
     ],
     ],
     // symbols that are auto closed when typing
     // symbols that are auto closed when typing
     "autoClosingPairs": [
     "autoClosingPairs": [
-        ["{", "}"],
-        ["[", "]"],
-        ["(", ")"],
-        ["\"", "\""],
-        ["'", "'"]
+        {"open": "{", "close": "}"},
+        {"open": "[", "close": "]"},
+        {"open": "(", "close": ")"},
+        {"open": "\"", "close": "\"", "notIn": ["string"]},
+        {"open": "'", "close": "'"}
     ],
     ],
     // symbols that that can be used to surround a selection
     // symbols that that can be used to surround a selection
     "surroundingPairs": [
     "surroundingPairs": [
@@ -23,6 +19,14 @@
         ["[", "]"],
         ["[", "]"],
         ["(", ")"],
         ["(", ")"],
         ["\"", "\""],
         ["\"", "\""],
-        ["'", "'"]
-    ]
-}
+        ["'", "'"],
+        ["<<", ">>"]
+    ],
+    // indendation when writing code
+    "indentationRules": {
+		"increaseIndentPattern": "^\\s*(if|else|elseif|act|\\{|\\b.*:)\\s*$",
+        "decreaseIndentPattern": "^\\s*(end|else|elseif|\\})\\b.*$"
+	},
+
+    "wordPattern": "(``((\\w*\\s?)\\s?)*``)|((\\w*')(\\w'?)*)|(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\$\\^\\&\\*\\(\\)\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\\/\\s]+)"
+}

+ 5 - 5
tools/syntax/VSCode/qsrc/package.json

@@ -2,10 +2,10 @@
     "name": "qsrc",
     "name": "qsrc",
     "displayName": "qsrc",
     "displayName": "qsrc",
     "description": "QSP grammar",
     "description": "QSP grammar",
-    "version": "0.2.1",
+    "version": "0.2.9",
     "publisher": "Xorgroth",
     "publisher": "Xorgroth",
     "engines": {
     "engines": {
-        "vscode": "^1.28.0"
+        "vscode": "^1.50.0"
     },
     },
     "categories": [
     "categories": [
         "Programming Languages"
         "Programming Languages"
@@ -14,13 +14,13 @@
         "languages": [{
         "languages": [{
             "id": "qsp",
             "id": "qsp",
             "aliases": ["QSP", "qsp"],
             "aliases": ["QSP", "qsp"],
-            "extensions": [".qsrc", ".qsp-txt", ".txt-qsp"],
+            "extensions": [".qsrc"],
             "configuration": "./language-configuration.json"
             "configuration": "./language-configuration.json"
         }],
         }],
         "grammars": [{
         "grammars": [{
             "language": "qsp",
             "language": "qsp",
-            "scopeName": "scope.qsp",
-            "path": "./syntaxes/QSP.tmLanguage.json"
+            "scopeName": "text.qsp.qsrc",
+            "path": "./syntaxes/qsp.tmLanguage.json"
         }]
         }]
     }
     }
 }
 }

+ 160 - 71
tools/syntax/VSCode/qsrc/syntaxes/QSP.tmLanguage.json

@@ -1,78 +1,28 @@
 {
 {
 	"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
 	"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
 	"name": "QSP",
 	"name": "QSP",
+	"scopeName": "text.qsp.qsrc",
 	"patterns": [
 	"patterns": [
 		{
 		{
-			"include": "#strings"
-		},
-		{
-			"name": "entity.other.attribute-name.qsp",
-			"match": "^(:)[^'\"]*$\n?"
-		},
-		{
-			"name": "variable.parameter.url.qsp",
-			"match": "^-{1,2}\\S.*?\\S-{1,2}$"
-		},
-		{
-			"name": "constant.character.qsp",
-			"match": "^(#)\\s?.+$"
-		},
-		{
-			"name": "constant.character.qsp",
-			"match": "\\b\\d+\\b"
-		},
-		{
-			"name": "variable.parameter.url.qsp",
-			"match": "\\b(?i:([$]dyneval|[$]user_text|[$]usrtxt|[$]maintxt|[$]stattxt|[$]func|[$]curloc|[$]selobj|[$]selact|[$]curact|[$]getobj|[$]mid|[$](u|l)case|[$]trim|[$]replace|[$]str|[$]loc|[$]strfind))\\b"
-		},
-		{
-			"name": "variable.parameter.url.qsp",
-			"match": "\\b(?i:(dyneval|input|user_text|usrtxt|iif|rgb|isplay|msecscount|desc|maintxt|stattxt|qspver|func|curloc|selobj|no|and|mod|selact|curact|arrsize|arrpos|countobj|getobj|led|mid|(u|l)case|trim|replace|instr|isnum|val|str|loc|or|max|min|r(a)?nd|(arr|str)comp|str(find|pos)))\\b"
-		},
-		{
-			"name": "keyword.control.qsp",
-			"match": "\\b[$](?i:(counter|ongload|ongsave|onnewloc|onactsel|onobjsel|onobjadd|onobjdel|usercom|fname|backimage|args|result))\\b"
-		},
-		{
-			"name": "keyword.control.qsp",
-			"match": "\\b(?i:(counter|ongload|ongsave|onnewloc|onactsel|onobjsel|onobjadd|onobjdel|usercom|fname|backimage|args|result))\\b"
-		},
-		{
-			"name": "keyword.control.qsp",
-			"match": "\\b(?i:(nosave|disablescroll|disablesubex|debug|usehtml|(b|f|l)color|fsize))\\b"
-		},
-		{
-			"name": "support.function.qsp",
-			"match": "\\b(?i:(act|exit|killvar|cla|\\*?clr|\\*?clear|gs|xgt|gt|goto|gosub|\\[|\\]|xgoto|if|else|elseif|end|jump|\\*|&|\\*?(n|p)l))\\b"
+			"include": "#begin-end"
 		},
 		},
 		{
 		{
-			"name": "support.function.qsp",
-			"match": "(?i:(,|\\[|\\]|\\(|\\)|\\{|\\}|&|\\+|=|-|(<|>)=?|=?(<|>)))"
+			"include": "#comments"
 		},
 		},
 		{
 		{
-			"name": "comment.block.doubleexclamation.qsp",
-			"begin": "!!{",
-			"end": "}$"
+			"include": "#keyword-control"
 		},
 		},
 		{
 		{
-			"name": "comment.block.exclamation.qsp",
-			"begin": "!{",
-			"end": "}$"
+			"include": "#keyword-operators"
 		},
 		},
 		{
 		{
-			"name": "comment.line.doubleexclamation.qsp",
-			"begin": "!!",
-			"end": "$"
+			"include": "#marks"
 		},
 		},
 		{
 		{
-			"name": "comment.line.exclamation.qsp",
-			"begin": "^!",
-			"end": "$"
+			"include": "#strings"
 		},
 		},
 		{
 		{
-			"name": "comment.line.exclamation.qsp",
-			"begin": "^\\s+!.*",
-			"end": "$"
+			"include": "#support-objects"
 		},
 		},
 		{
 		{
 			"folds": [
 			"folds": [
@@ -93,25 +43,149 @@
 		}
 		}
 	],
 	],
 	"repository": {
 	"repository": {
-		"strings": {
-			"name": "string.quoted.double.qsp",
-			"begin": "\"",
-			"end": "\"",
+		"begin-end": {
 			"patterns": [
 			"patterns": [
 				{
 				{
-					"name": "string.interpolated.qsp",
-					"begin": "<<",
-					"end": ">>",
+					"name": "constant.character.qsp",
+					"match": "^-{1,2}\\S.*?\\S-{1,2}$"
+				},
+				{
+					"name": "constant.character.qsp",
+					"match": "^(#)\\s?.+$"
+				},
+				{
+					"name": "constant.character.qsp",
+					"match": "\\b\\d+\\b"
+				}
+			]
+		},
+		"comments": {
+			"comment": "singe and multiline comments starting with !",
+			"patterns": [
+				{
+					"comment": "comments without possible multiline chars",
+					"match": "(?:^|\\s?[&])\\s*((!!?)[^{'\"]*?$\\n?)",
+					"captures": {
+						"1": {
+							"name": "comment.line.qsp"
+						},
+						"2": {
+							"name": "punctuation.definition.comment.qsp"
+						}
+					}
+				},
+				{
+					"comment": "comments with multiline chars",
+					"begin": "(?:^|\\s?[&])\\s*(!!?)",
+					"beginCaptures": {
+						"0": {
+							"name": "comment.block.qsp"
+						},
+						"1": {
+							"name": "punctuation.definition.comment.qsp"
+						}
+					},
 					"patterns": [
 					"patterns": [
 						{
 						{
-							"include": "$self"
+							"name": "comment.block.qsp",
+							"match": "\\G",
+							"include": "#comment-block"
 						}
 						}
 					]
 					]
 				}
 				}
+			]
+		},
+		"comment-block": {
+			"patterns": [
+				{
+					"match": "(\\s*[^{'\"]*)(?=$)",
+					"captures": {
+						"1": {
+							"name": "comment.block.text.qsp"
+						}
+					}
+				},
+				{
+					"include": "#comment-block-quote"
+				},
+				{
+					"include": "#comment-block-bracket-curly"
+				},
+				{
+					"match": "(\\s*[^{'\"]*)(?!$)",
+					"captures": {
+						"1": {
+							"name": "comment.block.text.qsp"
+						}
+					}
+				},
+				{
+					"comment": "continue parsing after the comment ends",
+					"begin": "($\\n?)",
+					"pattern": {
+						"match": "\\G"
+					}
+				}
+			]
+		},
+		"comment-block-quote": {
+			"name": "comment.block.quote.qsp",
+			"begin": "('|\")",
+			"end": "(\\1)"
+		},
+		"comment-block-bracket-curly": {
+			"name": "comment.block.bracket.curly.qsp",
+			"begin": "[{]",
+			"patterns": [
+				{
+					"include": "#comment-block-bracket-curly"
+				},
+				{
+					"include": "#comment-block-quote"
+				}
 			],
 			],
+			"end": "([}])"
+		},
+		"keyword-control": {
+			"patterns": [
+				{
+					"name": "keyword.control.qsp",
+					"match": "(\\$)(?=(\\b(?i:(counter|ongload|ongsave|onnewloc|onactsel|onobjsel|onobjadd|onobjdel|usercom|fname|backimage|args|result))\\b))"
+				},
+				{
+					"name": "keyword.control.qsp",
+					"match": "\\b(?i:(counter|ongload|ongsave|onnewloc|onactsel|onobjsel|onobjadd|onobjdel|usercom|fname|backimage|args|result|nosave|disablescroll|disablesubex|debug|usehtml|(b|f|l)color|fsize))\\b"
+				}
+			]
+		},
+		"keyword-operators": {
+			"patterns": [
+				{
+					"name": "keyword.operator.qsp",
+					"match": "(\\$)(?=(\\b(?i:(dyneval|input|user_text|usrtxt|maintxt|stattxt|func|curloc|selobj|selact|curacts|getobj|mid|(u|l)case|trim|replace|str|loc|strfind))\\b))"
+				},
+				{
+					"name": "keyword.operator.qsp",
+					"match": "\\b(?i:(dyneval|input|user_text|usrtxt|iif|rgb|isplay|msecscount|desc|maintxt|stattxt|qspver|func|curloc|selobj|no|and|obj|len|mod|selact|curacts|arrsize|arrpos|countobj|getobj|led|mid|(u|l)case|trim|replace|instr|isnum|val|str|loc|or|max|min|r(a)?nd|(arr|str)comp|str(find|pos)))\\b"
+				}
+			]
+		},
+		"marks": {
+			"patterns": [
+				{
+					"name": "entity.other.attribute-name.qsp",
+					"match": "^(:)[^'\"]*$\n?"
+				},
+				{
+					"name": "entity.other.attribute-name.qsp",
+					"match": "^(\\s+:)[^'\"]*$\n?"
+				}
+			]
+		},
+		"strings": {
 			"name": "string.quoted.single.qsp",
 			"name": "string.quoted.single.qsp",
-			"begin": "'",
-			"end": "'",
+			"begin": "(\"|')",
+			"end": "\\1",
 			"patterns": [
 			"patterns": [
 				{
 				{
 					"name": "string.interpolated.qsp",
 					"name": "string.interpolated.qsp",
@@ -124,7 +198,22 @@
 					]
 					]
 				}
 				}
 			]
 			]
+		},
+		"support-objects": {
+			"patterns": [
+				{
+					"name": "support.function.qsp",
+					"match": "(\\*)(?=(\\b(?i:(pl?|clear|clr|nl))\\b))"
+				},
+				{
+					"name": "support.function.qsp",
+					"match": "\\b(?i:(nl|pl?|clear|clr|act|exit|killvar|cla|gs|xgt|gt|goto|gosub|\\[|\\]|xgoto|if|else|elseif|end|jump|msg|wait|delact|cmdclear|cmdclr|cls|menu|settimer|dynamic|set|let|play|close|view|copyarr|addobj|delobj|killobj|unselect|unsel|killall|opengame|openqst|addqst|killqst|savegame|refint|showacts|showinput|showobjs|showstat|\\*|&))\\b"
+				},
+				{
+					"name": "support.function.qsp",
+					"match": "(?i:(,|\\[|\\]|\\(|\\)|\\{|\\}|&|\\/|!|\\*|\\+|=|-|(<|>)=?|=?(<|>)))"
+				}
+			]
 		}
 		}
-	},
-	"scopeName": "scope.qsp"
-}
+	}
+}