123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801 |
- {
- "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
- "name": "QSP",
- "patterns": [
- {
- "include": "#preprocessor"
- },
- {
- "include": "#qsp-general-structures"
- }
- ],
- "repository": {
- "preprocessor": {
- "comment": "preprocessor text",
- "patterns": [
- {
- "name": "meta.preprocessor.start.qsp",
- "match": "^\\s*(#)\\s?.+$"
- },
- {
- "name": "meta.preprocessor.end.qsp",
- "match": "^-{1,2}\\S.*?\\S-{1,2}$"
- }
- ]
- },
- "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": [
- {
- "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",
- "include": "#qsp-general-structures"
- }
- }
- ]
- },
- "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": "([}])"
- },
- "qsp-general-structures": {
- "comment": "the general structures for this language",
- "patterns": [
- {
- "include": "#comments"
- },
- {
- "include": "#qsp-control-structures"
- },
- {
- "include": "#if-branches"
- },
- {
- "include": "#qsp-expression"
- },
- {
- "include": "#preprocessor"
- },
- {
- "include": "#single-words"
- }
- ]
- },
- "qsp-control-structures": {
- "comment": "some specialized structures",
- "patterns": [
- {
- "include": "#qsp-code-block"
- },
- {
- "include": "#loops"
- }
- ]
- },
- "qsp-code-block": {
- "comment": "code blocks for this language, only possible for 'act' or 'if'",
- "name": "meta.structure.codeblock.qsp",
- "patterns": [
- {
- "include": "#qsp-code-block-if"
- },
- {
- "include": "#qsp-code-block-act"
- }
- ]
- },
- "qsp-code-block-if": {
- "name": "meta.structure.codeblock.if.qsp",
- "begin": "^\\s*(?i:(if))\\b(.*\\S.*)(:)\\s*$\\n?",
- "beginCaptures": {
- "1": {
- "patterns": [
- {
- "include": "#keywords-if"
- }
- ]
- },
- "2": {
- "patterns": [
- {
- "include": "#if-condition"
- }
- ]
- },
- "3": {
- "name": "punctuation.separator.if.qsp"
- }
- },
- "patterns": [
- {
- "comment": "recursivly parse the body",
- "include": "#qsp-codeblock-body"
- }
- ],
- "end": "^\\s*(?i:(end))\\b",
- "endCaptures": {
- "1": {
- "patterns": [
- {
- "include": "#keywords-if"
- }
- ]
- }
- }
- },
- "qsp-code-block-act": {
- "name": "meta.structure.codeblock.act.qsp",
- "begin": "^\\s*(?i:(act))\\b(.*\\S.*)(:)\\s*$\\n?",
- "beginCaptures": {
- "1": {
- "patterns": [
- {
- "include": "#keywords-act"
- }
- ]
- },
- "2": {
- "patterns": [
- {
- "include": "#qsp-general-structures"
- }
- ]
- },
- "3": {
- "name": "punctuation.separator.act.qsp"
- }
- },
- "patterns": [
- {
- "comment": "recursivly parse the body",
- "include": "#qsp-codeblock-body"
- }
- ],
- "end": "^\\s*(?i:(end))\\b",
- "endCaptures": {
- "1": {
- "patterns": [
- {
- "include": "#keywords-act"
- }
- ]
- }
- }
- },
- "qsp-codeblock-body": {
- "patterns": [
- {
- "comment": "this body can contain everything again",
- "include": "#qsp-general-structures"
- }
- ]
- },
- "qsp-expression": {
- "comment": "basically 'act' or 'if' expressions",
- "name": "meta.structure.expression.qsp",
- "patterns": [
- {
- "include": "#pairs"
- },
- {
- "include": "#qsp-expression-if"
- },
- {
- "include": "#qsp-expression-act"
- },
- {
- "include": "#single-words"
- }
- ]
- },
- "qsp-expression-if": {
- "patterns": [
- {
- "begin": "\\s*\\b(?i:(if))\\b",
- "beginCaptures": {
- "1": {
- "patterns": [
- {
- "include": "#keywords-if"
- }
- ]
- }
- },
- "end": "([:])",
- "endCaptures": {
- "1": {
- "name": "punctuation.separator.if.qsp"
- }
- },
- "patterns": [
- {
- "include": "#qsp-expression"
- }
- ]
- },
- {
- "begin": "\\s*\\b(?i:(elseif))\\b",
- "beginCaptures": {
- "1": {
- "patterns": [
- {
- "include": "#keywords-if"
- }
- ]
- }
- },
- "end": "(?=([:]))",
- "endCaptures": {
- "1": {
- "name": "punctuation.separator.if.qsp"
- }
- },
- "patterns": [
- {
- "include": "#qsp-expression"
- }
- ]
- },
- {
- "match": "\\s*\\b(?i:(else))\\b",
- "captures": {
- "1": {
- "patterns": [
- {
- "include": "#keywords-if"
- }
- ]
- }
- }
- }
- ]
- },
- "qsp-expression-act": {
- "comment": "parse single line act",
- "begin": "\\s*\\b(?i:(act))\\b",
- "beginCaptures": {
- "1": {
- "patterns": [
- {
- "include": "#keywords-act"
- }
- ]
- }
- },
- "end": "([:])",
- "endCaptures": {
- "1": {
- "name": "punctuation.separator.act.qsp"
- }
- },
- "patterns": [
- {
- "include": "#qsp-expression"
- }
- ]
- },
- "loops": {
- "comment": "loop parsing",
- "name": "meta.structure.line.loop.qsp",
- "patterns": [
- {
- "match": "^\\s*(:)\\s?(.+?)\\s*$\\n?",
- "captures": {
- "1": {
- "name": "punctuation.separator.loop.qsp"
- },
- "2": {
- "name": "keyword.other.user.loop.qsp"
- }
- }
- },
- {
- "match": "\\b(?i:(jump))\\s?(['][a-zA-Z_][a-zA-Z0-9_]*?['])",
- "captures": {
- "1": {
- "patterns": [
- {"include": "#keywords-loop"}
- ]
- },
- "2": {
- "name": "keyword.other.user.loop.end.qsp"
- }
- }
- }
- ]
- },
- "pairs":{
- "patterns": [
- {"include": "#strings"},
- {
- "begin": "(\\[)",
- "beginCaptures": {
- "1":{"name":"punctuation.brackets.square.open.qsp"}
- },
- "end": "(\\])",
- "endCaptures": {
- "1":{"name":"punctuation.brackets.square.close.qsp"}
- },
- "patterns": [
- {"include": "#qsp-general-structures"}
- ]
- },
- {
- "begin": "([{])",
- "beginCaptures": {
- "1":{"name":"punctuation.brackets.curly.open.qsp"}
- },
- "end": "([}])",
- "endCaptures": {
- "1":{"name":"punctuation.brackets.curly.close.qsp"}
- },
- "patterns": [
- {"include": "#qsp-general-structures"}
- ]
- },
- {
- "begin": "([(])",
- "beginCaptures": {
- "1":{"name":"punctuation.brackets.round.open.qsp"}
- },
- "end": "([)])",
- "endCaptures": {
- "1":{"name":"punctuation.brackets.round.close.qsp"}
- },
- "patterns": [
- {"include": "#qsp-general-structures"}
- ]
- }
- ]
- },
- "strings": {
- "comment": "parse string and their inlines",
- "patterns": [
- {
- "begin": "(\")",
- "beginCaptures": {
- "0":{"name":"string.quoted.double.qsp"},
- "1":{"name":"punctuation.definition.string.begin.qsp"}
- },
- "end": "(\")",
- "endCaptures": {
- "0":{"name":"string.quoted.double.qsp"},
- "1":{"name":"punctuation.definition.string.end.qsp"}
- },
- "patterns": [
- {
- "include": "#stringInterpolated"
- },
- {
- "match": ".",
- "name": "string.quoted.double.qsp"
- }
- ]
- },
- {
- "begin": "(')",
- "beginCaptures": {
- "0":{"name":"string.quoted.single.qsp"},
- "1":{"name":"punctuation.definition.string.begin.qsp"}
- },
- "end": "(')",
- "endCaptures": {
- "0":{"name":"string.quoted.single.qsp"},
- "1":{"name":"punctuation.definition.string.end.qsp"}
- },
- "patterns": [
- {
- "include": "#stringInterpolated"
- },
- {
- "comment": "//TODO: html parsing, default doesn't work due to inline code: 'include': 'text.html.basic'"
- },
- {
- "match": ".",
- "name": "string.quoted.single.qsp"
- }
- ]
- }
- ]
- },
- "stringInterpolated": {
- "name":"meta.interpolation.qsp",
- "begin": "(<<)",
- "beginCaptures": {
- "1":{
- "name":"punctuation.definition.stringinterpolation.qsp"
- }
- },
- "end": "(>>)",
- "endCaptures": {
- "1":{
- "name":"punctuation.definition.stringinterpolation.qsp"
- }
- },
- "patterns": [
- {
- "include": "#qsp-general-structures"
- }
- ]
- },
- "if-branches": {
- "comment": "'elseif' or 'else' whithin a 'if'-block",
- "patterns": [
- {
- "include": "#elseif-branch"
- },
- {
- "include": "#else-branch"
- }
- ]
- },
- "elseif-branch": {
- "comment": "elseif statement within if block",
- "match": "^\\s*(?i:(elseif))\\b\\s*(.?\\S.*?)(:)\\s*$\\n?",
- "captures": {
- "0": {
- "name": "meta.structure.qsp.codeblock.if.elseif.qsp"
- },
- "1": {
- "patterns": [
- {
- "include": "#keywords-if"
- }
- ]
- },
- "2": {
- "patterns": [
- {
- "include": "#if-condition"
- }
- ]
- },
- "3": {
- "name": "punctuation.condition.if.qsp"
- }
- }
- },
- "else-branch": {
- "comment": "else statement within if block",
- "match": "^\\s*(?i:(else))\\s*$\\n?",
- "captures": {
- "0": {
- "name": "meta.structure.qsp.codeblock.if.else.qsp"
- },
- "1": {
- "patterns": [
- {
- "include": "#keywords-if"
- }
- ]
- }
- }
- },
- "if-condition": {
- "patterns": [
- {
- "include": "#condition-pairs"
- },
- {
- "include": "#compare"
- },
- {
- "include": "#single-words"
- }
- ]
- },
- "condition-pairs":{
- "patterns": [
- {"include": "#strings"},
- {
- "begin": "(\\[)",
- "beginCaptures": {
- "1":{"name":"punctuation.brackets.square.open.qsp"}
- },
- "end": "(\\])",
- "endCaptures": {
- "1":{"name":"punctuation.brackets.square.close.qsp"}
- },
- "patterns": [
- {"include": "#if-condition"}
- ]
- },
- {
- "begin": "([(])",
- "beginCaptures": {
- "1":{"name":"punctuation.brackets.round.open.qsp"}
- },
- "end": "([)])",
- "endCaptures": {
- "1":{"name":"punctuation.brackets.round.close.qsp"}
- },
- "patterns": [
- {"include": "#if-condition"}
- ]
- },
- {
- "begin": "([{])",
- "beginCaptures": {
- "1":{"name":"punctuation.brackets.curly.open.qsp"}
- },
- "end": "([}])",
- "endCaptures": {
- "1":{"name":"punctuation.brackets.curly.close.qsp"}
- },
- "patterns": [
- {"include": "#qsp-general-structures"}
- ]
- }
- ]
- },
- "compare": {
- "patterns": [
- {
- "comment": "QSP accepts this, but it complicates text search and is bad practice",
- "name": "invalid.keyword.operator.compare.qsp",
- "match": "(=(<|>))"
- },
- {
- "name": "keyword.operator.compare.qsp",
- "match": "((<|>)?=|!|<>|<|>)"
- }
- ]
- },
- "single-words": {
- "comment": "patterns for single words",
- "patterns": [
- {
- "include": "#keywords"
- },
- {
- "include": "#entities"
- },
- {
- "include": "#qsp-variables"
- },
- {
- "include": "#constants"
- },
- {
- "include": "#errors"
- },
- {
- "include": "#keywords-if"
- },
- {
- "include": "#keywords-act"
- },
- {
- "include": "#user-variables"
- }
- ]
- },
- "keywords": {
- "patterns": [
- {
- "name": "keyword.operator.other.qsp",
- "match": "\\b(?i:(mod))\\b"
- },
- {
- "name": "keyword.operator.symbolic.qsp",
- "match": "[\\&*/+-]\\s*\\b"
- },
- {
- "name": "keyword.operator.assign.qsp",
- "match": "([*/+-]?[=])"
- },
- {
- "name": "keyword.control.exit.qsp",
- "match": "\\b(?i:(exit))\\b"
- }
- ]
- },
- "keywords-if": {
- "patterns": [
- {
- "name": "keyword.control.if.qsp",
- "match": "\\b(?i:(if))\\b"
- },
- {
- "name": "keyword.control.elseif.qsp",
- "match": "\\b(?i:(elseif))\\b"
- },
- {
- "name": "keyword.control.else.qsp",
- "match": "\\b(?i:(else))\\b"
- },
- {
- "name": "keyword.control.if.end.qsp",
- "match": "\\b(?i:(end))\\b"
- }
- ]
- },
- "keywords-act": {
- "patterns": [
- {
- "name": "keyword.control.act.qsp",
- "match": "\\b(?i:(act))\\b"
- },
- {
- "name": "keyword.control.act.end.qsp",
- "match": "\\b(?i:(end))\\b"
- }
- ]
- },
- "keywords-loop": {
- "patterns": [
- {
- "name": "keyword.control.loop.qsp",
- "match": "\\b(?i:(jump))\\b"
- }
- ]
- },
- "entities": {
- "patterns": [
- {
- "name": "entity.name.function.display.qsp",
- "match": "((\\s?[*]|^[*]|\\b)(?i:(cl(r|s|a)|clear|(n|p)l|p))|\\b(?i:(view|msg|menu|cmdcl(ea)?r)|showacts|showinput|showobjs|showstat))\\b"
- },
- {
- "name": "entity.name.function.include.qsp",
- "match": "\\b(?i:(xgt|xgoto|gt|goto|gs|gosub))\\b"
- },
- {
- "name": "entity.name.function.language.str.qsp",
- "match": "((\\b|\\s?[$])(?i:(mid|(u|l)case|trim|replace|str|strfind))|\\b(?i:(val|instr|isnum|len|strpos|strcomp)))\\b"
- },
- {
- "name": "entity.name.function.language.array.qsp",
- "match": "\\b(?i:(arrsize|arrpos|arrcomp|copyarr))\\b"
- },
- {
- "name": "entity.name.function.language.math.qsp",
- "match": "((\\b|\\s?[$])(?i:(max|min))|\\b(?i:(r(a)?nd)))\\b"
- },
- {
- "name": "entity.name.function.language.main.qsp",
- "match": "((\\b|\\s?[$])(?i:(func|dyneval|input|iif|qspver))|\\b(?i:(settimer|loc|dynamic|close(\\sall)?|play|(s|l)et)))\\b"
- },
- {
- "name": "entity.name.function.language.object.qsp",
- "match": "\\b(?i:(countobj|delobj|addobj|unsel(ect)?|killobj))\\b"
- },
- {
- "name": "entity.name.function.language.game.qsp",
- "match": "\\b(?i:(opengame|openqst|addqst|killqst|savegame|refint))\\b"
- },
- {
- "name": "entity.name.function.language.other.qsp",
- "match": "\\b(?i:(rgb|isplay|msecscount|killvar))\\b"
- }
- ]
- },
- "qsp-variables": {
- "patterns": [
- {
- "name": "variable.language.object.qsp",
- "match": "(\\b|\\s?[$])(?i:(desc|user_text|usrtxt|maintxt|stattxt|curloc|selobj|getobj|delact|selact|curact|result))\\b"
- },
- {
- "name": "variable.language.args.qsp",
- "match": "(\\b|\\s?[$])(?i:(args))\\b"
- },
- {
- "name": "variable.language.int.qsp",
- "match": "\\b(?i:(disablescroll|disablesubex|nosave|debug|usehtml|(b|f|l)color|fsize))\\b"
- },
- {
- "name": "variable.language.str.qsp",
- "match": "\\s?[$](?i:(counter|ongload|ongsave|onnewloc|onactsel|onobjsel|onobjadd|onobjdel|usercom|fname|backimage))\\b"
- }
- ]
- },
- "constants": {
- "patterns": [
- {
- "name": "constant.numeric.qsp",
- "match": "\\b\\d+\\b"
- },
- {
- "name": "constant.language.qsp",
- "match": "\\b(?i:(no|and|or))\\b"
- }
- ]
- },
- "errors": {
- "name": "invalid.keyword.control.qsp",
- "patterns": [
- {
- "name": "invalid.keyword.control.end.qsp",
- "match": "(^|\\b)(?i:(end))\\b"
- },
- {
- "name": "invalid.keyword.control.condition.qsp",
- "match": "\\b(?i:(if|elseif|else))\\b"
- },
- {
- "name": "invalid.keyword.control.act.qsp",
- "match": "\\b(?i:(act))\\b"
- }
- ]
- },
- "user-variables": {
- "name": "variable.other.user.qsp",
- "match": "(\\B[$])?\\b([a-zA-Z_\\x{7f}-\\x{ff}][a-zA-Z0-9_\\x{7f}-\\x{ff}]*?)\\b"
- }
- },
- "scopeName": "source.qsp"
- }
|