Clean up grammar by a lot
This commit is contained in:
parent
fa95da97ae
commit
8d8d6ac336
@ -1,56 +1,11 @@
|
||||
{
|
||||
"scopeName": "source.reid",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#import"
|
||||
},
|
||||
{
|
||||
"include": "#expression"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"import": {
|
||||
"begin": "(import)\\s*",
|
||||
"end": ";",
|
||||
"beginCaptures": {
|
||||
"1": {
|
||||
"name": "keyword"
|
||||
}
|
||||
},
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.semi.reid"
|
||||
}
|
||||
},
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#identifier"
|
||||
},
|
||||
{
|
||||
"include": "#punctiation"
|
||||
}
|
||||
]
|
||||
},
|
||||
"punctuation": {
|
||||
"patterns": [
|
||||
{
|
||||
"match": "::",
|
||||
"name": "keyword.operator.namespace.reid"
|
||||
},
|
||||
{
|
||||
"match": ";",
|
||||
"name": "punctuation.semi.reid"
|
||||
},
|
||||
{
|
||||
"match": ".",
|
||||
"name": "punctuation.dot.reid"
|
||||
},
|
||||
{
|
||||
"match": ",",
|
||||
"name": "punctuation.comma.reid"
|
||||
}
|
||||
]
|
||||
},
|
||||
"expression": {
|
||||
"patterns": [
|
||||
{
|
||||
@ -59,27 +14,18 @@
|
||||
{
|
||||
"include": "#fn-signature"
|
||||
},
|
||||
{
|
||||
"include": "#namespace"
|
||||
},
|
||||
{
|
||||
"include": "#common-type"
|
||||
},
|
||||
{
|
||||
"include": "#binop-impl"
|
||||
},
|
||||
{
|
||||
"include": "#type-impl"
|
||||
},
|
||||
{
|
||||
"include": "#struct-definition"
|
||||
},
|
||||
{
|
||||
"include": "#block"
|
||||
},
|
||||
{
|
||||
"include": "#binop"
|
||||
},
|
||||
{
|
||||
"include": "#namespace"
|
||||
},
|
||||
{
|
||||
"include": "#cast"
|
||||
},
|
||||
@ -95,9 +41,6 @@
|
||||
{
|
||||
"include": "#keywords"
|
||||
},
|
||||
{
|
||||
"include": "#struct-expression"
|
||||
},
|
||||
{
|
||||
"include": "#number-literal"
|
||||
},
|
||||
@ -112,93 +55,44 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"punctuation": {
|
||||
"patterns": [
|
||||
{
|
||||
"match": "::",
|
||||
"name": "keyword.operator.namespace.reid"
|
||||
},
|
||||
{
|
||||
"match": ":",
|
||||
"name": "keyword.operator.colon.reid"
|
||||
},
|
||||
{
|
||||
"match": ";",
|
||||
"name": "punctuation.semi.reid"
|
||||
},
|
||||
{
|
||||
"match": ".",
|
||||
"name": "punctuation.dot.reid"
|
||||
},
|
||||
{
|
||||
"match": ",",
|
||||
"name": "punctuation.comma.reid"
|
||||
},
|
||||
{
|
||||
"match": "\\{|\\}",
|
||||
"name": "punctuation.brackets.curly.reid"
|
||||
},
|
||||
{
|
||||
"match": "\\(|\\)",
|
||||
"name": "punctuation.parenthesis.reid"
|
||||
}
|
||||
]
|
||||
},
|
||||
"comment": {
|
||||
"match": "\\/\\/(.|\\/)*",
|
||||
"name": "comment.line.double-slash.reid"
|
||||
},
|
||||
"fn-signature": {
|
||||
"begin": "(fn)\\s*(\\w+)\\(",
|
||||
"beginCaptures": {
|
||||
"1": {
|
||||
"name": "keyword.fn.reid"
|
||||
},
|
||||
"2": {
|
||||
"name": "entity.name.function.reid"
|
||||
}
|
||||
},
|
||||
"end": "\\)",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#annotated-identifier"
|
||||
},
|
||||
{
|
||||
"include": "#keywords"
|
||||
},
|
||||
{
|
||||
"include": "#binop"
|
||||
}
|
||||
],
|
||||
"endCaptures": {
|
||||
"2": {
|
||||
"name": "entity.name.type.reid"
|
||||
}
|
||||
}
|
||||
},
|
||||
"type-impl": {
|
||||
"begin": "(impl)\\s* (\\w+)\\s* \\{\n",
|
||||
"end": "\\}",
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "keyword.impl.reid"
|
||||
},
|
||||
"2": {
|
||||
"name": "entity.name.type"
|
||||
}
|
||||
},
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#expression"
|
||||
}
|
||||
]
|
||||
},
|
||||
"binop-impl": {
|
||||
"begin": "(impl)\\s+(binop)\\s+\\(((.*)\\s*:\\s*(.*))\\)(.*)\\(((.*)\\s*:\\s*(.*))\\)\\s*->\\s*(\\w+)\\s*\\{",
|
||||
"end": "\\}",
|
||||
"beginCaptures": {
|
||||
"1": {
|
||||
"name": "keyword.impl.reid"
|
||||
},
|
||||
"2": {
|
||||
"name": "keyword.impl.reid"
|
||||
},
|
||||
"4": {
|
||||
"name": "variable.parameter.binop.reid"
|
||||
},
|
||||
"5": {
|
||||
"name": "entity.name.type.parameter.binop.reid"
|
||||
},
|
||||
"6": {
|
||||
"name": "keyword.operator.math.reid"
|
||||
},
|
||||
"8": {
|
||||
"name": "variable.parameter.binop.reid"
|
||||
},
|
||||
"9": {
|
||||
"name": "entity.name.type.parameter.binop.reid"
|
||||
},
|
||||
"10": {
|
||||
"name": "entity.name.type.return.binop.reid"
|
||||
}
|
||||
},
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#expression"
|
||||
}
|
||||
]
|
||||
},
|
||||
"struct-definition": {
|
||||
"begin": "(struct)\\s*(\\w+)\\s*\\{",
|
||||
"end": "\\}",
|
||||
"match": "(struct)\\s*(\\w+)",
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "keyword.struct.reid"
|
||||
@ -206,15 +100,10 @@
|
||||
"2": {
|
||||
"name": "entity.name.type"
|
||||
}
|
||||
},
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#annotated-identifier"
|
||||
}
|
||||
]
|
||||
},
|
||||
"struct-expression": {
|
||||
"begin": "([A-Z]\\w*)\\s*\\{",
|
||||
"begin": "\\b([A-Z]\\w*)\\s*\\{",
|
||||
"end": "\\}",
|
||||
"captures": {
|
||||
"1": {
|
||||
@ -230,19 +119,19 @@
|
||||
"number-literal": {
|
||||
"patterns": [
|
||||
{
|
||||
"match": "0x[0-9a-fA-F]+(\\.[0-9a-fA-F]+)?",
|
||||
"match": "\\b0x[0-9a-fA-F]+(\\.[0-9a-fA-F]+)?\\b",
|
||||
"name": "constant.hexadecimal"
|
||||
},
|
||||
{
|
||||
"match": "0o[0-7]+(\\.[0-7]+)?",
|
||||
"match": "\\b0o[0-7]+(\\.[0-7]+)?\\b",
|
||||
"name": "constant.octal"
|
||||
},
|
||||
{
|
||||
"match": "0b[01]+(\\.[01]+)?",
|
||||
"match": "\\b0b[01]+(\\.[01]+)?\\b",
|
||||
"name": "constant.binary"
|
||||
},
|
||||
{
|
||||
"match": "[0-9]+(\\.[0-9]+)?",
|
||||
"match": "\\b[0-9]+(\\.[0-9]+)?\\b",
|
||||
"name": "constant.numeric"
|
||||
}
|
||||
]
|
||||
@ -253,25 +142,16 @@
|
||||
"name": "string.quoted.double",
|
||||
"patterns": [
|
||||
{
|
||||
"match": "\\.",
|
||||
"match": "\\\\\\w",
|
||||
"name": "constant.character.escape"
|
||||
}
|
||||
]
|
||||
},
|
||||
"block": {
|
||||
"begin": "\\{",
|
||||
"end": "\\}",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#expression"
|
||||
}
|
||||
]
|
||||
},
|
||||
"namespace": {
|
||||
"match": "(\\w+)(\\:\\:)",
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "entity.name.function.reid"
|
||||
"name": "entity.name.namespace.reid"
|
||||
},
|
||||
"2": {
|
||||
"name": "keyword.operator.namespace.reid"
|
||||
@ -290,11 +170,19 @@
|
||||
}
|
||||
},
|
||||
"function-call": {
|
||||
"begin": "(\\w+)?\\(",
|
||||
"end": "\\)",
|
||||
"begin": "(\\w+)?(\\()",
|
||||
"end": "(\\))",
|
||||
"beginCaptures": {
|
||||
"1": {
|
||||
"name": "entity.name.function.reid"
|
||||
},
|
||||
"2": {
|
||||
"name": "punctuation.parenthesis.reid"
|
||||
}
|
||||
},
|
||||
"endCaptures": {
|
||||
"1": {
|
||||
"name": "punctuation.parenthesis.reid"
|
||||
}
|
||||
},
|
||||
"patterns": [
|
||||
@ -322,28 +210,10 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"annotated-identifier": {
|
||||
"begin": "(\\w+)\\:",
|
||||
"end": ",",
|
||||
"beginCaptures": {
|
||||
"1": {
|
||||
"name": "variable.language.reid"
|
||||
}
|
||||
},
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#expression"
|
||||
}
|
||||
]
|
||||
},
|
||||
"identifier": {
|
||||
"patterns": [
|
||||
{
|
||||
"match": "[A-Z]\\w*",
|
||||
"name": "entity.name.type.reid"
|
||||
},
|
||||
{
|
||||
"match": "\\w+",
|
||||
"match": "\\b(?:\\w+)\\b",
|
||||
"name": "variable.language.reid"
|
||||
}
|
||||
]
|
||||
@ -351,16 +221,32 @@
|
||||
"keywords": {
|
||||
"patterns": [
|
||||
{
|
||||
"match": "let|mut|pub|extern",
|
||||
"match": "\\b(?:let|mut|pub|extern)\\b",
|
||||
"name": "storage.type.reid"
|
||||
},
|
||||
{
|
||||
"match": "if|return",
|
||||
"match": "\\bimport\\b",
|
||||
"name": "keyword.import.reid"
|
||||
},
|
||||
{
|
||||
"match": "\\bbinop\\b",
|
||||
"name": "keyword.binop.reid"
|
||||
},
|
||||
{
|
||||
"match": "\\bimpl\\b",
|
||||
"name": "keyword.impl.reid"
|
||||
},
|
||||
{
|
||||
"match": "\\b(?:if|return|for|in)\\b",
|
||||
"name": "keyword.control"
|
||||
},
|
||||
{
|
||||
"match": "self",
|
||||
"match": "\\bself\\b",
|
||||
"name": "variable.language.self.reid"
|
||||
},
|
||||
{
|
||||
"match": "\\bfn\\b",
|
||||
"name": "keyword.fn.reid"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -388,7 +274,7 @@
|
||||
]
|
||||
},
|
||||
"common-type": {
|
||||
"match": "u8|u16|u32|u64|u128|i8|i16|i32|i64|i128|bool",
|
||||
"match": "\\b(?:u8|u16|u32|u64|u128|i8|i16|i32|i64|i128|f16|f16b|f32|f64|f80|f128|f128ppc|bool|char|([A-Z]\\w*))\\b",
|
||||
"name": "entity.name.type.common.reid"
|
||||
}
|
||||
}
|
||||
|
@ -1,133 +1,52 @@
|
||||
scopeName: source.reid
|
||||
patterns:
|
||||
- include: "#import"
|
||||
- include: "#expression"
|
||||
repository:
|
||||
# function-definition:
|
||||
# begin: "(fn)\\s*(\\w+)\\(((\\w+)\\s*\\:\\s*(\\w+),?)*\\)\\s*->\\s*(\\w+)\\s*\\{"
|
||||
# end: "\\}"
|
||||
# beginCaptures:
|
||||
# 1:
|
||||
# name: "keyword.other"
|
||||
# 2:
|
||||
# name: "entity.name.function"
|
||||
# 4:
|
||||
# name: "entity.name.parameter"
|
||||
# 5:
|
||||
# name: "entity.name.type"
|
||||
# 6:
|
||||
# name: "entity.name.type"
|
||||
# patterns:
|
||||
# - include: "#type"
|
||||
# - include: "#expression"
|
||||
import:
|
||||
begin: "(import)\\s*"
|
||||
end: ";"
|
||||
beginCaptures:
|
||||
1:
|
||||
name: keyword
|
||||
endCaptures:
|
||||
0:
|
||||
name: punctuation.semi.reid
|
||||
expression:
|
||||
patterns:
|
||||
- include: "#comment"
|
||||
- include: "#fn-signature"
|
||||
- include: "#namespace"
|
||||
- include: "#common-type"
|
||||
- include: "#struct-definition"
|
||||
- include: "#binop"
|
||||
- include: "#cast"
|
||||
- include: "#function-call"
|
||||
- include: "#parenthesis"
|
||||
- include: "#array"
|
||||
- include: "#keywords"
|
||||
- include: "#number-literal"
|
||||
- include: "#string-literal"
|
||||
- include: "#identifier"
|
||||
- include: "#punctiation"
|
||||
- include: "#punctuation"
|
||||
punctuation:
|
||||
patterns:
|
||||
- match: "::"
|
||||
name: keyword.operator.namespace.reid
|
||||
- match: ":"
|
||||
name: keyword.operator.colon.reid
|
||||
- match: ";"
|
||||
name: punctuation.semi.reid
|
||||
- match: "."
|
||||
name: punctuation.dot.reid
|
||||
- match: ","
|
||||
name: punctuation.comma.reid
|
||||
expression:
|
||||
patterns:
|
||||
- include: "#comment"
|
||||
- include: "#fn-signature"
|
||||
- include: "#common-type"
|
||||
- include: "#binop-impl"
|
||||
- include: "#type-impl"
|
||||
- include: "#struct-definition"
|
||||
- include: "#block"
|
||||
- include: "#binop"
|
||||
- include: "#namespace"
|
||||
- include: "#cast"
|
||||
- include: "#function-call"
|
||||
- include: "#parenthesis"
|
||||
- include: "#array"
|
||||
- include: "#keywords"
|
||||
- include: "#struct-expression"
|
||||
- include: "#number-literal"
|
||||
- include: "#string-literal"
|
||||
- include: "#identifier"
|
||||
- include: "#punctuation"
|
||||
- match: "\\{|\\}"
|
||||
name: punctuation.brackets.curly.reid
|
||||
- match: "\\(|\\)"
|
||||
name: punctuation.parenthesis.reid
|
||||
comment:
|
||||
match: "\\/\\/(.|\\/)*"
|
||||
name: comment.line.double-slash.reid
|
||||
fn-signature:
|
||||
begin: "(fn)\\s*(\\w+)\\("
|
||||
beginCaptures:
|
||||
1:
|
||||
name: keyword.fn.reid
|
||||
2:
|
||||
name: entity.name.function.reid
|
||||
end: "\\)"
|
||||
patterns:
|
||||
- include: "#annotated-identifier"
|
||||
- include: "#keywords"
|
||||
- include: "#binop"
|
||||
endCaptures:
|
||||
2:
|
||||
name: entity.name.type.reid
|
||||
type-impl:
|
||||
begin: >
|
||||
(impl)\s*
|
||||
(\w+)\s*
|
||||
\{
|
||||
end: "\\}"
|
||||
captures:
|
||||
1:
|
||||
name: keyword.impl.reid
|
||||
2:
|
||||
name: entity.name.type
|
||||
patterns:
|
||||
- include: "#expression"
|
||||
binop-impl:
|
||||
begin: "(impl)\\s+(binop)\\s+\\(((.*)\\s*:\\s*(.*))\\)(.*)\\(((.*)\\s*:\\s*(.*))\\)\\s*->\\s*(\\w+)\\s*\\{"
|
||||
end: "\\}"
|
||||
beginCaptures:
|
||||
1:
|
||||
name: keyword.impl.reid
|
||||
2:
|
||||
name: keyword.impl.reid
|
||||
4:
|
||||
name: variable.parameter.binop.reid
|
||||
5:
|
||||
name: entity.name.type.parameter.binop.reid
|
||||
6:
|
||||
name: keyword.operator.math.reid
|
||||
8:
|
||||
name: variable.parameter.binop.reid
|
||||
9:
|
||||
name: entity.name.type.parameter.binop.reid
|
||||
10:
|
||||
name: entity.name.type.return.binop.reid
|
||||
patterns:
|
||||
- include: "#expression"
|
||||
struct-definition:
|
||||
begin: "(struct)\\s*(\\w+)\\s*\\{"
|
||||
end: "\\}"
|
||||
match: "(struct)\\s*(\\w+)"
|
||||
captures:
|
||||
1:
|
||||
name: keyword.struct.reid
|
||||
2:
|
||||
name: entity.name.type
|
||||
patterns:
|
||||
- include: "#annotated-identifier"
|
||||
struct-expression:
|
||||
begin: "([A-Z]\\w*)\\s*\\{"
|
||||
begin: "\\b([A-Z]\\w*)\\s*\\{"
|
||||
end: "\\}"
|
||||
captures:
|
||||
1:
|
||||
@ -136,31 +55,26 @@ repository:
|
||||
- include: "#expression"
|
||||
number-literal:
|
||||
patterns:
|
||||
- match: "0x[0-9a-fA-F]+(\\.[0-9a-fA-F]+)?"
|
||||
- match: "\\b0x[0-9a-fA-F]+(\\.[0-9a-fA-F]+)?\\b"
|
||||
name: "constant.hexadecimal"
|
||||
- match: "0o[0-7]+(\\.[0-7]+)?"
|
||||
- match: "\\b0o[0-7]+(\\.[0-7]+)?\\b"
|
||||
name: "constant.octal"
|
||||
- match: "0b[01]+(\\.[01]+)?"
|
||||
- match: "\\b0b[01]+(\\.[01]+)?\\b"
|
||||
name: "constant.binary"
|
||||
- match: "[0-9]+(\\.[0-9]+)?"
|
||||
- match: "\\b[0-9]+(\\.[0-9]+)?\\b"
|
||||
name: "constant.numeric"
|
||||
string-literal:
|
||||
begin: '"'
|
||||
end: '"'
|
||||
name: string.quoted.double
|
||||
patterns:
|
||||
- match: "\\."
|
||||
- match: "\\\\\\w"
|
||||
name: constant.character.escape
|
||||
block:
|
||||
begin: "\\{"
|
||||
end: "\\}"
|
||||
patterns:
|
||||
- include: "#expression"
|
||||
namespace:
|
||||
match: "(\\w+)(\\:\\:)"
|
||||
captures:
|
||||
1:
|
||||
name: entity.name.function.reid
|
||||
name: entity.name.namespace.reid
|
||||
2:
|
||||
name: keyword.operator.namespace.reid
|
||||
cast:
|
||||
@ -171,11 +85,16 @@ repository:
|
||||
2:
|
||||
name: entity.name.type.reid
|
||||
function-call:
|
||||
begin: "(\\w+)?\\("
|
||||
end: "\\)"
|
||||
begin: "(\\w+)?(\\()"
|
||||
end: "(\\))"
|
||||
beginCaptures:
|
||||
1:
|
||||
name: entity.name.function.reid
|
||||
2:
|
||||
name: punctuation.parenthesis.reid
|
||||
endCaptures:
|
||||
1:
|
||||
name: punctuation.parenthesis.reid
|
||||
patterns:
|
||||
- include: "#expression"
|
||||
parenthesis:
|
||||
@ -189,28 +108,26 @@ repository:
|
||||
name: keyword.operator.parenthesis.reid
|
||||
patterns:
|
||||
- include: "#expression"
|
||||
annotated-identifier:
|
||||
begin: "(\\w+)\\:"
|
||||
end: ","
|
||||
beginCaptures:
|
||||
1:
|
||||
name: variable.language.reid
|
||||
patterns:
|
||||
- include: "#expression"
|
||||
identifier:
|
||||
patterns:
|
||||
- match: "[A-Z]\\w*"
|
||||
name: entity.name.type.reid
|
||||
- match: "\\w+"
|
||||
- match: "\\b(?:\\w+)\\b"
|
||||
name: variable.language.reid
|
||||
keywords:
|
||||
patterns:
|
||||
- match: "let|mut|pub|extern"
|
||||
name: "storage.type.reid"
|
||||
- match: "if|return"
|
||||
name: "keyword.control"
|
||||
- match: "self"
|
||||
name: "variable.language.self.reid"
|
||||
- match: "\\b(?:let|mut|pub|extern)\\b"
|
||||
name: storage.type.reid
|
||||
- match: "\\bimport\\b"
|
||||
name: keyword.import.reid
|
||||
- match: "\\bbinop\\b"
|
||||
name: keyword.binop.reid
|
||||
- match: "\\bimpl\\b"
|
||||
name: keyword.impl.reid
|
||||
- match: "\\b(?:if|return|for|in)\\b"
|
||||
name: keyword.control
|
||||
- match: "\\bself\\b"
|
||||
name: variable.language.self.reid
|
||||
- match: "\\bfn\\b"
|
||||
name: keyword.fn.reid
|
||||
binop:
|
||||
match: "\\<\\=|\\>\\=|\\=\\=|\\<|\\>|\\*|\\+|\\-|\\^|\\&\\&|\\&"
|
||||
name: keyword.operator.math.reid
|
||||
@ -226,7 +143,7 @@ repository:
|
||||
patterns:
|
||||
- include: "#expression"
|
||||
common-type:
|
||||
match: "u8|u16|u32|u64|u128|i8|i16|i32|i64|i128|bool"
|
||||
match: "\\b(?:u8|u16|u32|u64|u128|i8|i16|i32|i64|i128|f16|f16b|f32|f64|f80|f128|f128ppc|bool|char|([A-Z]\\w*))\\b"
|
||||
name: entity.name.type.common.reid
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user