697 lines
12 KiB
JSON
697 lines
12 KiB
JSON
{
|
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
|
"name": "4690 BASIC",
|
|
"patterns": [
|
|
{
|
|
"include": "#comments"
|
|
},
|
|
{
|
|
"include": "#strings"
|
|
},
|
|
{
|
|
"name": "string.regexp",
|
|
"match": "\\b[\\w\\.]+:"
|
|
},
|
|
{
|
|
"name": "meta",
|
|
"match": "\\s:"
|
|
},
|
|
{
|
|
"include": "#function-decl"
|
|
},
|
|
{
|
|
"include": "#function-end"
|
|
},
|
|
{
|
|
"include": "#subroutine-decl"
|
|
},
|
|
{
|
|
"include": "#subroutine-end"
|
|
},
|
|
{
|
|
"include": "#integer-decl"
|
|
},
|
|
{
|
|
"include": "#string-decl"
|
|
},
|
|
{
|
|
"include": "#real-decl"
|
|
},
|
|
{
|
|
"include": "#math-function"
|
|
},
|
|
{
|
|
"include": "#if-statement"
|
|
},
|
|
{
|
|
"include": "#if-statement-end"
|
|
},
|
|
{
|
|
"include": "#else"
|
|
},
|
|
{
|
|
"include": "#then"
|
|
},
|
|
{
|
|
"include": "#for-statement"
|
|
},
|
|
{
|
|
"include": "#arithmetic-operator"
|
|
},
|
|
{
|
|
"include": "#relational-operator"
|
|
},
|
|
{
|
|
"include": "#logical-operator"
|
|
},
|
|
{
|
|
"include": "#line-continuation"
|
|
},
|
|
{
|
|
"include": "#keywords"
|
|
},
|
|
{
|
|
"include": "#stmt-w-parameters"
|
|
},
|
|
{
|
|
"include": "#access-stmt"
|
|
},
|
|
{
|
|
"include": "#dim-stmt"
|
|
},
|
|
{
|
|
"include": "#compiler-directives"
|
|
},
|
|
{
|
|
"include": "#on-error"
|
|
},
|
|
{
|
|
"include": "#open-close"
|
|
},
|
|
{
|
|
"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",
|
|
"captures": {
|
|
"1": {
|
|
"name": "comment"
|
|
}
|
|
}
|
|
},
|
|
"function-decl": {
|
|
"name": "meta.function",
|
|
"begin": "(?i)\\b(FUNCTION|DEF)\\s+((\\?|[a-zA-Z])([a-zA-Z0-9#.]*)[\\$#%]?)",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "storage.type.function"
|
|
},
|
|
"2": {
|
|
"name": "entity.name.function"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#parameter-list"
|
|
},
|
|
{
|
|
"include": "#fun-sub-modifier"
|
|
},
|
|
{
|
|
"include": "#line-continuation"
|
|
},
|
|
{
|
|
"include": "#comments"
|
|
}
|
|
],
|
|
"end": "(?<!\\\\)\\n"
|
|
},
|
|
"function-end": {
|
|
"name": "keyword.control",
|
|
"match": "(?i)(FEND|END FUNCTION)"
|
|
},
|
|
"fun-sub-modifier": {
|
|
"name": "storage.modifer",
|
|
"match": "(?i)PUBLIC|EXTERNAL"
|
|
},
|
|
"subroutine-decl": {
|
|
"name": "meta.subroutine",
|
|
"begin": "\\b(SUB|sub)\\s+((\\?|[a-zA-Z])([a-zA-Z0-9#.]*)[\\$#%]?)",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "storage.type.function"
|
|
},
|
|
"2": {
|
|
"name": "entity.name.function"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#parameter-list"
|
|
},
|
|
{
|
|
"include": "#fun-sub-modifier"
|
|
},
|
|
{
|
|
"include": "#line-continuation"
|
|
},
|
|
{
|
|
"include": "#comments"
|
|
}
|
|
],
|
|
"end": "(?<!\\\\)\\n"
|
|
},
|
|
"subroutine-end": {
|
|
"name": "keyword.control",
|
|
"match": "(?i)END\\s+SUB"
|
|
},
|
|
"integer-decl": {
|
|
"begin": "(INTEGER|integer)((\\*)(1|2|4))?",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "storage.type"
|
|
},
|
|
"3": {
|
|
"name": "keyword.operator.arithmetic"
|
|
},
|
|
"4": {
|
|
"name": "constant.numeric"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"name": "keyword.operator",
|
|
"match": "GLOBAL|global"
|
|
},
|
|
{
|
|
"name": "entity.name.function",
|
|
"match": "(\\?|[a-zA-Z])([a-zA-Z0-9#\\.]*)([\\$#%])?",
|
|
"captures": {
|
|
"3": {
|
|
"name": "keyword.operator"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "punctuation.separator.parameter",
|
|
"match": ","
|
|
},
|
|
{
|
|
"match": "\\s+",
|
|
"name": "text.whitespace"
|
|
},
|
|
{
|
|
"match": "\\\\(.*)$",
|
|
"captures": {
|
|
"1": {
|
|
"name": "comment"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"end": "(?<!\\\\.*?)\\n|(!.*)",
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "comment"
|
|
}
|
|
}
|
|
},
|
|
"string-decl": {
|
|
"begin": "(?i)STRING\\s+",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "storage.type"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"name": "keyword.operator",
|
|
"match": "GLOBAL|global"
|
|
},
|
|
{
|
|
"name": "entity.name.function",
|
|
"match": "(\\?|[a-zA-Z])([a-zA-Z0-9#.]*)([\\$#%])?",
|
|
"captures": {
|
|
"3": {
|
|
"name": "keyword.operator"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "punctuation.separator.parameter",
|
|
"match": ","
|
|
},
|
|
{
|
|
"match": "\\s+",
|
|
"name": "text.whitespace"
|
|
},
|
|
{
|
|
"match": "\\\\(.*)$",
|
|
"captures": {
|
|
"1": {
|
|
"name": "comment"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"end": "(?<!\\\\.*?)\\n|(!.*)",
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "comment"
|
|
}
|
|
}
|
|
},
|
|
"real-decl": {
|
|
"begin": "(?i)REAL\\s+",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "storage.type"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"name": "keyword.operator",
|
|
"match": "GLOBAL|global"
|
|
},
|
|
{
|
|
"name": "entity.name.function",
|
|
"match": "(\\?|[a-zA-Z])([a-zA-Z0-9#.]*)([\\$#%])?",
|
|
"captures": {
|
|
"3": {
|
|
"name": "keyword.operator"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "punctuation.separator.parameter",
|
|
"match": ","
|
|
},
|
|
{
|
|
"match": "\\s+",
|
|
"name": "text.whitespace"
|
|
},
|
|
{
|
|
"match": "\\\\(.*)$",
|
|
"captures": {
|
|
"1": {
|
|
"name": "comment"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"end": "(?<!\\\\.*?)\\n|(!.*)",
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "comment"
|
|
}
|
|
}
|
|
},
|
|
"parameter-list": {
|
|
"name": "meta.parameters",
|
|
"begin": "\\(",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.parameters.begin"
|
|
}
|
|
},
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.parameters.end"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#single-param"
|
|
},
|
|
{
|
|
"name": "punctuation.separator.parameter",
|
|
"match": ","
|
|
},
|
|
{
|
|
"match": "\\s+",
|
|
"name": "text.whitespace"
|
|
}
|
|
]
|
|
},
|
|
"single-param": {
|
|
"patterns": [
|
|
{
|
|
"name": "variable.parameter",
|
|
"match": "(\\?|[a-zA-Z])([a-zA-Z0-9#.]*)[\\$#%]?"
|
|
}
|
|
]
|
|
},
|
|
"math-function": {
|
|
"name": "support.function.arithmetic",
|
|
"match": "(?i)\\b(ABS|CHR\\$|FLOAT|INT%?|MOD|PEEK|SGN|SHIFT|STR\\$|TAB)(?=\\s*\\()"
|
|
},
|
|
"numeric-expression": {
|
|
"name": "meta.expression.numeric",
|
|
"patterns": [
|
|
{
|
|
"include": "#number-literal"
|
|
},
|
|
{
|
|
"include": "#arithmetic-operator"
|
|
},
|
|
{
|
|
"name": "variable.name",
|
|
"match": "(\\?|[a-zA-Z])([a-zA-Z0-9#.]*)%?"
|
|
},
|
|
{
|
|
"match": "\\s+",
|
|
"name": "text.whitespace"
|
|
}
|
|
]
|
|
},
|
|
"identifier": {
|
|
"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\\.ABCDEF]+)(E[+-]?[0-9]+)?[HB]?\\b"
|
|
}
|
|
]
|
|
},
|
|
"arithmetic-operator": {
|
|
"name": "keyword.operator.arithmetic",
|
|
"match": "[\\+-\\/\\^\\*#]"
|
|
},
|
|
"relational-operator": {
|
|
"name": "keyword.operator.relational",
|
|
"match": "(?i)(<=|<>|<|=>|>|=)|\\b(LT|LE|GT|GE|EQ|NE)\\b"
|
|
},
|
|
"logical-operator": {
|
|
"name": "keyword.operator.logical",
|
|
"match": "(?i)\\b(NOT|AND|OR|XOR)($|\\n|\\s\\()"
|
|
},
|
|
"string-operator": {
|
|
"name": "keyword.operator",
|
|
"match": "[+]"
|
|
},
|
|
"string-function": {
|
|
"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": {
|
|
"name": "meta.expression.string",
|
|
"patterns": [
|
|
{
|
|
"include": "#strings"
|
|
},
|
|
{
|
|
"include": "#string-operator"
|
|
},
|
|
{
|
|
"include": "#identifier"
|
|
},
|
|
{
|
|
"name": "\\s+",
|
|
"match": "text.whitespace"
|
|
}
|
|
]
|
|
},
|
|
"logical-expression": {
|
|
"name": "meta.expression.logical",
|
|
"patterns": [
|
|
{
|
|
"include": "#strings"
|
|
},
|
|
{
|
|
"include": "#logical-operator"
|
|
},
|
|
{
|
|
"include": "#identifier"
|
|
},
|
|
{
|
|
"include": "#number-literal"
|
|
},
|
|
{
|
|
"name": "variable.name",
|
|
"match": "(\\?|[a-zA-Z])([a-zA-Z0-9#.]*)%?"
|
|
},
|
|
{
|
|
"name": "\\s+",
|
|
"match": "text.whitespace"
|
|
}
|
|
]
|
|
},
|
|
"relational-expression": {
|
|
"name": "meta.expression.relational",
|
|
"patterns": [
|
|
{
|
|
"include": "#strings"
|
|
},
|
|
{
|
|
"include": "#relational-operator"
|
|
},
|
|
{
|
|
"include": "#identifier"
|
|
},
|
|
{
|
|
"include": "#number-literal"
|
|
},
|
|
{
|
|
"name": "variable.name",
|
|
"match": "(\\?|[a-zA-Z])([a-zA-Z0-9#.]*)%?"
|
|
},
|
|
{
|
|
"name": "\\s+",
|
|
"match": "text.whitespace"
|
|
}
|
|
]
|
|
},
|
|
"general-expression": {
|
|
"name": "meta.expression",
|
|
"patterns": [
|
|
{
|
|
"include": "#logical-expression"
|
|
},
|
|
{
|
|
"include": "#relational-expression"
|
|
},
|
|
{
|
|
"include": "#numeric-expression"
|
|
},
|
|
{
|
|
"include": "#string-expression"
|
|
}
|
|
]
|
|
},
|
|
"keywords": {
|
|
"patterns": [
|
|
{
|
|
"name": "keyword.control",
|
|
"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",
|
|
"match": "(?i)\\b(NULL|TRUE|FALSE|READ|WRITE|KEY|NOWRITE|NODEL)\\b[^%\\$\\.]"
|
|
}
|
|
]
|
|
},
|
|
"single-stmts": {
|
|
"name": "support.function",
|
|
"match": "(COMMAND$|CONCHAR%|CONSOLE|DATE$)"
|
|
},
|
|
"stmt-w-parameters": {
|
|
"begin": "(?i)\\b(ASSIGNKEY|CHDIR|COMMON|CLEARS|DATA|DELETE|DELREC|GOSUB|GOTO|INPUT( LINE)?|MKDIR|NEXT|POINT|POKE|PUT|PUTLONG|READ MATRIX|RESUME|RMDIR|USE|WAIT)\\b",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "keyword.other"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#io-session"
|
|
},
|
|
{
|
|
"include": "#string-expression"
|
|
},
|
|
{
|
|
"include": "#numeric-expression"
|
|
},
|
|
{
|
|
"include": "#identifier"
|
|
},
|
|
{
|
|
"match": "\\s+",
|
|
"name": "text.whitespace"
|
|
}
|
|
],
|
|
"end": "(?<!\\\\)($|\\n)"
|
|
},
|
|
"open-close": {
|
|
"name": "support.function",
|
|
"match": "(?i)\\b(OPEN|CLOSE|KEYED|RECL|AS[^\\$])\\b"
|
|
},
|
|
"access-stmt": {
|
|
"match": "(ACCESS)\\s+((NOREAD|NOWRITE|NODEL)(\\s*,\\s*(NOREAD|NOWRITE|NODEL)){0,2})",
|
|
"captures": {
|
|
"1": {
|
|
"name": "support.function"
|
|
},
|
|
"2": {
|
|
"name": "constant.language"
|
|
}
|
|
}
|
|
},
|
|
"dim-stmt": {
|
|
"begin": "(?i)DIM\\s+",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "support.function"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#identifier"
|
|
},
|
|
{
|
|
"include": "#dim-subscript"
|
|
},
|
|
{
|
|
"include": "#line-continuation"
|
|
},
|
|
{
|
|
"include": "#comments"
|
|
}
|
|
],
|
|
"end": "\\)|$"
|
|
},
|
|
"dim-subscript": {
|
|
"begin": "\\(",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "meta.function-call.begin"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"name": "constant.numeric",
|
|
"match": "\\d"
|
|
},
|
|
{
|
|
"include": "#identifier"
|
|
},
|
|
{
|
|
"name": "punctuation.separator.parameter",
|
|
"match": ","
|
|
},
|
|
{
|
|
"name": "text.whitespace",
|
|
"match": "\\s+"
|
|
}
|
|
],
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.parameters.end"
|
|
}
|
|
}
|
|
},
|
|
"compiler-directives": {
|
|
"name": "keyword.other",
|
|
"match": "(%)(INCLUDE|include|DEBUG|debug|ENVIRON|environ|NOLIST|nolist|LIST|list|EJECT|eject|PAGE|page)\\s+([^!\\r\\n]*)",
|
|
"captures": {
|
|
"1": {
|
|
"name": "keyword.operator"
|
|
},
|
|
"2": {
|
|
"name": "keyword.other"
|
|
},
|
|
"3": {
|
|
"name": "constant.numeric"
|
|
}
|
|
}
|
|
},
|
|
"if-statement": {
|
|
"name": "keyword.control",
|
|
"match": "(?i)\\b(IF|BEGIN)\\b"
|
|
},
|
|
"if-statement-end": {
|
|
"name": "keyword.control",
|
|
"match": "(?i)ENDIF"
|
|
},
|
|
"else": {
|
|
"name": "keyword.control",
|
|
"match": "(?i)ELSE"
|
|
},
|
|
"then": {
|
|
"name": "keyword.control",
|
|
"match": "(?i)THEN"
|
|
},
|
|
"for-statement": {
|
|
"name": "meta.for",
|
|
"begin": "(?i)\\bFOR\\s+",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "keyword.control"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"name": "keyword.control",
|
|
"match": "(?i)\\bTO\\b"
|
|
},
|
|
{
|
|
"include": "#relational-expression"
|
|
},
|
|
{
|
|
"include": "#arithmetic-expression"
|
|
},
|
|
{
|
|
"include": "#variable-assignment"
|
|
},
|
|
{
|
|
"include": "#identifier"
|
|
},
|
|
{
|
|
"include": "#number-literal"
|
|
},
|
|
{
|
|
"include": "#comments"
|
|
}
|
|
],
|
|
"end": "(?<!\\\\)\\n"
|
|
}
|
|
},
|
|
"scopeName": "source.4690basic"
|
|
} |