Merge commit '06dfec714e2424be9d19aacb739771746f5aec2b'

pull/261/head
Wilfred Hughes 2022-04-17 19:09:58 +07:00
commit a7e298dfa1
16 changed files with 139000 additions and 101065 deletions

@ -7,7 +7,7 @@ Added support for Kotlin and TOML.
Fixed an issue with YAML and `|` block strings. Fixed an issue with YAML and `|` block strings.
Updated to the latest upstream C++, C#, Elixir, Go, Haskell, Java, Updated to the latest upstream C++, C#, Elixir, Go, Haskell, Java,
Python, Ruby and TypeScript parsers. Python, Ruby, Rust and TypeScript parsers.
### Diffing ### Diffing

@ -1,7 +1,7 @@
[package] [package]
name = "tree-sitter-rust" name = "tree-sitter-rust"
description = "Rust grammar for the tree-sitter parsing library" description = "Rust grammar for the tree-sitter parsing library"
version = "0.19.1" version = "0.20.1"
authors = ["Max Brunsfeld <maxbrunsfeld@gmail.com>"] authors = ["Max Brunsfeld <maxbrunsfeld@gmail.com>"]
license = "MIT" license = "MIT"
readme = "bindings/rust/README.md" readme = "bindings/rust/README.md"
@ -23,7 +23,7 @@ autoexamples = false
path = "bindings/rust/lib.rs" path = "bindings/rust/lib.rs"
[dependencies] [dependencies]
tree-sitter = "0.19" tree-sitter = "0.20"
[build-dependencies] [build-dependencies]
cc = "1.0" cc = "1.0"

