Files
4690-BASIC-Language-Support/syntaxes/4690basic.tmLanguage.json

841 lines
15 KiB
JSON

{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "4690 BASIC",
"patterns": [
{
"name": "string.quoted.double",
"begin": "\"",
"end": "\"",
"patterns": [
{
"match": ".",
"name": "string.quoted.double"
}
]
},
{
"name": "string.regexp",
"match": "\\b[\\w\\.]+:"
},
{
"include": "#comments"
},
{
"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": "#string-function"
},
{
"include": "#variable-assignment"
},
{
"include": "#if-statement"
},
{
"include": "#if-statement-end"
},
{
"include": "#for-statement"
},
{
"include": "#arithmetic-operator"
},
{
"include": "#relational-operator"
},
{
"include": "#logical-operator"
},
{
"include": "#line-continuation"
},
{
"include": "#keywords"
},
{
"include": "#strings"
},
{
"include": "#stmt-w-parameters"
},
{
"include": "#access-stmt"
},
{
"include": "#dim-stmt"
},
{
"include": "#compiler-directives"
},
{
"include": "#on-error"
},
{
"include": "#open-close"
},
{
"include": "#number-literal"
},
{
"include": "#identifier"
}
],
"repository": {
"line-continuation": {
"name": "meta.line.continuation",
"match": "\\\\(.*)\\n",
"captures": {
"1": {
"name": "comment"
}
}
},
"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#.]*)[\\$#%]?)",
"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": "PUBLIC|public|EXTERNAL|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": "END SUB|end 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": "REAL|real",
"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)\\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"
}
}
},
"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": {
"patterns": [
{
"name": "variable.name",
"match": "\\b(\\?|[a-zA-Z])([a-zA-Z0-9#.]*)[\\$#%]?\\b"
}
]
},
"number-literal": {
"patterns": [
{
"name": "constant.numeric",
"match": "(?i)\\b([+-]?[0-9.]+)(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": "\\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"
}
}
},
"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 SUB|FORM)\\b[^%\\$\\.]"
},
{
"name": "support.function",
"match": "(?i)\\b(NULL|TRUE|FALSE|READ|WRITE|KEY)\\b[^%\\$\\.]"
}
]
},
"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$)"
},
"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"
},
{
"name": "punctuation.separator.parameter",
"match": ","
},
{
"name": "punctuation.separator.option",
"match": ";"
},
{
"match": "\\s+",
"name": "text.whitespace"
}
],
"end": "$"
},
"open-close": {
"name": "support.function",
"match": "(?i)OPEN|CLOSE|KEYED|RECL|AS"
},
"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": "meta.if",
"begin": "(?i)\\b(IF)",
"beginCaptures": {
"0": {
"name": "keyword.control"
}
},
"patterns": [
{
"include": "#math-function"
},
{
"include": "#string-function"
},
{
"include": "#number-literal"
},
{
"include": "#number-literal"
},
{
"include": "#arithmetic-operator"
},
{
"include": "#relational-operator"
},
{
"include": "#logical-operator"
},
{
"include": "#keywords"
},
{
"include": "#strings"
},
{
"name": "keyword.control",
"match": "(?i)THEN"
},
{
"name": "keyword.control",
"match": "(?i)ELSE"
},
{
"name": "keyword.control",
"match": "(?i)(BEGIN)"
},
{
"include": "#line-continuation"
},
{
"include": "#comments"
},
{
"match": "\\s+",
"name": "text.whitespace"
}
],
"end": "(?<!\\\\)\\n"
},
"if-statement-end": {
"name": "meta.if.end",
"begin": "(?i)ENDIF",
"beginCaptures": {
"0": {
"name": "keyword.control"
}
},
"patterns": [
{
"name": "keyword.control",
"match": "ELSE"
},
{
"include": "#math-function"
},
{
"include": "#string-function"
},
{
"include": "#number-literal"
},
{
"include": "#arithmetic-operator"
},
{
"include": "#relational-operator"
},
{
"include": "#logical-operator"
},
{
"include": "#keywords"
},
{
"include": "#strings"
},
{
"name": "keyword.control",
"match": "THEN|then"
},
{
"name": "keyword.control",
"match": "(?i)BEGIN"
},
{
"name": "keyword.control",
"match": "(?i)ELSE"
},
{
"name": "keyword.control",
"match": "(?i)IF"
},
{
"include": "#line-continuation"
},
{
"include": "#comments"
}
],
"end": "(?<!\\\\)\\n"
},
"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"
}
],
"end": "(?<!\\\\)\\n"
}
},
"scopeName": "source.4690basic"
}