提交 15b6d56c 编写于 作者: M Martin Aeschlimann

[rust] update rust grammar (Feb 14, 2016)

上级 9f8ee47b
......@@ -63,7 +63,8 @@
"raw_string_literal": {
"comment": "Raw double-quote string literal",
"name": "string.quoted.double.raw.rust",
"match": "b?r(#*)\".*?\"(\\1)"
"begin": "b?r(#*)\"",
"end": "\"\\1"
},
"sigils": {
"comment": "Sigil",
......@@ -85,6 +86,16 @@
"name": "storage.modifier.box.rust",
"match": "\\bbox\\b"
},
"const": {
"comment": "Const storage modifier",
"name": "storage.modifier.const.rust",
"match": "\\bconst\\b"
},
"pub": {
"comment": "Visibility modifier",
"name": "storage.modifier.visibility.rust",
"match": "\\bpub\\b"
},
"lifetime": {
"comment": "Named lifetime",
"name": "storage.modifier.lifetime.rust",
......@@ -107,40 +118,40 @@
}
}
},
"types": {
"comment": "Built-in type",
"name": "storage.type.rust",
"match": "\\b(bool|char|usize|isize|u8|u16|u32|u64|i8|i16|i32|i64|f32|f64|str|Self)\\b"
"core_types": {
"comment": "Built-in/core type",
"name": "storage.type.core.rust",
"match": "\\b(bool|char|usize|isize|u8|u16|u32|u64|i8|i16|i32|i64|f32|f64|str|Self|Option|Result)\\b"
},
"core_vars": {
"comment": "Core type variant",
"name": "support.constant.core.rust",
"match": "\\b(Some|None|Ok|Err)\\b"
},
"marker": {
"core_marker": {
"comment": "Core trait (marker)",
"name": "support.type.marker.rust",
"match": "\\b(Copy|Send|Sized|Sync)\\b"
},
"ops": {
"comment": "Core trait (op)",
"name": "support.type.ops.rust",
"match": "\\b(Drop|Fn|FnMut|FnOnce)\\b"
"core_traits": {
"comment": "Core trait",
"name": "support.type.core.rust",
"match": "\\b(Drop|Fn|FnMut|FnOnce|Clone|PartialEq|PartialOrd|Eq|Ord|AsRef|AsMut|Into|From|Default|Iterator|Extend|IntoIterator|DoubleEndedIterator|ExactSizeIterator)\\b"
},
"std_types": {
"comment": "Standard library type",
"name": "storage.class.std.rust",
"match": "\\b(Box|Option|Path|PathBuf|Result|String|Vec)\\b"
},
"std_vars": {
"comment": "Standard library type variant",
"name": "support.constant.std.rust",
"match": "\\b(Some|None|Ok|Err)\\b"
"match": "\\b(Box|String|Vec|Path|PathBuf)\\b"
},
"std_traits": {
"comment": "Standard library trait",
"name": "support.type.std.rust",
"match": "\\b(Clone|PartialEq|PartialOrd|Eq|Ord|Read|Write|Seek|BufRead|DoubleEndedIterator|ExactSizeIterator|Iterator|Extend|AsPath|AsSlice|Str|ToString)\\b"
"match": "\\b(ToOwned|ToString)\\b"
},
"type_params": {
"comment": "Type parameters",
"name": "meta.type_params.rust",
"begin": "<",
"begin": "<(?![=<])",
"end": ">",
"patterns": [
{
......@@ -159,13 +170,16 @@
"include": "#lifetime"
},
{
"include": "#types"
"include": "#core_types"
},
{
"include": "#core_marker"
},
{
"include": "#marker"
"include": "#core_traits"
},
{
"include": "#ops"
"include": "#std_types"
},
{
"include": "#std_traits"
......@@ -214,17 +228,17 @@
{
"comment": "Floating point literal (fraction)",
"name": "constant.numeric.float.rust",
"match": "\\b[0-9][0-9_]*\\.[0-9][0-9_]*([eE][+-][0-9_]+)?(f32|f64)?\\b"
"match": "\\b[0-9][0-9_]*\\.[0-9][0-9_]*([eE][+-]?[0-9_]+)?(f32|f64)?\\b"
},
{
"comment": "Floating point literal (exponent)",
"name": "constant.numeric.float.rust",
"match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?[eE][+-][0-9_]+(f32|f64)?\\b"
"match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?[eE][+-]?[0-9_]+(f32|f64)?\\b"
},
{
"comment": "Floating point literal (typed)",
"name": "constant.numeric.float.rust",
"match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?([eE][+-][0-9_]+)?(f32|f64)\\b"
"match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?([eE][+-]?[0-9_]+)?(f32|f64)\\b"
},
{
"comment": "Integer literal (decimal)",
......@@ -251,16 +265,6 @@
"name": "storage.modifier.static.rust",
"match": "\\bstatic\\b"
},
{
"comment": "Const storage modifier",
"name": "storage.modifier.const.rust",
"match": "\\bconst\\b"
},
{
"comment": "Visibility modifier",
"name": "storage.modifier.visibility.rust",
"match": "\\bpub\\b"
},
{
"comment": "Boolean constant",
"name": "constant.language.boolean.rust",
......@@ -300,24 +304,50 @@
"include": "#ref_lifetime"
},
{
"comment": "Operator",
"name": "keyword.operator.rust",
"match": "(\\+|-|/|\\*|=|\\^|&|\\||!|>|<|%|::|\\bas\\b)"
"include": "#const"
},
{
"include": "#types"
"include": "#pub"
},
{
"include": "#marker"
"comment": "Miscellaneous operator",
"name": "keyword.operator.misc.rust",
"match": "(=>|::|\\bas\\b)"
},
{
"include": "#ops"
"comment": "Comparison operator",
"name": "keyword.operator.comparison.rust",
"match": "(&&|\\|\\||==|!=)"
},
{
"include": "#std_types"
"comment": "Assignment operator",
"name": "keyword.operator.assignment.rust",
"match": "(\\+=|-=|/=|\\*=|%=|\\^=|&=|\\|=|<<=|>>=|=)"
},
{
"comment": "Arithmetic operator",
"name": "keyword.operator.arithmetic.rust",
"match": "(!|\\+|-|/|\\*|%|\\^|&|\\||<<|>>)"
},
{
"include": "#std_vars"
"comment": "Comparison operator (second group because of regex precedence)",
"name": "keyword.operator.comparison.rust",
"match": "(<=|>=|<|>)"
},
{
"include": "#core_types"
},
{
"include": "#core_vars"
},
{
"include": "#core_marker"
},
{
"include": "#core_traits"
},
{
"include": "#std_types"
},
{
"include": "#std_traits"
......@@ -373,17 +403,50 @@
}
},
"patterns": [
{
"include": "#block_comment"
},
{
"include": "#line_comment"
},
{
"include": "#sigils"
},
{
"include": "#self"
},
{
"include": "#mut"
},
{
"include": "#ref_lifetime"
},
{
"include": "#core_types"
},
{
"include": "#core_marker"
},
{
"include": "#core_traits"
},
{
"include": "#std_types"
},
{
"include": "#std_traits"
},
{
"include": "#type_params"
},
{
"include": "$self"
"include": "#const"
}
]
},
{
"comment": "Type declaration",
"begin": "\\b(enum|struct|trait|type)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
"begin": "\\b(enum|struct|trait)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
"end": "[\\{;]",
"beginCaptures": {
"1": {
......@@ -394,42 +457,123 @@
}
},
"patterns": [
{
"include": "#block_comment"
},
{
"include": "#line_comment"
},
{
"include": "#core_traits"
},
{
"include": "#std_traits"
},
{
"include": "#type_params"
},
{
"include": "$self"
"include": "#core_types"
},
{
"include": "#pub"
}
]
},
{
"comment": "Implementation",
"begin": "\\b(impl)\\b",
"end": "\\{",
"comment": "Type alias",
"begin": "\\b(type)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
"end": ";",
"beginCaptures": {
"1": {
"name": "storage.type.rust"
},
"2": {
"name": "entity.name.type.rust"
}
},
"patterns": [
{
"include": "#type_params"
"include": "#block_comment"
},
{
"include": "#line_comment"
},
{
"include": "$self"
"include": "#sigils"
},
{
"include": "#mut"
},
{
"include": "#ref_lifetime"
},
{
"include": "#core_types"
},
{
"include": "#core_marker"
},
{
"include": "#core_traits"
},
{
"include": "#std_types"
},
{
"include": "#std_traits"
},
{
"include": "#type_params"
}
]
},
{
"comment": "Variable declaration",
"begin": ":",
"end": "[=;,\\)\\|]",
"comment": "Implementation",
"begin": "\\b(impl)\\b",
"end": "\\{",
"beginCaptures": {
"1": {
"name": "storage.type.rust"
}
},
"patterns": [
{
"include": "#block_comment"
},
{
"include": "#line_comment"
},
{
"include": "#sigils"
},
{
"include": "#mut"
},
{
"include": "#ref_lifetime"
},
{
"include": "#core_types"
},
{
"include": "#core_marker"
},
{
"include": "#core_traits"
},
{
"include": "#std_types"
},
{
"include": "#std_traits"
},
{
"include": "#type_params"
},
{
"include": "$self"
"name": "storage.type.rust",
"match": "\\bfor\\b"
}
]
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册