@ -1,6 +1,6 @@
============================================ ================================================================================
Async function Async function
============================================ ================================================================================
async fn abc() {} async fn abc() {}
@ -8,7 +8,7 @@ async fn main() {
let x = futures.await?; let x = futures.await?;
} }
--- --------------------------------------------------------------------------------
(source_file (source_file
(function_item (function_item
@ -16,56 +16,73 @@ async fn main() {
(identifier) (identifier)
(parameters) (parameters)
(block)) (block))
(function_item (function_modifiers) (identifier) (parameters) (function_item
(function_modifiers)
(identifier)
(parameters)
(block (block
(let_declaration (identifier) (try_expression (let_declaration
(await_expression (identifier))))))) (identifier)
(try_expression
(await_expression
(identifier)))))))
============================================ ================================================================================
Await expression Await expression
============================================ ================================================================================
futures.await; futures.await;
futures.await?; futures.await?;
futures.await?.await?; futures.await?.await?;
futures.await?.function().await?; futures.await?.function().await?;
--- --------------------------------------------------------------------------------
(source_file (source_file
(await_expression (identifier)) (expression_statement
(await_expression
(identifier)))
(expression_statement
(try_expression (try_expression
(await_expression (identifier))) (await_expression
(identifier))))
(expression_statement
(try_expression (try_expression
(await_expression (await_expression
(try_expression (try_expression
(await_expression (identifier))))) (await_expression
(identifier))))))
(expression_statement
(try_expression (try_expression
(await_expression (await_expression
(call_expression (call_expression
(field_expression (field_expression
(try_expression (try_expression
(await_expression (identifier))) (await_expression
(identifier)))
(field_identifier)) (field_identifier))
(arguments))))) (arguments))))))
============================================ ================================================================================
Async Block Async Block
============================================ ================================================================================
async {} async {}
async { let x = 10; } async { let x = 10; }
async move {} async move {}
--- --------------------------------------------------------------------------------
(source_file (source_file
(expression_statement
(async_block (async_block
(block)) (block)))
(expression_statement
(async_block (async_block
(block (block
(let_declaration (let_declaration
(identifier) (identifier)
(integer_literal)))) (integer_literal)))))
(expression_statement
(async_block (async_block
(block))) (block))))

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
============================================ ================================================================================
Integer literals Integer literals
============================================ ================================================================================
0; 0;
0___0; 0___0;
@ -14,24 +14,35 @@ Integer literals
0b1111_1111_1001_0000_i32; 0b1111_1111_1001_0000_i32;
1u128; 1u128;
--- --------------------------------------------------------------------------------
(source_file (source_file
(integer_literal) (expression_statement
(integer_literal)
(integer_literal)
(integer_literal)
(integer_literal)
(integer_literal)
(integer_literal)
(integer_literal)
(integer_literal)
(integer_literal)
(integer_literal)) (integer_literal))
(expression_statement
(integer_literal))
(expression_statement
(integer_literal))
(expression_statement
(integer_literal))
(expression_statement
(integer_literal))
(expression_statement
(integer_literal))
(expression_statement
(integer_literal))
(expression_statement
(integer_literal))
(expression_statement
(integer_literal))
(expression_statement
(integer_literal))
(expression_statement
(integer_literal)))
============================================ ================================================================================
Floating-point literals Floating-point literals
============================================ ================================================================================
123.123; 123.123;
2.; 2.;
@ -40,19 +51,25 @@ Floating-point literals
0.1f32; 0.1f32;
12E+99_f64; 12E+99_f64;
--- --------------------------------------------------------------------------------
(source_file (source_file
(float_literal) (expression_statement
(float_literal) (float_literal))
(float_literal) (expression_statement
(float_literal) (float_literal))
(float_literal) (expression_statement
(float_literal)) (float_literal))
(expression_statement
(float_literal))
(expression_statement
(float_literal))
(expression_statement
(float_literal)))
============================================ ================================================================================
String literals String literals
============================================ ================================================================================
""; "";
"abc"; "abc";
@ -64,52 +81,75 @@ b"foo\nbar";
"foo\x42\x43bar"; "foo\x42\x43bar";
"foo \x42 \x43 bar"; "foo \x42 \x43 bar";
--- --------------------------------------------------------------------------------
(source_file (source_file
(string_literal) (expression_statement
(string_literal) (string_literal))
(string_literal (escape_sequence)) (expression_statement
(string_literal (escape_sequence)) (string_literal))
(string_literal (escape_sequence) (escape_sequence)) (expression_statement
(string_literal) (string_literal
(string_literal (escape_sequence) (escape_sequence)) (escape_sequence)))
(string_literal (escape_sequence) (escape_sequence))) (expression_statement
(string_literal
============================================ (escape_sequence)))
(expression_statement
(string_literal
(escape_sequence)
(escape_sequence)))
(expression_statement
(string_literal))
(expression_statement
(string_literal
(escape_sequence)
(escape_sequence)))
(expression_statement
(string_literal
(escape_sequence)
(escape_sequence))))
================================================================================
Raw string literals Raw string literals
============================================ ================================================================================
r#"abc"#; r##"ok"##; r#"abc"#; r##"ok"##;
r##"foo #"# bar"##; r##"foo #"# bar"##;
r###"foo ##"## bar"###; r###"foo ##"## bar"###;
r######"foo ##### bar"######; r######"foo ##### bar"######;
--- --------------------------------------------------------------------------------
(source_file (source_file
(raw_string_literal) (expression_statement
(raw_string_literal) (raw_string_literal))
(raw_string_literal) (expression_statement
(raw_string_literal)
(raw_string_literal)) (raw_string_literal))
(expression_statement
(raw_string_literal))
(expression_statement
(raw_string_literal))
(expression_statement
(raw_string_literal)))
============================================ ================================================================================
Raw byte string literals Raw byte string literals
============================================ ================================================================================
br#"abc"#; br#"abc"#;
br##"abc"##; br##"abc"##;
--- --------------------------------------------------------------------------------
(source_file (source_file
(raw_string_literal) (expression_statement
(raw_string_literal)) (raw_string_literal))
(expression_statement
(raw_string_literal)))
============================================ ================================================================================
Character literals Character literals
============================================ ================================================================================
'a'; 'a';
'\''; '\'';
@ -119,24 +159,35 @@ b'x';
'\xff'; '\xff';
'\\'; '\\';
--- --------------------------------------------------------------------------------
(source_file (source_file
(char_literal) (expression_statement
(char_literal) (char_literal))
(char_literal) (expression_statement
(char_literal)
(char_literal)
(char_literal)
(char_literal)) (char_literal))
(expression_statement
(char_literal))
(expression_statement
(char_literal))
(expression_statement
(char_literal))
(expression_statement
(char_literal))
(expression_statement
(char_literal)))
============================================ ================================================================================
Boolean literals Boolean literals
============================================ ================================================================================
true; true;
false; false;
--- --------------------------------------------------------------------------------
(source_file (boolean_literal) (boolean_literal)) (source_file
(expression_statement
(boolean_literal))
(expression_statement
(boolean_literal)))

@ -1,6 +1,6 @@
============================================ ================================================================================
Macro invocation - no arguments Macro invocation - no arguments
============================================ ================================================================================
a!(); a!();
b![]; b![];
@ -8,18 +8,39 @@ c!{};
d::e!(); d::e!();
f::g::h!{}; f::g::h!{};
--- --------------------------------------------------------------------------------
(source_file (source_file
(macro_invocation (identifier) (token_tree)) (expression_statement
(macro_invocation (identifier) (token_tree)) (macro_invocation
(macro_invocation (identifier) (token_tree)) (identifier)
(macro_invocation (scoped_identifier (identifier) (identifier)) (token_tree)) (token_tree)))
(macro_invocation (scoped_identifier (scoped_identifier (identifier) (identifier)) (identifier)) (token_tree))) (expression_statement
(macro_invocation
(identifier)
(token_tree)))
(expression_statement
(macro_invocation
(identifier)
(token_tree)))
(expression_statement
(macro_invocation
(scoped_identifier
(identifier)
(identifier))
(token_tree)))
(expression_statement
(macro_invocation
(scoped_identifier
(scoped_identifier
(identifier)
(identifier))
(identifier))
(token_tree))))
============================================ ================================================================================
Macro invocation - arbitrary tokens Macro invocation - arbitrary tokens
============================================ ================================================================================
a!(* a *); a!(* a *);
a!(& a &); a!(& a &);
@ -30,57 +51,129 @@ a!('\u{0}'..='\u{2}');
a!('lifetime) a!('lifetime)
default!(a); default!(a);
union!(a); union!(a);
a!($);
a!($());
a!($ a $);
a!(${$([ a ])});
a!($a $a:ident $($a);*);
---- --------------------------------------------------------------------------------
(source_file (source_file
(expression_statement
(macro_invocation
(identifier)
(token_tree
(non_special_punctuation)
(identifier)
(non_special_punctuation))))
(expression_statement
(macro_invocation
(identifier)
(token_tree
(non_special_punctuation)
(identifier)
(non_special_punctuation))))
(expression_statement
(macro_invocation
(identifier)
(token_tree
(non_special_punctuation)
(identifier)
(non_special_punctuation))))
(expression_statement
(macro_invocation
(identifier)
(token_tree
(identifier)
(non_special_punctuation)
(identifier)
(non_special_punctuation)
(non_special_punctuation))))
(expression_statement
(macro_invocation (macro_invocation
(identifier) (identifier)
(token_tree (identifier))) (token_tree
(char_literal)
(non_special_punctuation)
(char_literal))))
(expression_statement
(macro_invocation (macro_invocation
(identifier) (identifier)
(token_tree (identifier))) (token_tree
(char_literal)
(non_special_punctuation)
(char_literal))))
(macro_invocation (macro_invocation
(identifier) (identifier)
(token_tree (identifier))) (token_tree
(identifier)))
(expression_statement
(macro_invocation (macro_invocation
(identifier) (identifier)
(token_tree (identifier) (identifier))) (token_tree
(identifier))))
(expression_statement
(macro_invocation (macro_invocation
(identifier) (identifier)
(token_tree (char_literal) (char_literal))) (token_tree
(identifier))))
(expression_statement
(macro_invocation (macro_invocation
(identifier) (identifier)
(token_tree (char_literal) (char_literal))) (token_tree)))
(expression_statement
(macro_invocation (macro_invocation
(identifier) (identifier)
(token_tree (identifier))) (token_tree
(token_tree))))
(expression_statement
(macro_invocation (macro_invocation
(identifier) (identifier)
(token_tree (identifier))) (token_tree
(identifier))))
(expression_statement
(macro_invocation (macro_invocation
(identifier) (identifier)
(token_tree (identifier)))) (token_tree
(token_tree
(token_tree
(token_tree
(identifier)))))))
(expression_statement
(macro_invocation
(identifier)
(token_tree
(identifier)
(identifier)
(non_special_punctuation)
(identifier)
(token_tree
(identifier))
(non_special_punctuation)
(non_special_punctuation)))))
===================================== ================================================================================
Macro invocation with comments Macro invocation with comments
===================================== ================================================================================
ok! { ok! {
// one // one
/* two */ /* two */
} }
--- --------------------------------------------------------------------------------
(source_file (source_file
(macro_invocation (macro_invocation
(identifier) (identifier)
(token_tree (line_comment) (block_comment)))) (token_tree
(line_comment)
(block_comment))))
============================================ ================================================================================
Macro definition Macro definition
============================================ ================================================================================
macro_rules! say_hello { macro_rules! say_hello {
() => ( () => (
@ -111,7 +204,7 @@ macro_rules! zero_or_one {
}; };
} }
---- --------------------------------------------------------------------------------
(source_file (source_file
(macro_definition (macro_definition
@ -120,38 +213,47 @@ macro_rules! zero_or_one {
left: (token_tree_pattern) left: (token_tree_pattern)
right: (token_tree right: (token_tree
(identifier) (identifier)
(non_special_punctuation)
(token_tree (token_tree
(string_literal))))) (string_literal))
(non_special_punctuation))))
(macro_definition (macro_definition
name: (identifier) name: (identifier)
(macro_rule (macro_rule
left: (token_tree_pattern) left: (token_tree_pattern)
right: (token_tree right: (token_tree
(integer_literal) (integer_literal)
(non_special_punctuation)
(integer_literal)))) (integer_literal))))
(macro_definition (macro_definition
name: (identifier) name: (identifier)
(macro_rule (macro_rule
left: (token_tree_pattern left: (token_tree_pattern
(identifier) (identifier)
(non_special_punctuation)
(token_binding_pattern (token_binding_pattern
name: (metavariable) name: (metavariable)
type: (fragment_specifier))) type: (fragment_specifier)))
right: (token_tree right: (token_tree
(identifier) (identifier)
(non_special_punctuation)
(token_tree (token_tree
(string_literal) (string_literal)
(non_special_punctuation)
(metavariable)))) (metavariable))))
(macro_rule (macro_rule
left: (token_tree_pattern left: (token_tree_pattern
(identifier) (identifier)
(non_special_punctuation)
(token_binding_pattern (token_binding_pattern
name: (metavariable) name: (metavariable)
type: (fragment_specifier))) type: (fragment_specifier)))
right: (token_tree right: (token_tree
(identifier) (identifier)
(non_special_punctuation)
(token_tree (token_tree
(string_literal) (string_literal)
(non_special_punctuation)
(metavariable))))) (metavariable)))))
(macro_definition (macro_definition
name: (identifier) name: (identifier)
@ -161,6 +263,7 @@ macro_rules! zero_or_one {
(token_binding_pattern (token_binding_pattern
name: (metavariable) name: (metavariable)
type: (fragment_specifier)) type: (fragment_specifier))
(non_special_punctuation)
(token_tree_pattern (token_tree_pattern
(token_repetition_pattern (token_repetition_pattern
(token_binding_pattern (token_binding_pattern
@ -170,6 +273,7 @@ macro_rules! zero_or_one {
(token_repetition (token_repetition
(token_repetition (token_repetition
(metavariable) (metavariable)
(non_special_punctuation)
(metavariable)))))) (metavariable))))))
(macro_definition (macro_definition
name: (identifier) name: (identifier)

@ -1,26 +1,36 @@
================================= ================================================================================
Tuple struct patterns Tuple struct patterns
================================= ================================================================================
match x { match x {
Some(x) => "some", Some(x) => "some",
std::None() => "none" std::None() => "none"
} }
--- --------------------------------------------------------------------------------
(source_file (source_file
(match_expression (identifier) (match_block (expression_statement
(match_expression
(identifier)
(match_block
(match_arm (match_arm
(match_pattern (tuple_struct_pattern (identifier) (identifier))) (match_pattern
(tuple_struct_pattern
(identifier)
(identifier)))
(string_literal)) (string_literal))
(match_arm (match_arm
(match_pattern (tuple_struct_pattern (scoped_identifier (identifier) (identifier)))) (match_pattern
(string_literal))))) (tuple_struct_pattern
(scoped_identifier
(identifier)
(identifier))))
(string_literal))))))
================================= ================================================================================
Reference patterns Reference patterns
================================= ================================================================================
match x { match x {
A(ref x) => x.0, A(ref x) => x.0,
@ -28,51 +38,82 @@ match x {
& mut z => z, & mut z => z,
} }
--- --------------------------------------------------------------------------------
(source_file (source_file
(match_expression (identifier) (match_block (expression_statement
(match_expression
(identifier)
(match_block
(match_arm (match_arm
(match_pattern (tuple_struct_pattern (identifier) (ref_pattern (identifier)))) (match_pattern
(field_expression (identifier) (integer_literal))) (tuple_struct_pattern
(identifier)
(ref_pattern
(identifier))))
(field_expression
(identifier)
(integer_literal)))
(match_arm (match_arm
(match_pattern (ref_pattern (mut_pattern (mutable_specifier) (identifier)))) (match_pattern
(ref_pattern
(mut_pattern
(mutable_specifier)
(identifier))))
(identifier)) (identifier))
(match_arm (match_arm
(match_pattern (reference_pattern (mutable_specifier) (identifier))) (match_pattern
(identifier))))) (reference_pattern
(mutable_specifier)
(identifier)))
(identifier))))))
================================= ================================================================================
Struct patterns Struct patterns
================================= ================================================================================
match x { match x {
Person{name, age} if age < 5 => ("toddler", name), Person{name, age} if age < 5 => ("toddler", name),
Person{name: adult_name, age: _} => ("adult", adult_name), Person{name: adult_name, age: _} => ("adult", adult_name),
} }
--- --------------------------------------------------------------------------------
(source_file (source_file
(match_expression (identifier) (match_block (expression_statement
(match_expression
(identifier)
(match_block
(match_arm (match_arm
(match_pattern (struct_pattern (match_pattern
(struct_pattern
(type_identifier) (type_identifier)
(field_pattern (shorthand_field_identifier)) (field_pattern
(field_pattern (shorthand_field_identifier))) (shorthand_field_identifier))
(binary_expression (identifier) (integer_literal))) (field_pattern
(tuple_expression (string_literal) (identifier))) (shorthand_field_identifier)))
(binary_expression
(identifier)
(integer_literal)))
(tuple_expression
(string_literal)
(identifier)))
(match_arm (match_arm
(match_pattern (match_pattern
(struct_pattern (struct_pattern
(type_identifier) (type_identifier)
(field_pattern (field_identifier) (identifier)) (field_pattern
(field_pattern (field_identifier)))) (field_identifier)
(tuple_expression (string_literal) (identifier)))))) (identifier))
(field_pattern
(field_identifier))))
(tuple_expression
(string_literal)
(identifier)))))))
================================= ================================================================================
Ignored patterns Ignored patterns
================================= ================================================================================
match x { match x {
(a, ..) => a, (a, ..) => a,
@ -80,29 +121,40 @@ match x {
D::E{f: g, ..} => g D::E{f: g, ..} => g
} }
--- --------------------------------------------------------------------------------
(source_file (source_file
(match_expression (identifier) (match_block (expression_statement
(match_expression
(identifier)
(match_block
(match_arm (match_arm
(match_pattern (match_pattern
(tuple_pattern (identifier) (remaining_field_pattern))) (tuple_pattern
(identifier)
(remaining_field_pattern)))
(identifier)) (identifier))
(match_arm (match_arm
(match_pattern (match_pattern
(tuple_struct_pattern (identifier) (remaining_field_pattern))) (tuple_struct_pattern
(identifier)
(remaining_field_pattern)))
(identifier)) (identifier))
(match_arm (match_arm
(match_pattern (match_pattern
(struct_pattern (struct_pattern
(scoped_type_identifier (identifier) (type_identifier)) (scoped_type_identifier
(field_pattern (field_identifier) (identifier)) (identifier)
(type_identifier))
(field_pattern
(field_identifier)
(identifier))
(remaining_field_pattern))) (remaining_field_pattern)))
(identifier))))) (identifier))))))
================================= ================================================================================
Captured patterns Captured patterns
================================= ================================================================================
match x { match x {
a @ A(_) | b @ B(..) => a, a @ A(_) | b @ B(..) => a,
@ -112,9 +164,10 @@ match x {
a @ b..=c => a, a @ b..=c => a,
} }
--- --------------------------------------------------------------------------------
(source_file (source_file
(expression_statement
(match_expression (match_expression
value: (identifier) value: (identifier)
body: (match_block body: (match_block
@ -162,11 +215,11 @@ match x {
(range_pattern (range_pattern
(identifier) (identifier)
(identifier)))) (identifier))))
value: (identifier))))) value: (identifier))))))
================================= ================================================================================
Or patterns Or patterns
================================= ================================================================================
if let A(x) | B(x) = expr { if let A(x) | B(x) = expr {
do_stuff_with(x); do_stuff_with(x);
@ -196,9 +249,10 @@ fn foo((1 | 2 | 3): u8) {}
// Not handled cause devs didn't got into agreement if should be acceptd or not // Not handled cause devs didn't got into agreement if should be acceptd or not
// |Ok(x) | Err(x)| expr(); // |Ok(x) | Err(x)| expr();
--- --------------------------------------------------------------------------------
(source_file (source_file
(expression_statement
(if_let_expression (if_let_expression
pattern: (or_pattern pattern: (or_pattern
(tuple_struct_pattern (tuple_struct_pattern
@ -209,10 +263,12 @@ fn foo((1 | 2 | 3): u8) {}
(identifier))) (identifier)))
value: (identifier) value: (identifier)
consequence: (block consequence: (block
(expression_statement
(call_expression (call_expression
function: (identifier) function: (identifier)
arguments: (arguments arguments: (arguments
(identifier))))) (identifier)))))))
(expression_statement
(while_let_expression (while_let_expression
pattern: (or_pattern pattern: (or_pattern
(tuple_struct_pattern (tuple_struct_pattern
@ -223,10 +279,11 @@ fn foo((1 | 2 | 3): u8) {}
(identifier))) (identifier)))
value: (identifier) value: (identifier)
body: (block body: (block
(expression_statement
(call_expression (call_expression
function: (identifier) function: (identifier)
arguments: (arguments arguments: (arguments
(identifier))))) (identifier)))))))
(let_declaration (let_declaration
pattern: (or_pattern pattern: (or_pattern
(tuple_struct_pattern (tuple_struct_pattern
@ -242,13 +299,14 @@ fn foo((1 | 2 | 3): u8) {}
arguments: (arguments arguments: (arguments
(reference_expression (reference_expression
value: (identifier))))) value: (identifier)))))
(expression_statement
(for_expression (for_expression
pattern: (or_pattern pattern: (or_pattern
(ref_pattern (ref_pattern
(identifier)) (identifier))
(identifier)) (identifier))
value: (identifier) value: (identifier)
body: (block)) body: (block)))
(let_declaration (let_declaration
pattern: (or_pattern pattern: (or_pattern
(tuple_struct_pattern (tuple_struct_pattern
@ -261,6 +319,7 @@ fn foo((1 | 2 | 3): u8) {}
function: (identifier) function: (identifier)
arguments: (arguments arguments: (arguments
(identifier)))) (identifier))))
(expression_statement
(for_expression (for_expression
pattern: (or_pattern pattern: (or_pattern
(or_pattern (or_pattern
@ -268,7 +327,8 @@ fn foo((1 | 2 | 3): u8) {}
(identifier)) (identifier))
(identifier)) (identifier))
value: (identifier) value: (identifier)
body: (block)) body: (block)))
(expression_statement
(closure_expression (closure_expression
parameters: (closure_parameters parameters: (closure_parameters
(tuple_pattern (tuple_pattern
@ -281,7 +341,7 @@ fn foo((1 | 2 | 3): u8) {}
(identifier))))) (identifier)))))
body: (call_expression body: (call_expression
function: (identifier) function: (identifier)
arguments: (arguments))) arguments: (arguments))))
(let_declaration (let_declaration
pattern: (ref_pattern pattern: (ref_pattern
(mut_pattern (mut_pattern
@ -311,9 +371,9 @@ fn foo((1 | 2 | 3): u8) {}
(line_comment) (line_comment)
(line_comment)) (line_comment))
=========================================== ================================================================================
Inline const or Const blocks as pattern Inline const or Const blocks as pattern
=========================================== ================================================================================
fn foo(x: i32) { fn foo(x: i32) {
const CUBE: i32 = 3.pow(3); const CUBE: i32 = 3.pow(3);
@ -330,7 +390,7 @@ fn foo(x: i32) {
} }
} }
--- --------------------------------------------------------------------------------
(source_file (source_file
(function_item (function_item
@ -349,6 +409,7 @@ fn foo(x: i32) {
field: (field_identifier)) field: (field_identifier))
arguments: (arguments arguments: (arguments
(integer_literal)))) (integer_literal))))
(expression_statement
(match_expression (match_expression
value: (identifier) value: (identifier)
body: (match_block body: (match_block
@ -361,7 +422,7 @@ fn foo(x: i32) {
(string_literal)))) (string_literal))))
(match_arm (match_arm
pattern: (match_pattern) pattern: (match_pattern)
value: (block)))))) value: (block)))))))
(function_item (function_item
name: (identifier) name: (identifier)
parameters: (parameters parameters: (parameters
@ -369,6 +430,7 @@ fn foo(x: i32) {
pattern: (identifier) pattern: (identifier)
type: (primitive_type))) type: (primitive_type)))
body: (block body: (block
(expression_statement
(match_expression (match_expression
value: (identifier) value: (identifier)
body: (match_block body: (match_block
@ -388,4 +450,4 @@ fn foo(x: i32) {
(string_literal)))) (string_literal))))
(match_arm (match_arm
pattern: (match_pattern) pattern: (match_pattern)
value: (block))))))) value: (block))))))))

