Mist highlighting
This commit is contained in:
@@ -17,7 +17,7 @@ The pattern is clear:
|
|||||||
|
|
||||||
## New proposition (Scope Counting)
|
## New proposition (Scope Counting)
|
||||||
I want to propose a new memory system (to my understanding), Scope Counting, which you have to see in action to understand it.
|
I want to propose a new memory system (to my understanding), Scope Counting, which you have to see in action to understand it.
|
||||||
```cpp
|
```mist
|
||||||
{
|
{
|
||||||
var x = new Box(10); // sc = 0
|
var x = new Box(10); // sc = 0
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ I want to propose a new memory system (to my understanding), Scope Counting, whi
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
```cpp
|
```mist
|
||||||
var r; // sc = 0
|
var r; // sc = 0
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -47,7 +47,7 @@ What makes this better is that it can still live with Rust's lifetime model when
|
|||||||
|
|
||||||
## More examples
|
## More examples
|
||||||
In rust this is a very limiting issue, but with SC, it goes how it's supposed to go
|
In rust this is a very limiting issue, but with SC, it goes how it's supposed to go
|
||||||
```cpp
|
```mist
|
||||||
str* longest(str* x, str* y) {
|
str* longest(str* x, str* y) {
|
||||||
if (x.len() > y.len()) return x;
|
if (x.len() > y.len()) return x;
|
||||||
else return y;
|
else return y;
|
||||||
@@ -57,7 +57,7 @@ str* longest(str* x, str* y) {
|
|||||||
Why? because both x and y are already a level higher.
|
Why? because both x and y are already a level higher.
|
||||||
|
|
||||||
if x is an outer scope of y (generally means lives longer), y would actually push it's sc to live as long as x, a better example is this:
|
if x is an outer scope of y (generally means lives longer), y would actually push it's sc to live as long as x, a better example is this:
|
||||||
```cpp
|
```mist
|
||||||
str* greet() {
|
str* greet() {
|
||||||
return "hello, world!"; // Impossible in Rust
|
return "hello, world!"; // Impossible in Rust
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,231 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||||
|
"name": "mist",
|
||||||
|
"scopeName": "source.mist",
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#comments"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#keywords"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#attributes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#strings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#macros"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#type_declarations"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#constants"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#lifetimes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#generics"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#types"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#namespaces"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#functions"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#numbers"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#operators"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#punctuation"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"comments": {
|
||||||
|
"match": "//.*",
|
||||||
|
"name": "comment.line.double-slash.mist"
|
||||||
|
},
|
||||||
|
"attributes": {
|
||||||
|
"begin": "#!?\\[",
|
||||||
|
"beginCaptures": {
|
||||||
|
"0": {
|
||||||
|
"name": "punctuation.definition.attribute.begin.mist"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"end": "\\]",
|
||||||
|
"endCaptures": {
|
||||||
|
"0": {
|
||||||
|
"name": "punctuation.definition.attribute.end.mist"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "meta.attribute.mist",
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "$self"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"strings": {
|
||||||
|
"begin": "\"",
|
||||||
|
"beginCaptures": {
|
||||||
|
"0": {
|
||||||
|
"name": "punctuation.definition.string.begin.mist"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"end": "\"",
|
||||||
|
"endCaptures": {
|
||||||
|
"0": {
|
||||||
|
"name": "punctuation.definition.string.end.mist"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "string.quoted.double.mist",
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"match": "\\\\.",
|
||||||
|
"name": "constant.character.escape.mist"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"macros": {
|
||||||
|
"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)(!)",
|
||||||
|
"captures": {
|
||||||
|
"1": {
|
||||||
|
"name": "entity.name.function.macro.mist"
|
||||||
|
},
|
||||||
|
"2": {
|
||||||
|
"name": "keyword.operator.macro.mist"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type_declarations": {
|
||||||
|
"match": "\\b(struct|enum|class|trait)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
|
||||||
|
"captures": {
|
||||||
|
"1": {
|
||||||
|
"name": "storage.type.mist"
|
||||||
|
},
|
||||||
|
"2": {
|
||||||
|
"name": "entity.name.type.mist"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"keywords": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"match": "\\b(if|else|while|for|in|return|break|continue|match)\\b",
|
||||||
|
"name": "keyword.control.mist"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": "\\b(struct|enum|class|trait|var)\\b",
|
||||||
|
"name": "storage.type.mist"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": "\\b(pub|mut|constructor)\\b",
|
||||||
|
"name": "storage.modifier.mist"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": "\\b(impl|use|mod|new|void|self)\\b",
|
||||||
|
"name": "keyword.other.mist"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"constants": {
|
||||||
|
"match": "\\b(true|false)\\b",
|
||||||
|
"name": "constant.language.boolean.mist"
|
||||||
|
},
|
||||||
|
"lifetimes": {
|
||||||
|
"match": "'[a-zA-Z_][a-zA-Z0-9_]*\\b",
|
||||||
|
"name": "storage.modifier.lifetime.mist"
|
||||||
|
},
|
||||||
|
"generics": {
|
||||||
|
"begin": "<",
|
||||||
|
"beginCaptures": {
|
||||||
|
"0": {
|
||||||
|
"name": "punctuation.brackets.angle.mist"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"end": ">",
|
||||||
|
"endCaptures": {
|
||||||
|
"0": {
|
||||||
|
"name": "punctuation.brackets.angle.mist"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#lifetimes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": "\\b[a-zA-Z_][a-zA-Z0-9_]*\\b",
|
||||||
|
"name": "entity.name.type.mist"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": ",",
|
||||||
|
"name": "punctuation.separator.mist"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": ":|\\+",
|
||||||
|
"name": "keyword.operator.mist"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#generics"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"types": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"match": "(?<![A-Za-z])(f32|f64|i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)\\b",
|
||||||
|
"name": "entity.name.type.numeric.mist"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": "(?<![A-Za-z])(str|char|bool)\\b",
|
||||||
|
"name": "entity.name.type.other.mist"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": "\\b_?[A-Z][A-Za-z0-9_]*\\b(?!!)",
|
||||||
|
"name": "entity.name.type.mist"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"namespaces": {
|
||||||
|
"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)(?=\\s*::)",
|
||||||
|
"captures": {
|
||||||
|
"1": {
|
||||||
|
"name": "entity.name.namespace.mist"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"functions": {
|
||||||
|
"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\s*(?=\\()",
|
||||||
|
"name": "entity.name.function.mist"
|
||||||
|
},
|
||||||
|
"numbers": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"match": "\\b\\d+\\.\\d+\\b",
|
||||||
|
"name": "constant.numeric.float.mist"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": "\\b\\d+\\b",
|
||||||
|
"name": "constant.numeric.integer.mist"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"operators": {
|
||||||
|
"match": "(<=|>=|==|!=|&&|\\|\\||\\+|-|\\*|/|%|<|>|=|=>|!)",
|
||||||
|
"name": "keyword.operator.mist"
|
||||||
|
},
|
||||||
|
"punctuation": {
|
||||||
|
"match": "::|:|;|,|\\.|\\{|\\}|\\(|\\)|\\[|\\]",
|
||||||
|
"name": "punctuation.mist"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
-1
@@ -5,6 +5,7 @@ import {
|
|||||||
} from "fumadocs-mdx/config";
|
} from "fumadocs-mdx/config";
|
||||||
import { metaSchema, pageSchema } from "fumadocs-core/source/schema";
|
import { metaSchema, pageSchema } from "fumadocs-core/source/schema";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
import mist from "./public/mist.tmLanguage.json";
|
||||||
|
|
||||||
// You can customize Zod schemas for frontmatter and `meta.json` here
|
// You can customize Zod schemas for frontmatter and `meta.json` here
|
||||||
// see https://fumadocs.dev/docs/mdx/collections
|
// see https://fumadocs.dev/docs/mdx/collections
|
||||||
@@ -33,6 +34,12 @@ export const blogPosts = defineCollections({
|
|||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
mdxOptions: {
|
mdxOptions: {
|
||||||
// MDX options
|
rehypeCodeOptions: {
|
||||||
|
langs: [mist],
|
||||||
|
themes: {
|
||||||
|
light: "github-light",
|
||||||
|
dark: "github-dark",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user