before rewriting formatter

This commit is contained in:
2025-06-25 08:34:56 -06:00
parent c4a2e5a077
commit 889c150b08
5 changed files with 542 additions and 296 deletions

View File

@@ -3,23 +3,15 @@
"name": "4690 BASIC",
"patterns": [
{
"name": "string.quoted.double",
"begin": "\"",
"end": "\"",
"patterns": [
{
"match": ".",
"name": "string.quoted.double"
}
]
"include": "#comments"
},
{
"include": "#strings"
},
{
"name": "string.regexp",
"match": "\\b[\\w\\.]+:"
},
{
"include": "#comments"
},
{
"include": "#function-decl"
},
@@ -44,12 +36,6 @@
{
"include": "#math-function"
},
{
"include": "#string-function"
},
{
"include": "#variable-assignment"
},
{
"include": "#if-statement"
},
@@ -74,9 +60,6 @@
{
"include": "#keywords"
},
{
"include": "#strings"
},
{
"include": "#stmt-w-parameters"
},
@@ -98,11 +81,27 @@
{
"include": "#number-literal"
},
{
"include": "#string-function"
},
{
"include": "#identifier"
}
],
"repository": {
"comments": {
"patterns": [
{
"name": "comment.line",
"match": "!.*|\\bREM.*|\\bREMARK.*"
}
]
},
"strings": {
"name": "string.quoted.double",
"begin": "\"",
"end": "\""
},
"line-continuation": {
"name": "meta.line.continuation",
"match": "\\\\(.*)\\n",
@@ -112,14 +111,6 @@
}
}
},
"comments": {
"patterns": [
{
"name": "comment.line",
"match": "!.*|REM.*|REMARK.*"
}
]
},
"function-decl": {
"name": "meta.function",
"begin": "(?i)\\b(FUNCTION|DEF)\\s+((\\?|[a-zA-Z])([a-zA-Z0-9#.]*)[\\$#%]?)",
@@ -184,7 +175,7 @@
},
"subroutine-end": {
"name": "keyword.control",
"match": "END SUB|end sub"
"match": "(?i)END\\s+SUB"
},
"integer-decl": {
"begin": "(INTEGER|integer)((\\*)(1|2|4))?",
@@ -206,7 +197,7 @@
},
{
"name": "entity.name.function",
"match": "(\\?|[a-zA-Z])([a-zA-Z0-9#.]*)([\\$#%])?",
"match": "(\\?|[a-zA-Z])([a-zA-Z0-9#\\.]*)([\\$#%])?",
"captures": {
"3": {
"name": "keyword.operator"
@@ -283,7 +274,7 @@
}
},
"real-decl": {
"begin": "REAL|real",
"begin": "(?i)REAL\\s+",
"beginCaptures": {
"0": {
"name": "storage.type"
@@ -365,25 +356,7 @@
},
"math-function": {
"name": "support.function.arithmetic",
"match": "(?i)\\b(ABS|CHR\\$|FLOAT|INT%?|MOD|PEEK|SGN|SHIFT|STR\\$|TAB)\\b[^%\\$\\.]"
},
"variable-assignment": {
"name": "meta.assignment",
"match": "^\\s*(\\?|[a-zA-Z])([a-zA-Z0-9#.]*)([\\$#%])?\\s+(=)",
"captures": {
"1": {
"name": "variable.name"
},
"2": {
"name": "variable.name"
},
"3": {
"name": "keyword.operator"
},
"4": {
"name": "keyword.operator.arithmetic"
}
}
"match": "(?i)\\b(ABS|CHR\\$|FLOAT|INT%?|MOD|PEEK|SGN|SHIFT|STR\\$|TAB)(?=\\s*\\()"
},
"numeric-expression": {
"name": "meta.expression.numeric",
@@ -405,24 +378,28 @@
]
},
"identifier": {
"patterns": [
{
"name": "variable.name",
"match": "\\b(\\?|[a-zA-Z])([a-zA-Z0-9#.]*)[\\$#%]?\\b"
"name": "meta.identifier",
"match": "((\\?|[a-zA-Z])([a-zA-Z0-9#\\.]*))([\\$#%])?",
"captures": {
"1": {
"name": "variable.name"
},
"4": {
"name": "keyword.operator"
}
]
}
},
"number-literal": {
"patterns": [
{
"name": "constant.numeric",
"match": "(?i)\\b([+-]?[0-9.]+)(E[+-]?[0-9]+)?[hb]?\\b"
"match": "(?i)\\b([+-]?[0-9\\.ABCDEF]+)(E[+-]?[0-9]+)?[HB]?\\b"
}
]
},
"arithmetic-operator": {
"name": "keyword.operator.arithmetic",
"match": "[\\+-\\/\\^\\*]"
"match": "[\\+-\\/\\^\\*#]"
},
"relational-operator": {
"name": "keyword.operator.relational",
@@ -430,27 +407,17 @@
},
"logical-operator": {
"name": "keyword.operator.logical",
"match": "\\b(NOT|AND|OR|XOR)\\b"
"match": "(?i)\\b(NOT|AND|OR|XOR)\\b"
},
"string-operator": {
"name": "keyword.operator",
"match": "[+]"
},
"string-function": {
"begin": "(?i)\\b(ASC|LEN|PACK\\$|TRANSLATE\\$|UCASE\\$|UNPACK\\$|VAL|MID\\$|LEFT\\$|RIGHT\\$|MATCH)\\b",
"beginCaptures": {
"1": {
"name": "support.function.string"
},
"0": {
"name": "meta.function-call.begin"
}
},
"end": "\\(",
"endCaptures": {
"0": {
"name": "punctuation.parameters.start"
}
"name": "support.function.builtin",
"match": "(?i)\\b(ASC|LEN|PACK\\$|TRANSLATE\\$|UCASE\\$|UNPACK\\$|VAL|MID\\$|LEFT\\$|RIGHT\\$|MATCH|SUBSTR|STRING\\$)(?=\\s*\\()",
"captures": {
"1": { "name": "support.function.builtin"}
}
},
"string-expression": {
@@ -542,7 +509,7 @@
"patterns": [
{
"name": "keyword.control",
"match": "(?i)\\b(GOSUB|RETURN|GOTO|WHILE|WEND|NEXT|ON|ERROR|STOP|RANDOMIZE|CHAIN|COMMON|CALL|EXIT SUB|FORM)\\b[^%\\$\\.]"
"match": "(?i)\\b(GOSUB|RETURN|GOTO|WHILE|WEND|NEXT|ON|ERROR|STOP|RANDOMIZE|CHAIN|COMMON|CALL|EXIT\\s+SUB|EXIT\\s+FUNCTION|FORM)\\b[^%\\$\\.]"
},
{
"name": "support.function",
@@ -550,17 +517,6 @@
}
]
},
"strings": {
"name": "string.quoted.double.4690basic",
"begin": "\"",
"end": "\"",
"patterns": [
{
"name": "constant.character.escape.4690basic",
"match": "\\\\."
}
]
},
"single-stmts": {
"name": "support.function",
"match": "(COMMAND$|CONCHAR%|CONSOLE|DATE$)"
@@ -585,24 +541,16 @@
{
"include": "#identifier"
},
{
"name": "punctuation.separator.parameter",
"match": ","
},
{
"name": "punctuation.separator.option",
"match": ";"
},
{
"match": "\\s+",
"name": "text.whitespace"
}
],
"end": "$"
"end": "(?<!\\\\)($|\\n)"
},
"open-close": {
"name": "support.function",
"match": "(?i)OPEN|CLOSE|KEYED|RECL|AS"
"match": "(?i)\\b(OPEN|CLOSE|KEYED|RECL|AS[^\\$])\\b"
},
"access-stmt": {
"match": "(ACCESS)\\s+((NOREAD|NOWRITE|NODEL)(\\s*,\\s*(NOREAD|NOWRITE|NODEL)){0,2})",
@@ -702,9 +650,6 @@
{
"include": "#number-literal"
},
{
"include": "#number-literal"
},
{
"include": "#arithmetic-operator"
},
@@ -732,6 +677,9 @@
"name": "keyword.control",
"match": "(?i)(BEGIN)"
},
{
"include": "#identifier"
},
{
"include": "#line-continuation"
},
@@ -743,7 +691,7 @@
"name": "text.whitespace"
}
],
"end": "(?<!\\\\)\\n"
"end": "(?<!\\\\)(\\n)"
},
"if-statement-end": {
"name": "meta.if.end",
@@ -811,7 +759,9 @@
"name": "meta.for",
"begin": "(?i)\\bFOR\\s+",
"beginCaptures": {
"0": { "name": "keyword.control" }
"0": {
"name": "keyword.control"
}
},
"patterns": [
{
@@ -832,6 +782,9 @@
},
{
"include": "#number-literal"
},
{
"include": "#comments"
}
],
"end": "(?<!\\\\)\\n"