@ -1,123 +1,187 @@
===================== ================================================================================
The unit type The unit type
===================== ================================================================================
type A = (); type A = ();
--- --------------------------------------------------------------------------------
(source_file (source_file
(type_item (type_identifier) (unit_type))) (type_item
(type_identifier)
(unit_type)))
===================== ================================================================================
Tuple types Tuple types
===================== ================================================================================
type A = (i32, String); type A = (i32, String);
--- --------------------------------------------------------------------------------
(source_file (source_file
(type_item (type_identifier) (tuple_type (primitive_type) (type_identifier)))) (type_item
(type_identifier)
(tuple_type
(primitive_type)
(type_identifier))))
===================== ================================================================================
Reference types Reference types
===================== ================================================================================
type A = &B; type A = &B;
type C = &'a str; type C = &'a str;
type D = &'a mut str; type D = &'a mut str;
--- --------------------------------------------------------------------------------
(source_file (source_file
(type_item (type_identifier) (reference_type (type_identifier))) (type_item
(type_item (type_identifier) (reference_type (lifetime (identifier)) (primitive_type))) (type_identifier)
(type_item (type_identifier) (reference_type (lifetime (identifier)) (mutable_specifier) (primitive_type)))) (reference_type
(type_identifier)))
(type_item
(type_identifier)
(reference_type
(lifetime
(identifier))
(primitive_type)))
(type_item
(type_identifier)
(reference_type
(lifetime
(identifier))
(mutable_specifier)
(primitive_type))))
===================== ================================================================================
Raw pointer types Raw pointer types
===================== ================================================================================
type A = *mut B; type A = *mut B;
type C = *const str; type C = *const str;
--- --------------------------------------------------------------------------------
(source_file (source_file
(type_item (type_identifier) (pointer_type (mutable_specifier) (type_identifier))) (type_item
(type_item (type_identifier) (pointer_type (primitive_type)))) (type_identifier)
(pointer_type
(mutable_specifier)
(type_identifier)))
(type_item
(type_identifier)
(pointer_type
(primitive_type))))
===================== ================================================================================
Generic types Generic types
===================== ================================================================================
type A = B<C>; type A = B<C>;
type D = E<F, str>; type D = E<F, str>;
type G = H<'a, I>; type G = H<'a, I>;
type J = H<K=L>; type J = H<K=L>;
--- --------------------------------------------------------------------------------
(source_file (source_file
(type_item (type_item
(type_identifier) (type_identifier)
(generic_type (type_identifier) (type_arguments (type_identifier)))) (generic_type
(type_identifier)
(type_arguments
(type_identifier))))
(type_item (type_item
(type_identifier) (type_identifier)
(generic_type (type_identifier) (type_arguments (type_identifier) (primitive_type)))) (generic_type
(type_identifier)
(type_arguments
(type_identifier)
(primitive_type))))
(type_item (type_item
(type_identifier) (type_identifier)
(generic_type (type_identifier) (type_arguments (lifetime (identifier)) (type_identifier)))) (generic_type
(type_identifier)
(type_arguments
(lifetime
(identifier))
(type_identifier))))
(type_item (type_item
(type_identifier) (type_identifier)
(generic_type (type_identifier) (type_arguments (type_binding (type_identifier) (type_identifier)))))) (generic_type
(type_identifier)
(type_arguments
(type_binding
(type_identifier)
(type_identifier))))))
===================== ================================================================================
Scoped types Scoped types
===================== ================================================================================
type A = B::C; type A = B::C;
type D = E::F::G; type D = E::F::G;
type H = I::J<K>; type H = I::J<K>;
type L = M<N>::O; type L = M<N>::O;
--- --------------------------------------------------------------------------------
(source_file (source_file
(type_item (type_item
(type_identifier) (type_identifier)
(scoped_type_identifier (identifier) (type_identifier))) (scoped_type_identifier
(identifier)
(type_identifier)))
(type_item (type_item
(type_identifier) (type_identifier)
(scoped_type_identifier (scoped_identifier (identifier) (identifier)) (type_identifier))) (scoped_type_identifier
(scoped_identifier
(identifier)
(identifier))
(type_identifier)))
(type_item (type_item
(type_identifier) (type_identifier)
(generic_type (generic_type
(scoped_type_identifier (identifier) (type_identifier)) (scoped_type_identifier
(type_arguments (type_identifier)))) (identifier)
(type_identifier))
(type_arguments
(type_identifier))))
(type_item (type_item
(type_identifier) (type_identifier)
(scoped_type_identifier (scoped_type_identifier
(generic_type (type_identifier) (type_arguments (type_identifier))) (generic_type
(type_identifier)
(type_arguments
(type_identifier)))
(type_identifier)))) (type_identifier))))
===================== ================================================================================
Array types Array types
===================== ================================================================================
type A = [B; 4]; type A = [B; 4];
type C = &[D]; type C = &[D];
--- --------------------------------------------------------------------------------
(source_file (source_file
(type_item (type_identifier) (array_type (type_identifier) (integer_literal))) (type_item
(type_item (type_identifier) (reference_type (array_type (type_identifier))))) (type_identifier)
(array_type
(type_identifier)
(integer_literal)))
(type_item
(type_identifier)
(reference_type
(array_type
(type_identifier)))))
============================ ================================================================================
Function types Function types
============================ ================================================================================
fn high_order1(value: i32, f: fn(i32)) -> i32 {} fn high_order1(value: i32, f: fn(i32)) -> i32 {}
@ -131,100 +195,180 @@ fn high_order3(value: i32, f: &FnOnce(i32) -> i32) -> i32 {
type F = for<'a, 'b> fn(x: &'a A, y: &'a mut B<'i, 't>,) -> C; type F = for<'a, 'b> fn(x: &'a A, y: &'a mut B<'i, 't>,) -> C;
--- --------------------------------------------------------------------------------
(source_file (source_file
(function_item (function_item
(identifier) (identifier)
(parameters (parameters
(parameter (identifier) (primitive_type)) (parameter
(parameter (identifier) (function_type (parameters (primitive_type))))) (identifier)
(primitive_type))
(parameter
(identifier)
(function_type
(parameters
(primitive_type)))))
(primitive_type) (primitive_type)
(block)) (block))
(function_item (function_item
(identifier) (identifier)
(parameters (parameters
(parameter (identifier) (primitive_type)) (parameter
(parameter (identifier) (function_type (parameters (primitive_type)) (primitive_type)))) (identifier)
(primitive_type))
(parameter
(identifier)
(function_type
(parameters
(primitive_type))
(primitive_type))))
(primitive_type) (primitive_type)
(block (call_expression (identifier) (arguments (identifier))))) (block
(call_expression
(identifier)
(arguments
(identifier)))))
(function_item (function_item
(identifier) (identifier)
(parameters (parameters
(parameter (identifier) (primitive_type)) (parameter
(parameter (identifier) (reference_type (function_type (type_identifier) (parameters (primitive_type)) (primitive_type))))) (identifier)
(primitive_type) (block (call_expression (identifier) (arguments (identifier))))) (primitive_type))
(parameter
(identifier)
(reference_type
(function_type
(type_identifier)
(parameters
(primitive_type))
(primitive_type)))))
(primitive_type)
(block
(call_expression
(identifier)
(arguments
(identifier)))))
(type_item (type_item
(type_identifier) (type_identifier)
(function_type (function_type
(for_lifetimes (lifetime (identifier)) (lifetime (identifier))) (for_lifetimes
(parameters (parameter (identifier) (reference_type (lifetime (identifier)) (type_identifier))) (parameter (identifier) (reference_type (lifetime (identifier)) (mutable_specifier) (generic_type (type_identifier) (type_arguments (lifetime (identifier)) (lifetime (identifier))))))) (lifetime
(identifier))
(lifetime
(identifier)))
(parameters
(parameter
(identifier)
(reference_type
(lifetime
(identifier))
(type_identifier)))
(parameter
(identifier)
(reference_type
(lifetime
(identifier))
(mutable_specifier)
(generic_type
(type_identifier)
(type_arguments
(lifetime
(identifier))
(lifetime
(identifier)))))))
(type_identifier)))) (type_identifier))))
================================= ================================================================================
Unsafe and extern function types Unsafe and extern function types
================================= ================================================================================
type a = extern "C" fn(*mut c_void); type a = extern "C" fn(*mut c_void);
type b = unsafe extern "C" fn() -> *mut c_void; type b = unsafe extern "C" fn() -> *mut c_void;
--- --------------------------------------------------------------------------------
(source_file (source_file
(type_item (type_item
(type_identifier) (type_identifier)
(function_type (function_type
(function_modifiers (extern_modifier (string_literal))) (function_modifiers
(parameters (pointer_type (mutable_specifier) (type_identifier))))) (extern_modifier
(string_literal)))
(parameters
(pointer_type
(mutable_specifier)
(type_identifier)))))
(type_item (type_item
(type_identifier) (type_identifier)
(function_type (function_type
(function_modifiers (extern_modifier (string_literal))) (function_modifiers
(extern_modifier
(string_literal)))
(parameters) (parameters)
(pointer_type (mutable_specifier) (type_identifier))))) (pointer_type
(mutable_specifier)
(type_identifier)))))
=================================== ================================================================================
Trait objects Trait objects
=================================== ================================================================================
type a = Box<Something + 'a>; type a = Box<Something + 'a>;
type b = Rc<dyn Something>; type b = Rc<dyn Something>;
type c = A<&dyn Fn(&B) -> C>; type c = A<&dyn Fn(&B) -> C>;
--- --------------------------------------------------------------------------------
(source_file (source_file
(type_item (type_item
(type_identifier) (type_identifier)
(generic_type (generic_type
(type_identifier) (type_identifier)
(type_arguments (bounded_type (type_identifier) (lifetime (identifier)))))) (type_arguments
(bounded_type
(type_identifier)
(lifetime
(identifier))))))
(type_item (type_item
(type_identifier) (type_identifier)
(generic_type (generic_type
(type_identifier) (type_identifier)
(type_arguments (dynamic_type (type_identifier))))) (type_arguments
(dynamic_type
(type_identifier)))))
(type_item (type_item
(type_identifier) (type_identifier)
(generic_type (generic_type
(type_identifier) (type_identifier)
(type_arguments (type_arguments
(reference_type (reference_type
(dynamic_type (function_type (type_identifier) (parameters (reference_type (type_identifier))) (type_identifier)))))))) (dynamic_type
(function_type
(type_identifier)
(parameters
(reference_type
(type_identifier)))
(type_identifier))))))))
==================================== ================================================================================
Type cast expressions with generics Type cast expressions with generics
==================================== ================================================================================
a as B<C>; a as B<C>;
d as *mut E<<F as E>::G>; d as *mut E<<F as E>::G>;
--- --------------------------------------------------------------------------------
(source_file (source_file
(expression_statement
(type_cast_expression (type_cast_expression
(identifier) (identifier)
(generic_type (type_identifier) (type_arguments (type_identifier)))) (generic_type
(type_identifier)
(type_arguments
(type_identifier)))))
(expression_statement
(type_cast_expression (type_cast_expression
(identifier) (identifier)
(pointer_type (pointer_type
@ -233,5 +377,8 @@ d as *mut E<<F as E>::G>;
(type_identifier) (type_identifier)
(type_arguments (type_arguments
(scoped_type_identifier (scoped_type_identifier
(bracketed_type (qualified_type (type_identifier) (type_identifier))) (bracketed_type
(type_identifier))))))) (qualified_type
(type_identifier)
(type_identifier)))
(type_identifier))))))))

