mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
add vscode syntax plugin
This commit is contained in:
4
resources/editor_plugins/vscode/.vscodeignore
Normal file
4
resources/editor_plugins/vscode/.vscodeignore
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
.vscode/**
|
||||||
|
.vscode-test/**
|
||||||
|
.gitignore
|
||||||
|
vsc-extension-quickstart.md
|
||||||
35
resources/editor_plugins/vscode/example.c3
Normal file
35
resources/editor_plugins/vscode/example.c3
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
module stack <Type>;
|
||||||
|
// Above: the parameterized type is applied to the entire module.
|
||||||
|
import std::mem;
|
||||||
|
|
||||||
|
struct Stack
|
||||||
|
{
|
||||||
|
usize capacity;
|
||||||
|
usize size;
|
||||||
|
Type* elems;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The type methods offers dot syntax calls,
|
||||||
|
// so this function can either be called
|
||||||
|
// Stack.push(&my_stack, ...) or
|
||||||
|
// my_stack.push(...)
|
||||||
|
fn void Stack.push(Stack* this, Type element)
|
||||||
|
{
|
||||||
|
if (this.capacity == this.size)
|
||||||
|
{
|
||||||
|
this.capacity *= 2;
|
||||||
|
this.elems = mem::realloc(this.elems, $sizeof(Type) * this.capacity);
|
||||||
|
}
|
||||||
|
this.elems[this.size++] = element;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn Type Stack.pop(Stack* this)
|
||||||
|
{
|
||||||
|
assert(this.size > 0);
|
||||||
|
return this.elems[--this.size];
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bool Stack.empty(Stack* this)
|
||||||
|
{
|
||||||
|
return !this.size;
|
||||||
|
}
|
||||||
30
resources/editor_plugins/vscode/language-configuration.json
Normal file
30
resources/editor_plugins/vscode/language-configuration.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"comments": {
|
||||||
|
// symbol used for single line comment. Remove this entry if your language does not support line comments
|
||||||
|
"lineComment": "//",
|
||||||
|
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
|
||||||
|
"blockComment": [ "/*", "*/" ]
|
||||||
|
},
|
||||||
|
// symbols used as brackets
|
||||||
|
"brackets": [
|
||||||
|
["{", "}"],
|
||||||
|
["[", "]"],
|
||||||
|
["(", ")"]
|
||||||
|
],
|
||||||
|
// symbols that are auto closed when typing
|
||||||
|
"autoClosingPairs": [
|
||||||
|
["{", "}"],
|
||||||
|
["[", "]"],
|
||||||
|
["(", ")"],
|
||||||
|
["\"", "\""],
|
||||||
|
["'", "'"]
|
||||||
|
],
|
||||||
|
// symbols that can be used to surround a selection
|
||||||
|
"surroundingPairs": [
|
||||||
|
["{", "}"],
|
||||||
|
["[", "]"],
|
||||||
|
["(", ")"],
|
||||||
|
["\"", "\""],
|
||||||
|
["'", "'"]
|
||||||
|
]
|
||||||
|
}
|
||||||
25
resources/editor_plugins/vscode/package.json
Normal file
25
resources/editor_plugins/vscode/package.json
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "c3-vscode",
|
||||||
|
"displayName": "c3-vscode",
|
||||||
|
"description": "C3 Language Support for VSCode",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"engines": {
|
||||||
|
"vscode": "^1.63.0"
|
||||||
|
},
|
||||||
|
"categories": [
|
||||||
|
"Programming Languages"
|
||||||
|
],
|
||||||
|
"contributes": {
|
||||||
|
"languages": [{
|
||||||
|
"id": "c3",
|
||||||
|
"aliases": ["C3", "c3"],
|
||||||
|
"extensions": ["c3"],
|
||||||
|
"configuration": "./language-configuration.json"
|
||||||
|
}],
|
||||||
|
"grammars": [{
|
||||||
|
"language": "c3",
|
||||||
|
"scopeName": "source.c3",
|
||||||
|
"path": "./syntaxes/c3.tmLanguage.json"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
150
resources/editor_plugins/vscode/syntaxes/c3.tmLanguage.json
Normal file
150
resources/editor_plugins/vscode/syntaxes/c3.tmLanguage.json
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||||
|
"name": "C3",
|
||||||
|
"patterns": [
|
||||||
|
{ "include": "#keywords" },
|
||||||
|
{ "include": "#comments" },
|
||||||
|
{ "include": "#strings" },
|
||||||
|
{ "include": "#numbers" },
|
||||||
|
{ "include": "#types" },
|
||||||
|
{ "include": "#support" },
|
||||||
|
{ "include": "#operators" }
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"keywords": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "keyword",
|
||||||
|
"match": "\\b(extern|break|case|const|continue|default)\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword",
|
||||||
|
"match": "\\b(do|else|for|goto|if|return|null)\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword",
|
||||||
|
"match": "\\b(define|local|errtype|module|as|import)\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword",
|
||||||
|
"match": "\\b(generic|switch|typedef|volatile)\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword",
|
||||||
|
"match": "\\b(while|fn|nil|next|in|$for|$case)\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword",
|
||||||
|
"match": "\\b(%switch|$default|$if|$elif|$else)\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword",
|
||||||
|
"match": "\\b(true|false)\\b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"comments": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "comment.line",
|
||||||
|
"begin": "//",
|
||||||
|
"end": "$"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "comment.block",
|
||||||
|
"begin": "/\\*",
|
||||||
|
"end": "\\*/"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"strings": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "string.quoted.double",
|
||||||
|
"patterns": [ {"include": "#stringcontent"} ],
|
||||||
|
"begin": "\"",
|
||||||
|
"end": "\""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "string.quoted.double",
|
||||||
|
"patterns": [ {"include": "#stringcontent"} ],
|
||||||
|
"begin": "b64\"",
|
||||||
|
"end": "\""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "string.quoted.double",
|
||||||
|
"patterns": [ {"include": "#stringcontent"} ],
|
||||||
|
"begin": "x\"",
|
||||||
|
"end": "\""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "string.quoted.single",
|
||||||
|
"patterns": [ {"include": "#stringcontent"} ],
|
||||||
|
"begin": "'",
|
||||||
|
"end": "'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "string.quoted.single",
|
||||||
|
"patterns": [ {"include": "#stringcontent"} ],
|
||||||
|
"begin": "b64'",
|
||||||
|
"end": "'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "string.quoted.single",
|
||||||
|
"patterns": [ {"include": "#stringcontent"} ],
|
||||||
|
"begin": "x'",
|
||||||
|
"end": "'"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"stringcontent": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "constant.character.escape",
|
||||||
|
"match": "\\\\([nrt'\"\\\\]|(x[0-9a-fA-F]{2})|(u\\{[0-9a-fA-F]+\\}))"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "invalid.illegal.unrecognized-string-escape",
|
||||||
|
"match": "\\\\."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"numbers": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "constant.numeric",
|
||||||
|
"match": "\\b[0-9]\\.[0-9]+\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "constant.numeric",
|
||||||
|
"match": "\\b[0-9]+\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "constant.numeric",
|
||||||
|
"match": "\\b0x[a-fA-F0-9_]+\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "constant.numeric",
|
||||||
|
"match": "\\b0o[0-7_]+\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "constant.numeric",
|
||||||
|
"match": "\\b0b[01_]+\\b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"types": {
|
||||||
|
"name": "storage.type",
|
||||||
|
"match": "\\b(double|usize|type|Type|bool|char|enum|float|int|uint|long|ulong|short|ushort|struct|void)\\b"
|
||||||
|
},
|
||||||
|
"support": {
|
||||||
|
"name": "support.function.builtin",
|
||||||
|
"match": "\\$[_a-zA-Z][_a-zA-Z0-9]*"
|
||||||
|
},
|
||||||
|
"operators": {
|
||||||
|
"name": "keyword.operator",
|
||||||
|
"match": "(\\+|-|\\.|%|&|\\||=|<|>|!|\\^|\\*|/|::)=?"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scopeName": "source.c3"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user