diff --git a/.gitignore b/.gitignore index e69de29..600d2d3 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +.vscode \ No newline at end of file diff --git a/vscode-ext/language-configurations.json b/vscode-ext/language-configurations.json new file mode 100644 index 0000000..ffd5219 --- /dev/null +++ b/vscode-ext/language-configurations.json @@ -0,0 +1,19 @@ +{ + "brackets": [ + ["{", "}"], + ["[", "]"], + ["<", ">"] + ], + "autoClosingPairs": [ + { "open": "{", "close": "}" }, + { "open": "[", "close": "]" }, + { "open": "(", "close": ")" }, + { "open": "<", "close": ">" } + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["<", ">"] + ] +} \ No newline at end of file diff --git a/vscode-ext/package.json b/vscode-ext/package.json new file mode 100644 index 0000000..bd2c40b --- /dev/null +++ b/vscode-ext/package.json @@ -0,0 +1,33 @@ +{ + "name": "midas", + "version": "0.1.0", + "engines": { + "vscode": "*" + }, + "categories": ["Programming Languages"], + "contributes": { + "languages": [ + { + "id": "midas", + "extensions": [ + ".mpy", + ".midas" + ], + "aliases": [ + "Midas" + ], + "configuration": "./language-configuration.json" + } + ], + "grammars": [ + { + "language": "midas", + "scopeName": "source.midas", + "path": "./syntaxes/midas.tmLanguage.json", + "embeddedLanguages": { + "meta.embedded.block.python": "python" + } + } + ] + } +} \ No newline at end of file diff --git a/vscode-ext/syntaxes/midas.tmLanguage.json b/vscode-ext/syntaxes/midas.tmLanguage.json new file mode 100644 index 0000000..44745b0 --- /dev/null +++ b/vscode-ext/syntaxes/midas.tmLanguage.json @@ -0,0 +1,135 @@ +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "Midas", + "scopeName": "source.midas", + "patterns": [{ "include": "#statement" }], + "repository": { + "comment": { + "begin": "(//)", + "end": "($)", + "name": "comment.line", + "beginCaptures": { + "1": { + "name": "comment.line.double-dash" + } + } + }, + "type-def": { + "begin": "\\b(type)\\s+([a-zA-Z_][a-zA-Z_\\d]*)", + "end": "$", + "beginCaptures": { + "1": { + "name": "keyword.control.type.midas" + }, + "2": { + "name" : "variable.name" + } + }, + "patterns": [ + { "include": "#type-base" }, + { "include": "#type-body" } + ] + }, + "type-base": { + "begin": "<", + "end": ">", + "beginCaptures": { + "0": { + "name": "punctuation.definition.base.begin.midas" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.base.end.midas" + } + }, + "patterns": [ + {"include": "source.python"} + ] + }, + "type-body": { + "begin": "\\{", + "end": "\\}", + "beginCaptures": { + "0": { + "name": "punctuation.definition.type-body.begin.midas" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.type-body.end.midas" + } + }, + "patterns": [ + {"include": "#type-prop"} + ] + }, + "type-prop": { + "match": "([a-zA-Z_][a-zA-Z_\\d]*)(:)\\s*([a-zA-Z_][a-zA-Z_\\d]*)", + "captures": { + "1": { + "name": "variable.name" + }, + "2": { + "name": "punctuation.separator.annotation.midas" + }, + "3": { + "name": "meta.type.name" + } + } + }, + "op-def": { + "match": "\\b(op)\\s+<([a-zA-Z_][a-zA-Z_\\d]*)>\\s+(\\S+)\\s+<([a-zA-Z_][a-zA-Z_\\d]*)>\\s+(=)\\s+<([a-zA-Z_][a-zA-Z_\\d]*)>", + "captures": { + "1": { + "name": "keyword.control.op.midas" + }, + "2": { + "name" : "variable.name" + }, + "3": { + "name" : "keyword.operator" + }, + "4": { + "name" : "variable.name" + }, + "5": { + "name" : "keyword.operator.assignment" + }, + "6": { + "name" : "variable.name" + } + }, + "patterns": [ + { "include": "#type-base" }, + { "include": "#type-body" } + ] + }, + "constr-def": { + "begin": "(constraint)\\s+([a-zA-Z_][a-zA-Z_\\d]*)\\s*(=)", + "end": "$", + "beginCaptures": { + "1": { + "name": "keyword.control.constr.midas" + }, + "2": { + "name": "variable.name" + }, + "3": { + "name": "keyword.operator.assignment" + } + }, + "patterns": [ + { "include": "source.python" } + ] + }, + "statement": { + "patterns": [ + { "include": "#comment" }, + { "include": "#type-def" }, + { "include": "#op-def" }, + { "include": "#constr-def" } + ] + } + } +} \ No newline at end of file