@ -35,6 +35,54 @@ const numeric_types = [
const primitive_types = numeric_types.concat(['bool', 'str', 'char']) const primitive_types = numeric_types.concat(['bool', 'str', 'char'])
const built_in_attributes = [
'cfg',
'cfg_attr',
'test',
'ignore',
'should_panic',
'derive',
'automatically_derived',
'macro_export',
'macro_use',
'proc_macro',
'proc_macro_derive',
'proc_macro_attribute',
'allow',
'warn',
'deny',
'forbid',
'deprecated',
'must_use',
'link',
'link_name',
'no_link',
'repr',
'crate_type',
'no_main',
'export_name',
'link_section',
'no_mangle',
'used',
'crate_name',
'inline',
'cold',
'no_builtins',
'target_feature',
'track_caller',
'doc',
'no_std',
'no_implicit_prelude',
'path',
'recursion_limit',
'type_length_limit',
'panic_handler',
'global_allocator',
'windows_subsystem',
'feature',
'non_exhaustive'
]
module.exports = grammar({ module.exports = grammar({
name: 'rust', name: 'rust',
@ -84,13 +132,13 @@ module.exports = grammar({
source_file: $ => repeat($._statement), source_file: $ => repeat($._statement),
_statement: $ => choice( _statement: $ => choice(
$._expression_statement, $.expression_statement,
$._declaration_statement $._declaration_statement
), ),
empty_statement: $ => ';', empty_statement: $ => ';',
_expression_statement: $ => choice( expression_statement: $ => choice(
seq($._expression, ';'), seq($._expression, ';'),
prec(1, $._expression_ending_with_block) prec(1, $._expression_ending_with_block)
), ),
@ -150,6 +198,7 @@ module.exports = grammar({
$.token_tree_pattern, $.token_tree_pattern,
$.token_repetition_pattern, $.token_repetition_pattern,
$.token_binding_pattern, $.token_binding_pattern,
$.metavariable,
$._non_special_token $._non_special_token
), ),
@ -177,6 +226,7 @@ module.exports = grammar({
_tokens: $ => choice( _tokens: $ => choice(
$.token_tree, $.token_tree,
$.token_repetition, $.token_repetition,
$.metavariable,
$._non_special_token $._non_special_token
), ),
@ -190,10 +240,19 @@ module.exports = grammar({
'$', '(', repeat($._tokens), ')', optional(/[^+*?]+/), choice('+', '*', '?') '$', '(', repeat($._tokens), ')', optional(/[^+*?]+/), choice('+', '*', '?')
), ),
non_special_punctuation: $ => /[/_\-=->,;:::!=?.@*&#%^+<>|~]+/, non_special_punctuation: $ => choice(
// https://doc.rust-lang.org/reference/tokens.html#punctuation
"+", "-", "*", "/", "%", "^", "!", "&", "|", "&&", "||", "<<",
">>", "+=", "-=", "*=", "/=", "%=", "^=", "&=", "|=", "<<=",
">>=", "=", "==", "!=", ">", "<", ">=", "<=", "@", "_", ".",
"..", "...", "..=", ",", ";", ":", "::", "->", "=>", "#", "?",
),
// Matches non-delimiter tokens common to both macro invocations and
// definitions. This is everything except $ and metavariables (which begin
// with $).
_non_special_token: $ => choice( _non_special_token: $ => choice(
$._literal, $.identifier, $.metavariable, $.mutable_specifier, $.self, $.super, $.crate, $._literal, $.identifier, $.mutable_specifier, $.self, $.super, $.crate,
alias(choice(...primitive_types), $.primitive_type), alias(choice(...primitive_types), $.primitive_type),
$.non_special_punctuation, $.non_special_punctuation,
'\'', '\'',
@ -207,7 +266,7 @@ module.exports = grammar({
attribute_item: $ => seq( attribute_item: $ => seq(
'#', '#',
'[', '[',
$.meta_item, $._attr,
']' ']'
), ),
@ -215,14 +274,39 @@ module.exports = grammar({
'#', '#',
'!', '!',
'[', '[',
$.meta_item, $._attr,
']' ']'
), ),
_attr: $ => choice(
alias($.built_in_attr, $.meta_item),
alias($.custom_attr, $.attr_item),
),
custom_attr: $ => seq(
$._path,
optional(choice(
seq('=', field('value', $._expression)),
field('arguments', alias($.delim_token_tree, $.token_tree))
))
),
built_in_attr: $ => seq(
$._built_in_attr_path,
optional(choice(
seq('=', field('value', $._expression)),
field('arguments', $.meta_arguments)
))
),
_built_in_attr_path: $ => choice(
...built_in_attributes.map(name => alias(name, $.identifier))
),
meta_item: $ => seq( meta_item: $ => seq(
$._path, $._path,
optional(choice( optional(choice(
seq('=', field('value', $._literal)), seq('=', field('value', $._expression)),
field('arguments', $.meta_arguments) field('arguments', $.meta_arguments)
)) ))
), ),
@ -466,7 +550,7 @@ module.exports = grammar({
)), )),
field('type', $._type), field('type', $._type),
optional($.where_clause), optional($.where_clause),
field('body', $.declaration_list) choice(field('body', $.declaration_list), ';')
), ),
trait_item: $ => seq( trait_item: $ => seq(
@ -483,6 +567,7 @@ module.exports = grammar({
associated_type: $ => seq( associated_type: $ => seq(
'type', 'type',
field('name', $._type_identifier), field('name', $._type_identifier),
field('type_parameters', optional($.type_parameters)),
field('bounds', optional($.trait_bounds)), field('bounds', optional($.trait_bounds)),
';' ';'
), ),
@ -788,6 +873,7 @@ module.exports = grammar({
type_binding: $ => seq( type_binding: $ => seq(
field('name', $._type_identifier), field('name', $._type_identifier),
field('type_arguments', optional($.type_arguments)),
'=', '=',
field('type', $._type) field('type', $._type)
), ),
@ -831,7 +917,7 @@ module.exports = grammar({
// Section - Expressions // Section - Expressions
_expression: $ => choice( _expression_except_range: $ => choice(
$.unary_expression, $.unary_expression,
$.reference_expression, $.reference_expression,
$.try_expression, $.try_expression,
@ -839,9 +925,9 @@ module.exports = grammar({
$.assignment_expression, $.assignment_expression,
$.compound_assignment_expr, $.compound_assignment_expr,
$.type_cast_expression, $.type_cast_expression,
$.range_expression,
$.call_expression, $.call_expression,
$.return_expression, $.return_expression,
$.yield_expression,
$._literal, $._literal,
prec.left($.identifier), prec.left($.identifier),
alias(choice(...primitive_types), $.identifier), alias(choice(...primitive_types), $.identifier),
@ -855,14 +941,19 @@ module.exports = grammar({
$.tuple_expression, $.tuple_expression,
prec(1, $.macro_invocation), prec(1, $.macro_invocation),
$.unit_expression, $.unit_expression,
$._expression_ending_with_block,
$.break_expression, $.break_expression,
$.continue_expression, $.continue_expression,
$.index_expression, $.index_expression,
$.metavariable, $.metavariable,
$.closure_expression, $.closure_expression,
$.parenthesized_expression, $.parenthesized_expression,
$.struct_expression $.struct_expression,
$._expression_ending_with_block,
),
_expression: $ => choice(
$._expression_except_range,
$.range_expression,
), ),
_expression_ending_with_block: $ => choice( _expression_ending_with_block: $ => choice(
@ -886,7 +977,24 @@ module.exports = grammar({
$._reserved_identifier, $._reserved_identifier,
)), )),
'!', '!',
$.token_tree alias($.delim_token_tree, $.token_tree)
),
delim_token_tree: $ => choice(
seq('(', repeat($._delim_tokens), ')'),
seq('[', repeat($._delim_tokens), ']'),
seq('{', repeat($._delim_tokens), '}')
),
_delim_tokens: $ => choice(
$._non_delim_token,
alias($.delim_token_tree, $.token_tree),
),
// Should match any token other than a delimiter.
_non_delim_token: $ => choice(
$._non_special_token,
'$'
), ),
scoped_identifier: $ => seq( scoped_identifier: $ => seq(
@ -920,10 +1028,7 @@ module.exports = grammar({
), ),
range_expression: $ => prec.left(PREC.range, choice( range_expression: $ => prec.left(PREC.range, choice(
prec.left( seq($._expression, choice('..', '...', '..='), $._expression),
PREC.range + 1,
seq($._expression, choice('..', '...', '..='), $._expression)
),
seq($._expression, '..'), seq($._expression, '..'),
seq('..', $._expression), seq('..', $._expression),
'..' '..'
@ -988,8 +1093,13 @@ module.exports = grammar({
prec(-1, 'return'), prec(-1, 'return'),
), ),
yield_expression: $ => choice(
prec.left(seq('yield', $._expression)),
prec(-1, 'yield'),
),
call_expression: $ => prec(PREC.call, seq( call_expression: $ => prec(PREC.call, seq(
field('function', $._expression), field('function', $._expression_except_range),
field('arguments', $.arguments) field('arguments', $.arguments)
)), )),

@ -1,6 +1,6 @@
{ {
"name": "tree-sitter-rust", "name": "tree-sitter-rust",
"version": "0.19.1", "version": "0.20.1",
"description": "Rust grammar for tree-sitter", "description": "Rust grammar for tree-sitter",
"main": "bindings/node", "main": "bindings/node",
"keywords": [ "keywords": [
@ -17,7 +17,7 @@
"nan": "^2.14.0" "nan": "^2.14.0"
}, },
"devDependencies": { "devDependencies": {
"tree-sitter-cli": "^0.19.1" "tree-sitter-cli": "^0.20.0"
}, },
"scripts": { "scripts": {
"generate": "tree-sitter generate", "generate": "tree-sitter generate",

@ -0,0 +1,60 @@
; ADT definitions
(struct_item
name: (type_identifier) @name) @definition.class
(enum_item
name: (type_identifier) @name) @definition.class
(union_item
name: (type_identifier) @name) @definition.class
; type aliases
(type_item
name: (type_identifier) @name) @definition.class
; method definitions
(declaration_list
(function_item
name: (identifier) @name)) @definition.method
; function definitions
(function_item
name: (identifier) @name) @definition.function
; trait definitions
(trait_item
name: (type_identifier) @name) @definition.interface
; module definitions
(mod_item
name: (identifier) @name) @definition.module
; macro definitions
(macro_definition
name: (identifier) @name) @definition.macro
; references
(call_expression
function: (identifier) @name) @reference.call
(call_expression
function: (field_expression
field: (field_identifier) @name)) @reference.call
(macro_invocation
macro: (identifier) @name) @reference.call
; implementations
(impl_item
trait: (type_identifier) @name) @reference.implementation
(impl_item
type: (type_identifier) @name
!trait) @reference.implementation

File diff suppressed because it is too large Load Diff

@ -248,6 +248,10 @@
{ {
"type": "while_let_expression", "type": "while_let_expression",
"named": true "named": true
},
{
"type": "yield_expression",
"named": true
} }
] ]
}, },
@ -607,6 +611,16 @@
"named": true "named": true
} }
] ]
},
"type_parameters": {
"multiple": false,
"required": false,
"types": [
{
"type": "type_parameters",
"named": true
}
]
} }
} }
}, },
@ -625,6 +639,62 @@
] ]
} }
}, },
{
"type": "attr_item",
"named": true,
"fields": {
"arguments": {
"multiple": false,
"required": false,
"types": [
{
"type": "token_tree",
"named": true
}
]
},
"value": {
"multiple": false,
"required": false,
"types": [
{
"type": "_expression",
"named": true
}
]
}
},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "crate",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "metavariable",
"named": true
},
{
"type": "scoped_identifier",
"named": true
},
{
"type": "self",
"named": true
},
{
"type": "super",
"named": true
}
]
}
},
{ {
"type": "attribute_item", "type": "attribute_item",
"named": true, "named": true,
@ -633,6 +703,10 @@
"multiple": false, "multiple": false,
"required": true, "required": true,
"types": [ "types": [
{
"type": "attr_item",
"named": true
},
{ {
"type": "meta_item", "type": "meta_item",
"named": true "named": true
@ -789,6 +863,10 @@
{ {
"type": "_expression", "type": "_expression",
"named": true "named": true
},
{
"type": "expression_statement",
"named": true
} }
] ]
} }
@ -874,7 +952,159 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "_expression", "type": "_literal",
"named": true
},
{
"type": "array_expression",
"named": true
},
{
"type": "assignment_expression",
"named": true
},
{
"type": "async_block",
"named": true
},
{
"type": "await_expression",
"named": true
},
{
"type": "binary_expression",
"named": true
},
{
"type": "block",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "call_expression",
"named": true
},
{
"type": "closure_expression",
"named": true
},
{
"type": "compound_assignment_expr",
"named": true
},
{
"type": "const_block",
"named": true
},
{
"type": "continue_expression",
"named": true
},
{
"type": "field_expression",
"named": true
},
{
"type": "for_expression",
"named": true
},
{
"type": "generic_function",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "if_expression",
"named": true
},
{
"type": "if_let_expression",
"named": true
},
{
"type": "index_expression",
"named": true
},
{
"type": "loop_expression",
"named": true
},
{
"type": "macro_invocation",
"named": true
},
{
"type": "match_expression",
"named": true
},
{
"type": "metavariable",
"named": true
},
{
"type": "parenthesized_expression",
"named": true
},
{
"type": "reference_expression",
"named": true
},
{
"type": "return_expression",
"named": true
},
{
"type": "scoped_identifier",
"named": true
},
{
"type": "self",
"named": true
},
{
"type": "struct_expression",
"named": true
},
{
"type": "try_expression",
"named": true
},
{
"type": "tuple_expression",
"named": true
},
{
"type": "type_cast_expression",
"named": true
},
{
"type": "unary_expression",
"named": true
},
{
"type": "unit_expression",
"named": true
},
{
"type": "unsafe_block",
"named": true
},
{
"type": "while_expression",
"named": true
},
{
"type": "while_let_expression",
"named": true
},
{
"type": "yield_expression",
"named": true "named": true
} }
] ]
@ -1351,6 +1581,21 @@
] ]
} }
}, },
{
"type": "expression_statement",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "_expression",
"named": true
}
]
}
},
{ {
"type": "extern_crate_declaration", "type": "extern_crate_declaration",
"named": true, "named": true,
@ -2113,7 +2358,7 @@
"fields": { "fields": {
"body": { "body": {
"multiple": false, "multiple": false,
"required": true, "required": false,
"types": [ "types": [
{ {
"type": "declaration_list", "type": "declaration_list",
@ -2194,6 +2439,10 @@
"multiple": false, "multiple": false,
"required": true, "required": true,
"types": [ "types": [
{
"type": "attr_item",
"named": true
},
{ {
"type": "meta_item", "type": "meta_item",
"named": true "named": true
@ -2530,7 +2779,7 @@
"required": false, "required": false,
"types": [ "types": [
{ {
"type": "_literal", "type": "_expression",
"named": true "named": true
} }
] ]
@ -2641,6 +2890,11 @@
] ]
} }
}, },
{
"type": "non_special_punctuation",
"named": true,
"fields": {}
},
{ {
"type": "optional_type_parameter", "type": "optional_type_parameter",
"named": true, "named": true,
@ -3257,7 +3511,7 @@
"named": true "named": true
}, },
{ {
"type": "_expression", "type": "expression_statement",
"named": true "named": true
} }
] ]
@ -3939,6 +4193,16 @@
"named": true "named": true
} }
] ]
},
"type_arguments": {
"multiple": false,
"required": false,
"types": [
{
"type": "type_arguments",
"named": true
}
]
} }
} }
}, },
@ -4528,6 +4792,21 @@
] ]
} }
}, },
{
"type": "yield_expression",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": false,
"types": [
{
"type": "_expression",
"named": true
}
]
}
},
{ {
"type": "!", "type": "!",
"named": false "named": false
@ -4988,6 +5267,10 @@
"type": "while", "type": "while",
"named": false "named": false
}, },
{
"type": "yield",
"named": false
},
{ {
"type": "{", "type": "{",
"named": false "named": false

File diff suppressed because it is too large Load Diff

@ -123,6 +123,7 @@ struct TSLanguage {
unsigned (*serialize)(void *, char *); unsigned (*serialize)(void *, char *);
void (*deserialize)(void *, const char *, unsigned); void (*deserialize)(void *, const char *, unsigned);
} external_scanner; } external_scanner;
const TSStateId *primary_state_ids;
}; };
/* /*