diff options
-rw-r--r-- | crates/ra_assists/src/handlers/add_impl.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/add_new.rs | 5 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/introduce_variable.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/merge_imports.rs | 4 | ||||
-rw-r--r-- | crates/ra_fmt/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/raw.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_def/src/path/lower.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/path/lower/lower_use.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/visibility.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests.rs | 4 | ||||
-rw-r--r-- | crates/ra_parser/src/syntax_kind/generated.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 26 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/expr_extensions.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 148 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/traits.rs | 32 | ||||
-rw-r--r-- | xtask/src/ast_src.rs | 383 |
18 files changed, 436 insertions, 214 deletions
diff --git a/crates/ra_assists/src/handlers/add_impl.rs b/crates/ra_assists/src/handlers/add_impl.rs index 6622eadb2..72a201b6d 100644 --- a/crates/ra_assists/src/handlers/add_impl.rs +++ b/crates/ra_assists/src/handlers/add_impl.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, AstNode, NameOwner, TypeParamsOwner}, | 2 | ast::{self, AstNode, AstToken, NameOwner, TypeParamsOwner}, |
3 | TextUnit, | 3 | TextUnit, |
4 | }; | 4 | }; |
5 | use stdx::{format_to, SepBy}; | 5 | use stdx::{format_to, SepBy}; |
@@ -42,7 +42,7 @@ pub(crate) fn add_impl(ctx: AssistCtx) -> Option<Assist> { | |||
42 | if let Some(type_params) = type_params { | 42 | if let Some(type_params) = type_params { |
43 | let lifetime_params = type_params | 43 | let lifetime_params = type_params |
44 | .lifetime_params() | 44 | .lifetime_params() |
45 | .filter_map(|it| it.lifetime_token()) | 45 | .filter_map(|it| it.lifetime()) |
46 | .map(|it| it.text().clone()); | 46 | .map(|it| it.text().clone()); |
47 | let type_params = | 47 | let type_params = |
48 | type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone()); | 48 | type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone()); |
diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index 240b19fa3..c10397249 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs | |||
@@ -1,7 +1,8 @@ | |||
1 | use hir::Adt; | 1 | use hir::Adt; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | ast::{ | 3 | ast::{ |
4 | self, AstNode, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, VisibilityOwner, | 4 | self, AstNode, AstToken, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, |
5 | VisibilityOwner, | ||
5 | }, | 6 | }, |
6 | TextUnit, T, | 7 | TextUnit, T, |
7 | }; | 8 | }; |
@@ -105,7 +106,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { | |||
105 | if let Some(type_params) = type_params { | 106 | if let Some(type_params) = type_params { |
106 | let lifetime_params = type_params | 107 | let lifetime_params = type_params |
107 | .lifetime_params() | 108 | .lifetime_params() |
108 | .filter_map(|it| it.lifetime_token()) | 109 | .filter_map(|it| it.lifetime()) |
109 | .map(|it| it.text().clone()); | 110 | .map(|it| it.text().clone()); |
110 | let type_params = | 111 | let type_params = |
111 | type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone()); | 112 | type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone()); |
diff --git a/crates/ra_assists/src/handlers/introduce_variable.rs b/crates/ra_assists/src/handlers/introduce_variable.rs index 1edbdc14c..9963f884b 100644 --- a/crates/ra_assists/src/handlers/introduce_variable.rs +++ b/crates/ra_assists/src/handlers/introduce_variable.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, AstNode}, | 2 | ast::{self, AstElement, AstNode}, |
3 | SyntaxKind::{ | 3 | SyntaxKind::{ |
4 | BLOCK_EXPR, BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, | 4 | BLOCK_EXPR, BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, |
5 | WHITESPACE, | 5 | WHITESPACE, |
@@ -124,7 +124,7 @@ fn anchor_stmt(expr: ast::Expr) -> Option<(SyntaxNode, bool)> { | |||
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | if ast::Stmt::cast(node.clone()).is_some() { | 127 | if ast::Stmt::cast_element(node.clone().into()).is_some() { |
128 | return Some((node, false)); | 128 | return Some((node, false)); |
129 | } | 129 | } |
130 | 130 | ||
diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs index 5d4b74e56..f8b3ddb4e 100644 --- a/crates/ra_assists/src/handlers/merge_imports.rs +++ b/crates/ra_assists/src/handlers/merge_imports.rs | |||
@@ -3,7 +3,7 @@ use std::iter::successors; | |||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | algo::{neighbor, SyntaxRewriter}, | 4 | algo::{neighbor, SyntaxRewriter}, |
5 | ast::{self, edit::AstNodeEdit, make}, | 5 | ast::{self, edit::AstNodeEdit, make}, |
6 | AstNode, Direction, InsertPosition, SyntaxElement, T, | 6 | AstNode, AstToken, Direction, InsertPosition, SyntaxElement, T, |
7 | }; | 7 | }; |
8 | 8 | ||
9 | use crate::{Assist, AssistCtx, AssistId}; | 9 | use crate::{Assist, AssistCtx, AssistId}; |
@@ -82,7 +82,7 @@ fn try_merge_trees(old: &ast::UseTree, new: &ast::UseTree) -> Option<ast::UseTre | |||
82 | .filter(|it| it.kind() != T!['{'] && it.kind() != T!['}']), | 82 | .filter(|it| it.kind() != T!['{'] && it.kind() != T!['}']), |
83 | ); | 83 | ); |
84 | let use_tree_list = lhs.use_tree_list()?; | 84 | let use_tree_list = lhs.use_tree_list()?; |
85 | let pos = InsertPosition::Before(use_tree_list.r_curly()?.into()); | 85 | let pos = InsertPosition::Before(use_tree_list.r_curly()?.syntax().clone().into()); |
86 | let use_tree_list = use_tree_list.insert_children(pos, to_insert); | 86 | let use_tree_list = use_tree_list.insert_children(pos, to_insert); |
87 | Some(lhs.with_use_tree_list(use_tree_list)) | 87 | Some(lhs.with_use_tree_list(use_tree_list)) |
88 | } | 88 | } |
diff --git a/crates/ra_fmt/src/lib.rs b/crates/ra_fmt/src/lib.rs index db27f9b83..0b4ba1bbe 100644 --- a/crates/ra_fmt/src/lib.rs +++ b/crates/ra_fmt/src/lib.rs | |||
@@ -60,10 +60,10 @@ pub fn extract_trivial_expression(block: &ast::BlockExpr) -> Option<ast::Expr> { | |||
60 | } else { | 60 | } else { |
61 | // Unwrap `{ continue; }` | 61 | // Unwrap `{ continue; }` |
62 | let (stmt,) = block.statements().next_tuple()?; | 62 | let (stmt,) = block.statements().next_tuple()?; |
63 | if has_anything_else(stmt.syntax()) { | ||
64 | return None; | ||
65 | } | ||
66 | if let ast::Stmt::ExprStmt(expr_stmt) = stmt { | 63 | if let ast::Stmt::ExprStmt(expr_stmt) = stmt { |
64 | if has_anything_else(expr_stmt.syntax()) { | ||
65 | return None; | ||
66 | } | ||
67 | let expr = expr_stmt.expr()?; | 67 | let expr = expr_stmt.expr()?; |
68 | match expr.syntax().kind() { | 68 | match expr.syntax().kind() { |
69 | CONTINUE_EXPR | BREAK_EXPR | RETURN_EXPR => return Some(expr), | 69 | CONTINUE_EXPR | BREAK_EXPR | RETURN_EXPR => return Some(expr), |
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 8d4b8b0f0..8338414fa 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -482,14 +482,17 @@ impl ExprCollector<'_> { | |||
482 | self.collect_block_items(&block); | 482 | self.collect_block_items(&block); |
483 | let statements = block | 483 | let statements = block |
484 | .statements() | 484 | .statements() |
485 | .map(|s| match s { | 485 | .filter_map(|s| match s { |
486 | ast::Stmt::LetStmt(stmt) => { | 486 | ast::Stmt::LetStmt(stmt) => { |
487 | let pat = self.collect_pat_opt(stmt.pat()); | 487 | let pat = self.collect_pat_opt(stmt.pat()); |
488 | let type_ref = stmt.ascribed_type().map(TypeRef::from_ast); | 488 | let type_ref = stmt.ascribed_type().map(TypeRef::from_ast); |
489 | let initializer = stmt.initializer().map(|e| self.collect_expr(e)); | 489 | let initializer = stmt.initializer().map(|e| self.collect_expr(e)); |
490 | Statement::Let { pat, type_ref, initializer } | 490 | Some(Statement::Let { pat, type_ref, initializer }) |
491 | } | 491 | } |
492 | ast::Stmt::ExprStmt(stmt) => Statement::Expr(self.collect_expr_opt(stmt.expr())), | 492 | ast::Stmt::ExprStmt(stmt) => { |
493 | Some(Statement::Expr(self.collect_expr_opt(stmt.expr()))) | ||
494 | } | ||
495 | ast::Stmt::ModuleItem(_) => None, | ||
493 | }) | 496 | }) |
494 | .collect(); | 497 | .collect(); |
495 | let tail = block.expr().map(|e| self.collect_expr(e)); | 498 | let tail = block.expr().map(|e| self.collect_expr(e)); |
@@ -541,6 +544,7 @@ impl ExprCollector<'_> { | |||
541 | let ast_id = self.expander.ast_id(&def); | 544 | let ast_id = self.expander.ast_id(&def); |
542 | (TraitLoc { container, ast_id }.intern(self.db).into(), def.name()) | 545 | (TraitLoc { container, ast_id }.intern(self.db).into(), def.name()) |
543 | } | 546 | } |
547 | ast::ModuleItem::ExternBlock(_) => continue, // FIXME: collect from extern blocks | ||
544 | ast::ModuleItem::ImplDef(_) | 548 | ast::ModuleItem::ImplDef(_) |
545 | | ast::ModuleItem::UseItem(_) | 549 | | ast::ModuleItem::UseItem(_) |
546 | | ast::ModuleItem::ExternCrateItem(_) | 550 | | ast::ModuleItem::ExternCrateItem(_) |
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 8f190e7f9..a9dff3a5d 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs | |||
@@ -266,6 +266,10 @@ impl RawItemsCollector { | |||
266 | self.add_macro(current_module, it); | 266 | self.add_macro(current_module, it); |
267 | return; | 267 | return; |
268 | } | 268 | } |
269 | ast::ModuleItem::ExternBlock(_) => { | ||
270 | // FIXME: add extern block | ||
271 | return; | ||
272 | } | ||
269 | }; | 273 | }; |
270 | if let Some(name) = name { | 274 | if let Some(name) = name { |
271 | let name = name.as_name(); | 275 | let name = name.as_name(); |
diff --git a/crates/ra_hir_def/src/path/lower.rs b/crates/ra_hir_def/src/path/lower.rs index 4900000fe..3c13cb2c7 100644 --- a/crates/ra_hir_def/src/path/lower.rs +++ b/crates/ra_hir_def/src/path/lower.rs | |||
@@ -28,7 +28,7 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path> | |||
28 | loop { | 28 | loop { |
29 | let segment = path.segment()?; | 29 | let segment = path.segment()?; |
30 | 30 | ||
31 | if segment.has_colon_colon() { | 31 | if segment.coloncolon().is_some() { |
32 | kind = PathKind::Abs; | 32 | kind = PathKind::Abs; |
33 | } | 33 | } |
34 | 34 | ||
diff --git a/crates/ra_hir_def/src/path/lower/lower_use.rs b/crates/ra_hir_def/src/path/lower/lower_use.rs index 278d5196e..6ec944228 100644 --- a/crates/ra_hir_def/src/path/lower/lower_use.rs +++ b/crates/ra_hir_def/src/path/lower/lower_use.rs | |||
@@ -34,7 +34,7 @@ pub(crate) fn lower_use_tree( | |||
34 | let alias = tree.alias().map(|a| { | 34 | let alias = tree.alias().map(|a| { |
35 | a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) | 35 | a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) |
36 | }); | 36 | }); |
37 | let is_glob = tree.has_star(); | 37 | let is_glob = tree.star().is_some(); |
38 | if let Some(ast_path) = tree.path() { | 38 | if let Some(ast_path) = tree.path() { |
39 | // Handle self in a path. | 39 | // Handle self in a path. |
40 | // E.g. `use something::{self, <...>}` | 40 | // E.g. `use something::{self, <...>}` |
diff --git a/crates/ra_hir_def/src/visibility.rs b/crates/ra_hir_def/src/visibility.rs index 62513873e..1482d3be0 100644 --- a/crates/ra_hir_def/src/visibility.rs +++ b/crates/ra_hir_def/src/visibility.rs | |||
@@ -84,6 +84,10 @@ impl RawVisibility { | |||
84 | let path = ModPath { kind: PathKind::Super(1), segments: Vec::new() }; | 84 | let path = ModPath { kind: PathKind::Super(1), segments: Vec::new() }; |
85 | RawVisibility::Module(path) | 85 | RawVisibility::Module(path) |
86 | } | 86 | } |
87 | ast::VisibilityKind::PubSelf => { | ||
88 | let path = ModPath { kind: PathKind::Plain, segments: Vec::new() }; | ||
89 | RawVisibility::Module(path) | ||
90 | } | ||
87 | ast::VisibilityKind::Pub => RawVisibility::Public, | 91 | ast::VisibilityKind::Pub => RawVisibility::Public, |
88 | } | 92 | } |
89 | } | 93 | } |
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 608408d88..ac0966236 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs | |||
@@ -23,7 +23,7 @@ use insta::assert_snapshot; | |||
23 | use ra_db::{fixture::WithFixture, salsa::Database, FilePosition, SourceDatabase}; | 23 | use ra_db::{fixture::WithFixture, salsa::Database, FilePosition, SourceDatabase}; |
24 | use ra_syntax::{ | 24 | use ra_syntax::{ |
25 | algo, | 25 | algo, |
26 | ast::{self, AstNode}, | 26 | ast::{self, AstNode, AstToken}, |
27 | }; | 27 | }; |
28 | use stdx::format_to; | 28 | use stdx::format_to; |
29 | 29 | ||
@@ -101,7 +101,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String { | |||
101 | let node = src_ptr.value.to_node(&src_ptr.file_syntax(&db)); | 101 | let node = src_ptr.value.to_node(&src_ptr.file_syntax(&db)); |
102 | 102 | ||
103 | let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.clone()) { | 103 | let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.clone()) { |
104 | (self_param.self_kw_token().text_range(), "self".to_string()) | 104 | (self_param.self_kw().unwrap().syntax().text_range(), "self".to_string()) |
105 | } else { | 105 | } else { |
106 | (src_ptr.value.range(), node.text().to_string().replace("\n", " ")) | 106 | (src_ptr.value.range(), node.text().to_string().replace("\n", " ")) |
107 | }; | 107 | }; |
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs index 4c16cf1cd..004f4e564 100644 --- a/crates/ra_parser/src/syntax_kind/generated.rs +++ b/crates/ra_parser/src/syntax_kind/generated.rs | |||
@@ -105,6 +105,7 @@ pub enum SyntaxKind { | |||
105 | DEFAULT_KW, | 105 | DEFAULT_KW, |
106 | EXISTENTIAL_KW, | 106 | EXISTENTIAL_KW, |
107 | UNION_KW, | 107 | UNION_KW, |
108 | RAW_KW, | ||
108 | INT_NUMBER, | 109 | INT_NUMBER, |
109 | FLOAT_NUMBER, | 110 | FLOAT_NUMBER, |
110 | CHAR, | 111 | CHAR, |
@@ -258,7 +259,7 @@ impl SyntaxKind { | |||
258 | | IMPL_KW | IN_KW | LET_KW | LOOP_KW | MACRO_KW | MATCH_KW | MOD_KW | MOVE_KW | 259 | | IMPL_KW | IN_KW | LET_KW | LOOP_KW | MACRO_KW | MATCH_KW | MOD_KW | MOVE_KW |
259 | | MUT_KW | PUB_KW | REF_KW | RETURN_KW | SELF_KW | STATIC_KW | STRUCT_KW | SUPER_KW | 260 | | MUT_KW | PUB_KW | REF_KW | RETURN_KW | SELF_KW | STATIC_KW | STRUCT_KW | SUPER_KW |
260 | | TRAIT_KW | TRUE_KW | TRY_KW | TYPE_KW | UNSAFE_KW | USE_KW | WHERE_KW | WHILE_KW | 261 | | TRAIT_KW | TRUE_KW | TRY_KW | TYPE_KW | UNSAFE_KW | USE_KW | WHERE_KW | WHILE_KW |
261 | | AUTO_KW | DEFAULT_KW | EXISTENTIAL_KW | UNION_KW => true, | 262 | | AUTO_KW | DEFAULT_KW | EXISTENTIAL_KW | UNION_KW | RAW_KW => true, |
262 | _ => false, | 263 | _ => false, |
263 | } | 264 | } |
264 | } | 265 | } |
@@ -651,4 +652,7 @@ macro_rules! T { | |||
651 | ( union ) => { | 652 | ( union ) => { |
652 | $crate::SyntaxKind::UNION_KW | 653 | $crate::SyntaxKind::UNION_KW |
653 | }; | 654 | }; |
655 | ( raw ) => { | ||
656 | $crate::SyntaxKind::RAW_KW | ||
657 | }; | ||
654 | } | 658 | } |
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index ab0f44dd2..c81b68d3e 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -271,7 +271,7 @@ where | |||
271 | let pred = predicates.next().unwrap(); | 271 | let pred = predicates.next().unwrap(); |
272 | let mut bounds = pred.type_bound_list().unwrap().bounds(); | 272 | let mut bounds = pred.type_bound_list().unwrap().bounds(); |
273 | 273 | ||
274 | assert_eq!("'a", pred.lifetime_token().unwrap().text()); | 274 | assert_eq!("'a", pred.lifetime().unwrap().text()); |
275 | 275 | ||
276 | assert_bound("'b", bounds.next()); | 276 | assert_bound("'b", bounds.next()); |
277 | assert_bound("'c", bounds.next()); | 277 | assert_bound("'c", bounds.next()); |
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index b69cae234..d79310995 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -99,7 +99,7 @@ impl ast::ItemList { | |||
99 | None => match self.l_curly() { | 99 | None => match self.l_curly() { |
100 | Some(it) => ( | 100 | Some(it) => ( |
101 | " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(), | 101 | " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(), |
102 | InsertPosition::After(it), | 102 | InsertPosition::After(it.syntax().clone().into()), |
103 | ), | 103 | ), |
104 | None => return self.clone(), | 104 | None => return self.clone(), |
105 | }, | 105 | }, |
@@ -109,10 +109,6 @@ impl ast::ItemList { | |||
109 | [ws.ws().into(), item.syntax().clone().into()].into(); | 109 | [ws.ws().into(), item.syntax().clone().into()].into(); |
110 | self.insert_children(position, to_insert) | 110 | self.insert_children(position, to_insert) |
111 | } | 111 | } |
112 | |||
113 | fn l_curly(&self) -> Option<SyntaxElement> { | ||
114 | self.syntax().children_with_tokens().find(|it| it.kind() == T!['{']) | ||
115 | } | ||
116 | } | 112 | } |
117 | 113 | ||
118 | impl ast::RecordFieldList { | 114 | impl ast::RecordFieldList { |
@@ -147,7 +143,7 @@ impl ast::RecordFieldList { | |||
147 | macro_rules! after_l_curly { | 143 | macro_rules! after_l_curly { |
148 | () => {{ | 144 | () => {{ |
149 | let anchor = match self.l_curly() { | 145 | let anchor = match self.l_curly() { |
150 | Some(it) => it, | 146 | Some(it) => it.syntax().clone().into(), |
151 | None => return self.clone(), | 147 | None => return self.clone(), |
152 | }; | 148 | }; |
153 | InsertPosition::After(anchor) | 149 | InsertPosition::After(anchor) |
@@ -189,24 +185,20 @@ impl ast::RecordFieldList { | |||
189 | 185 | ||
190 | self.insert_children(position, to_insert) | 186 | self.insert_children(position, to_insert) |
191 | } | 187 | } |
192 | |||
193 | fn l_curly(&self) -> Option<SyntaxElement> { | ||
194 | self.syntax().children_with_tokens().find(|it| it.kind() == T!['{']) | ||
195 | } | ||
196 | } | 188 | } |
197 | 189 | ||
198 | impl ast::TypeParam { | 190 | impl ast::TypeParam { |
199 | #[must_use] | 191 | #[must_use] |
200 | pub fn remove_bounds(&self) -> ast::TypeParam { | 192 | pub fn remove_bounds(&self) -> ast::TypeParam { |
201 | let colon = match self.colon_token() { | 193 | let colon = match self.colon() { |
202 | Some(it) => it, | 194 | Some(it) => it, |
203 | None => return self.clone(), | 195 | None => return self.clone(), |
204 | }; | 196 | }; |
205 | let end = match self.type_bound_list() { | 197 | let end = match self.type_bound_list() { |
206 | Some(it) => it.syntax().clone().into(), | 198 | Some(it) => it.syntax().clone().into(), |
207 | None => colon.clone().into(), | 199 | None => colon.syntax().clone().into(), |
208 | }; | 200 | }; |
209 | self.replace_children(colon.into()..=end, iter::empty()) | 201 | self.replace_children(colon.syntax().clone().into()..=end, iter::empty()) |
210 | } | 202 | } |
211 | } | 203 | } |
212 | 204 | ||
@@ -305,8 +297,12 @@ impl ast::UseTree { | |||
305 | Some(it) => it, | 297 | Some(it) => it, |
306 | None => return self.clone(), | 298 | None => return self.clone(), |
307 | }; | 299 | }; |
308 | let use_tree = | 300 | let use_tree = make::use_tree( |
309 | make::use_tree(suffix.clone(), self.use_tree_list(), self.alias(), self.has_star()); | 301 | suffix.clone(), |
302 | self.use_tree_list(), | ||
303 | self.alias(), | ||
304 | self.star().is_some(), | ||
305 | ); | ||
310 | let nested = make::use_tree_list(iter::once(use_tree)); | 306 | let nested = make::use_tree_list(iter::once(use_tree)); |
311 | return make::use_tree(prefix.clone(), Some(nested), None, false); | 307 | return make::use_tree(prefix.clone(), Some(nested), None, false); |
312 | 308 | ||
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index 8bbd946c0..40c8fca3b 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs | |||
@@ -52,6 +52,10 @@ impl ast::RefExpr { | |||
52 | pub fn is_mut(&self) -> bool { | 52 | pub fn is_mut(&self) -> bool { |
53 | self.syntax().children_with_tokens().any(|n| n.kind() == T![mut]) | 53 | self.syntax().children_with_tokens().any(|n| n.kind() == T![mut]) |
54 | } | 54 | } |
55 | |||
56 | pub fn raw_token(&self) -> Option<SyntaxToken> { | ||
57 | None // FIXME: implement &raw | ||
58 | } | ||
55 | } | 59 | } |
56 | 60 | ||
57 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] | 61 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] |
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index bf7d137be..400eba210 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -4,7 +4,10 @@ | |||
4 | use itertools::Itertools; | 4 | use itertools::Itertools; |
5 | 5 | ||
6 | use crate::{ | 6 | use crate::{ |
7 | ast::{self, child_opt, children, AstNode, AttrInput, NameOwner, SyntaxNode}, | 7 | ast::{ |
8 | self, child_opt, child_token_opt, children, AstElement, AstNode, AstToken, AttrInput, | ||
9 | NameOwner, SyntaxNode, | ||
10 | }, | ||
8 | SmolStr, SyntaxElement, | 11 | SmolStr, SyntaxElement, |
9 | SyntaxKind::*, | 12 | SyntaxKind::*, |
10 | SyntaxToken, T, | 13 | SyntaxToken, T, |
@@ -130,13 +133,6 @@ impl ast::PathSegment { | |||
130 | }; | 133 | }; |
131 | Some(res) | 134 | Some(res) |
132 | } | 135 | } |
133 | |||
134 | pub fn has_colon_colon(&self) -> bool { | ||
135 | match self.syntax.first_child_or_token().map(|s| s.kind()) { | ||
136 | Some(T![::]) => true, | ||
137 | _ => false, | ||
138 | } | ||
139 | } | ||
140 | } | 136 | } |
141 | 137 | ||
142 | impl ast::Path { | 138 | impl ast::Path { |
@@ -154,12 +150,6 @@ impl ast::Module { | |||
154 | } | 150 | } |
155 | } | 151 | } |
156 | 152 | ||
157 | impl ast::UseTree { | ||
158 | pub fn has_star(&self) -> bool { | ||
159 | self.syntax().children_with_tokens().any(|it| it.kind() == T![*]) | ||
160 | } | ||
161 | } | ||
162 | |||
163 | impl ast::UseTreeList { | 153 | impl ast::UseTreeList { |
164 | pub fn parent_use_tree(&self) -> ast::UseTree { | 154 | pub fn parent_use_tree(&self) -> ast::UseTree { |
165 | self.syntax() | 155 | self.syntax() |
@@ -167,20 +157,6 @@ impl ast::UseTreeList { | |||
167 | .and_then(ast::UseTree::cast) | 157 | .and_then(ast::UseTree::cast) |
168 | .expect("UseTreeLists are always nested in UseTrees") | 158 | .expect("UseTreeLists are always nested in UseTrees") |
169 | } | 159 | } |
170 | pub fn l_curly(&self) -> Option<SyntaxToken> { | ||
171 | self.token(T!['{']) | ||
172 | } | ||
173 | |||
174 | pub fn r_curly(&self) -> Option<SyntaxToken> { | ||
175 | self.token(T!['}']) | ||
176 | } | ||
177 | |||
178 | fn token(&self, kind: SyntaxKind) -> Option<SyntaxToken> { | ||
179 | self.syntax() | ||
180 | .children_with_tokens() | ||
181 | .filter_map(|it| it.into_token()) | ||
182 | .find(|it| it.kind() == kind) | ||
183 | } | ||
184 | } | 160 | } |
185 | 161 | ||
186 | impl ast::ImplDef { | 162 | impl ast::ImplDef { |
@@ -387,24 +363,9 @@ pub enum SelfParamKind { | |||
387 | } | 363 | } |
388 | 364 | ||
389 | impl ast::SelfParam { | 365 | impl ast::SelfParam { |
390 | pub fn self_kw_token(&self) -> SyntaxToken { | ||
391 | self.syntax() | ||
392 | .children_with_tokens() | ||
393 | .filter_map(|it| it.into_token()) | ||
394 | .find(|it| it.kind() == T![self]) | ||
395 | .expect("invalid tree: self param must have self") | ||
396 | } | ||
397 | |||
398 | pub fn kind(&self) -> SelfParamKind { | 366 | pub fn kind(&self) -> SelfParamKind { |
399 | let borrowed = self.syntax().children_with_tokens().any(|n| n.kind() == T![&]); | 367 | if self.amp().is_some() { |
400 | if borrowed { | 368 | if self.amp_mut_kw().is_some() { |
401 | // check for a `mut` coming after the & -- `mut &self` != `&mut self` | ||
402 | if self | ||
403 | .syntax() | ||
404 | .children_with_tokens() | ||
405 | .skip_while(|n| n.kind() != T![&]) | ||
406 | .any(|n| n.kind() == T![mut]) | ||
407 | { | ||
408 | SelfParamKind::MutRef | 369 | SelfParamKind::MutRef |
409 | } else { | 370 | } else { |
410 | SelfParamKind::Ref | 371 | SelfParamKind::Ref |
@@ -413,32 +374,23 @@ impl ast::SelfParam { | |||
413 | SelfParamKind::Owned | 374 | SelfParamKind::Owned |
414 | } | 375 | } |
415 | } | 376 | } |
416 | } | ||
417 | 377 | ||
418 | impl ast::LifetimeParam { | 378 | /// the "mut" in "mut self", not the one in "&mut self" |
419 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | 379 | pub fn mut_kw(&self) -> Option<ast::MutKw> { |
420 | self.syntax() | 380 | self.syntax() |
421 | .children_with_tokens() | 381 | .children_with_tokens() |
422 | .filter_map(|it| it.into_token()) | 382 | .filter_map(|it| it.into_token()) |
423 | .find(|it| it.kind() == LIFETIME) | 383 | .take_while(|it| it.kind() != T![&]) |
384 | .find_map(ast::MutKw::cast) | ||
424 | } | 385 | } |
425 | } | ||
426 | 386 | ||
427 | impl ast::TypeParam { | 387 | /// the "mut" in "&mut self", not the one in "mut self" |
428 | pub fn colon_token(&self) -> Option<SyntaxToken> { | 388 | pub fn amp_mut_kw(&self) -> Option<ast::MutKw> { |
429 | self.syntax() | 389 | self.syntax() |
430 | .children_with_tokens() | 390 | .children_with_tokens() |
431 | .filter_map(|it| it.into_token()) | 391 | .filter_map(|it| it.into_token()) |
432 | .find(|it| it.kind() == T![:]) | 392 | .skip_while(|it| it.kind() != T![&]) |
433 | } | 393 | .find_map(ast::MutKw::cast) |
434 | } | ||
435 | |||
436 | impl ast::WherePred { | ||
437 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
438 | self.syntax() | ||
439 | .children_with_tokens() | ||
440 | .filter_map(|it| it.into_token()) | ||
441 | .find(|it| it.kind() == LIFETIME) | ||
442 | } | 394 | } |
443 | } | 395 | } |
444 | 396 | ||
@@ -449,7 +401,7 @@ pub enum TypeBoundKind { | |||
449 | /// for<'a> ... | 401 | /// for<'a> ... |
450 | ForType(ast::ForType), | 402 | ForType(ast::ForType), |
451 | /// 'a | 403 | /// 'a |
452 | Lifetime(ast::SyntaxToken), | 404 | Lifetime(ast::Lifetime), |
453 | } | 405 | } |
454 | 406 | ||
455 | impl ast::TypeBound { | 407 | impl ast::TypeBound { |
@@ -465,21 +417,28 @@ impl ast::TypeBound { | |||
465 | } | 417 | } |
466 | } | 418 | } |
467 | 419 | ||
468 | fn lifetime(&self) -> Option<SyntaxToken> { | 420 | pub fn has_question_mark(&self) -> bool { |
469 | self.syntax() | 421 | self.question().is_some() |
470 | .children_with_tokens() | ||
471 | .filter_map(|it| it.into_token()) | ||
472 | .find(|it| it.kind() == LIFETIME) | ||
473 | } | 422 | } |
474 | 423 | ||
475 | pub fn question_mark_token(&self) -> Option<SyntaxToken> { | 424 | pub fn const_question(&self) -> Option<ast::Question> { |
476 | self.syntax() | 425 | self.syntax() |
477 | .children_with_tokens() | 426 | .children_with_tokens() |
478 | .filter_map(|it| it.into_token()) | 427 | .filter_map(|it| it.into_token()) |
479 | .find(|it| it.kind() == T![?]) | 428 | .take_while(|it| it.kind() != T![const]) |
429 | .find_map(ast::Question::cast) | ||
480 | } | 430 | } |
481 | pub fn has_question_mark(&self) -> bool { | 431 | |
482 | self.question_mark_token().is_some() | 432 | pub fn question(&self) -> Option<ast::Question> { |
433 | if self.const_kw().is_some() { | ||
434 | self.syntax() | ||
435 | .children_with_tokens() | ||
436 | .filter_map(|it| it.into_token()) | ||
437 | .skip_while(|it| it.kind() != T![const]) | ||
438 | .find_map(ast::Question::cast) | ||
439 | } else { | ||
440 | child_token_opt(self) | ||
441 | } | ||
483 | } | 442 | } |
484 | } | 443 | } |
485 | 444 | ||
@@ -493,6 +452,7 @@ pub enum VisibilityKind { | |||
493 | In(ast::Path), | 452 | In(ast::Path), |
494 | PubCrate, | 453 | PubCrate, |
495 | PubSuper, | 454 | PubSuper, |
455 | PubSelf, | ||
496 | Pub, | 456 | Pub, |
497 | } | 457 | } |
498 | 458 | ||
@@ -504,6 +464,8 @@ impl ast::Visibility { | |||
504 | VisibilityKind::PubCrate | 464 | VisibilityKind::PubCrate |
505 | } else if self.is_pub_super() { | 465 | } else if self.is_pub_super() { |
506 | VisibilityKind::PubSuper | 466 | VisibilityKind::PubSuper |
467 | } else if self.is_pub_self() { | ||
468 | VisibilityKind::PubSuper | ||
507 | } else { | 469 | } else { |
508 | VisibilityKind::Pub | 470 | VisibilityKind::Pub |
509 | } | 471 | } |
@@ -516,6 +478,10 @@ impl ast::Visibility { | |||
516 | fn is_pub_super(&self) -> bool { | 478 | fn is_pub_super(&self) -> bool { |
517 | self.syntax().children_with_tokens().any(|it| it.kind() == T![super]) | 479 | self.syntax().children_with_tokens().any(|it| it.kind() == T![super]) |
518 | } | 480 | } |
481 | |||
482 | fn is_pub_self(&self) -> bool { | ||
483 | self.syntax().children_with_tokens().any(|it| it.kind() == T![self]) | ||
484 | } | ||
519 | } | 485 | } |
520 | 486 | ||
521 | impl ast::MacroCall { | 487 | impl ast::MacroCall { |
@@ -528,3 +494,41 @@ impl ast::MacroCall { | |||
528 | } | 494 | } |
529 | } | 495 | } |
530 | } | 496 | } |
497 | |||
498 | impl ast::LifetimeParam { | ||
499 | pub fn lifetime_bounds(&self) -> impl Iterator<Item = ast::Lifetime> { | ||
500 | self.syntax() | ||
501 | .children_with_tokens() | ||
502 | .filter_map(|it| it.into_token()) | ||
503 | .skip_while(|x| x.kind() != T![:]) | ||
504 | .filter_map(ast::Lifetime::cast) | ||
505 | } | ||
506 | } | ||
507 | |||
508 | impl ast::RangePat { | ||
509 | pub fn start(&self) -> Option<ast::Pat> { | ||
510 | self.syntax() | ||
511 | .children_with_tokens() | ||
512 | .take_while(|it| !ast::RangeSeparator::can_cast_element(it.kind())) | ||
513 | .filter_map(|it| it.into_node()) | ||
514 | .find_map(ast::Pat::cast) | ||
515 | } | ||
516 | |||
517 | pub fn end(&self) -> Option<ast::Pat> { | ||
518 | self.syntax() | ||
519 | .children_with_tokens() | ||
520 | .skip_while(|it| !ast::RangeSeparator::can_cast_element(it.kind())) | ||
521 | .filter_map(|it| it.into_node()) | ||
522 | .find_map(ast::Pat::cast) | ||
523 | } | ||
524 | } | ||
525 | |||
526 | impl ast::TokenTree { | ||
527 | pub fn left_delimiter(&self) -> Option<ast::LeftDelimiter> { | ||
528 | self.syntax().first_child_or_token().and_then(ast::LeftDelimiter::cast_element) | ||
529 | } | ||
530 | |||
531 | pub fn right_delimiter(&self) -> Option<ast::RightDelimiter> { | ||
532 | self.syntax().last_child_or_token().and_then(ast::RightDelimiter::cast_element) | ||
533 | } | ||
534 | } | ||
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index 576378306..e6f3a4ebb 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs | |||
@@ -4,9 +4,9 @@ | |||
4 | 4 | ||
5 | use itertools::Itertools; | 5 | use itertools::Itertools; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::ast::{ |
8 | ast::{self, child_opt, children, AstChildren, AstNode, AstToken}, | 8 | self, child_elements, child_opt, child_token_opt, child_tokens, children, AstChildElements, |
9 | syntax_node::SyntaxElementChildren, | 9 | AstChildTokens, AstChildren, AstNode, AstToken, |
10 | }; | 10 | }; |
11 | 11 | ||
12 | pub trait TypeAscriptionOwner: AstNode { | 12 | pub trait TypeAscriptionOwner: AstNode { |
@@ -31,6 +31,10 @@ pub trait LoopBodyOwner: AstNode { | |||
31 | fn loop_body(&self) -> Option<ast::BlockExpr> { | 31 | fn loop_body(&self) -> Option<ast::BlockExpr> { |
32 | child_opt(self) | 32 | child_opt(self) |
33 | } | 33 | } |
34 | |||
35 | fn label(&self) -> Option<ast::Label> { | ||
36 | child_opt(self) | ||
37 | } | ||
34 | } | 38 | } |
35 | 39 | ||
36 | pub trait ArgListOwner: AstNode { | 40 | pub trait ArgListOwner: AstNode { |
@@ -65,6 +69,10 @@ pub trait TypeBoundsOwner: AstNode { | |||
65 | fn type_bound_list(&self) -> Option<ast::TypeBoundList> { | 69 | fn type_bound_list(&self) -> Option<ast::TypeBoundList> { |
66 | child_opt(self) | 70 | child_opt(self) |
67 | } | 71 | } |
72 | |||
73 | fn colon(&self) -> Option<ast::Colon> { | ||
74 | child_token_opt(self) | ||
75 | } | ||
68 | } | 76 | } |
69 | 77 | ||
70 | pub trait AttrsOwner: AstNode { | 78 | pub trait AttrsOwner: AstNode { |
@@ -74,11 +82,14 @@ pub trait AttrsOwner: AstNode { | |||
74 | fn has_atom_attr(&self, atom: &str) -> bool { | 82 | fn has_atom_attr(&self, atom: &str) -> bool { |
75 | self.attrs().filter_map(|x| x.as_simple_atom()).any(|x| x == atom) | 83 | self.attrs().filter_map(|x| x.as_simple_atom()).any(|x| x == atom) |
76 | } | 84 | } |
85 | fn attr_or_comments(&self) -> AstChildElements<ast::AttrOrComment> { | ||
86 | child_elements(self) | ||
87 | } | ||
77 | } | 88 | } |
78 | 89 | ||
79 | pub trait DocCommentsOwner: AstNode { | 90 | pub trait DocCommentsOwner: AstNode { |
80 | fn doc_comments(&self) -> CommentIter { | 91 | fn doc_comments(&self) -> AstChildTokens<ast::Comment> { |
81 | CommentIter { iter: self.syntax().children_with_tokens() } | 92 | child_tokens(self) |
82 | } | 93 | } |
83 | 94 | ||
84 | /// Returns the textual content of a doc comment block as a single string. | 95 | /// Returns the textual content of a doc comment block as a single string. |
@@ -123,14 +134,3 @@ pub trait DocCommentsOwner: AstNode { | |||
123 | } | 134 | } |
124 | } | 135 | } |
125 | } | 136 | } |
126 | |||
127 | pub struct CommentIter { | ||
128 | iter: SyntaxElementChildren, | ||
129 | } | ||
130 | |||
131 | impl Iterator for CommentIter { | ||
132 | type Item = ast::Comment; | ||
133 | fn next(&mut self) -> Option<ast::Comment> { | ||
134 | self.iter.by_ref().find_map(|el| el.into_token().and_then(ast::Comment::cast)) | ||
135 | } | ||
136 | } | ||
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index d9f51ec39..3200acc86 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs | |||
@@ -70,7 +70,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { | |||
70 | "match", "mod", "move", "mut", "pub", "ref", "return", "self", "static", "struct", "super", | 70 | "match", "mod", "move", "mut", "pub", "ref", "return", "self", "static", "struct", "super", |
71 | "trait", "true", "try", "type", "unsafe", "use", "where", "while", | 71 | "trait", "true", "try", "type", "unsafe", "use", "where", "while", |
72 | ], | 72 | ], |
73 | contextual_keywords: &["auto", "default", "existential", "union"], | 73 | contextual_keywords: &["auto", "default", "existential", "union", "raw"], |
74 | literals: &[ | 74 | literals: &[ |
75 | "INT_NUMBER", | 75 | "INT_NUMBER", |
76 | "FLOAT_NUMBER", | 76 | "FLOAT_NUMBER", |
@@ -297,235 +297,311 @@ macro_rules! ast_enums { | |||
297 | 297 | ||
298 | pub(crate) const AST_SRC: AstSrc = AstSrc { | 298 | pub(crate) const AST_SRC: AstSrc = AstSrc { |
299 | nodes: &ast_nodes! { | 299 | nodes: &ast_nodes! { |
300 | struct SourceFile: ModuleItemOwner, FnDefOwner { | 300 | struct SourceFile: ModuleItemOwner, FnDefOwner, AttrsOwner { |
301 | modules: [Module], | 301 | modules: [Module], |
302 | } | 302 | } |
303 | 303 | ||
304 | struct FnDef: VisibilityOwner, NameOwner, TypeParamsOwner, DocCommentsOwner, AttrsOwner { | 304 | struct FnDef: VisibilityOwner, NameOwner, TypeParamsOwner, DocCommentsOwner, AttrsOwner { |
305 | Abi, | ||
306 | ConstKw, | ||
307 | DefaultKw, | ||
308 | AsyncKw, | ||
309 | UnsafeKw, | ||
310 | FnKw, | ||
305 | ParamList, | 311 | ParamList, |
306 | RetType, | 312 | RetType, |
307 | body: BlockExpr, | 313 | body: BlockExpr, |
314 | Semi | ||
308 | } | 315 | } |
309 | 316 | ||
310 | struct RetType { TypeRef } | 317 | struct RetType { ThinArrow, TypeRef } |
311 | 318 | ||
312 | struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { | 319 | struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { |
320 | StructKw, | ||
321 | FieldDefList, | ||
322 | Semi | ||
313 | } | 323 | } |
314 | 324 | ||
315 | struct UnionDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { | 325 | struct UnionDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { |
326 | UnionKw, | ||
316 | RecordFieldDefList, | 327 | RecordFieldDefList, |
317 | } | 328 | } |
318 | 329 | ||
319 | struct RecordFieldDefList { fields: [RecordFieldDef] } | 330 | struct RecordFieldDefList { LCurly, fields: [RecordFieldDef], RCurly } |
320 | struct RecordFieldDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { } | 331 | struct RecordFieldDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { } |
321 | 332 | ||
322 | struct TupleFieldDefList { fields: [TupleFieldDef] } | 333 | struct TupleFieldDefList { LParen, fields: [TupleFieldDef], RParen } |
323 | struct TupleFieldDef: VisibilityOwner, AttrsOwner { | 334 | struct TupleFieldDef: VisibilityOwner, AttrsOwner { |
324 | TypeRef, | 335 | TypeRef, |
325 | } | 336 | } |
326 | 337 | ||
327 | struct EnumDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { | 338 | struct EnumDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { |
339 | EnumKw, | ||
328 | variant_list: EnumVariantList, | 340 | variant_list: EnumVariantList, |
329 | } | 341 | } |
330 | struct EnumVariantList { | 342 | struct EnumVariantList { |
343 | LCurly, | ||
331 | variants: [EnumVariant], | 344 | variants: [EnumVariant], |
345 | RCurly | ||
332 | } | 346 | } |
333 | struct EnumVariant: NameOwner, DocCommentsOwner, AttrsOwner { | 347 | struct EnumVariant: VisibilityOwner, NameOwner, DocCommentsOwner, AttrsOwner { |
348 | FieldDefList, | ||
349 | Eq, | ||
334 | Expr | 350 | Expr |
335 | } | 351 | } |
336 | 352 | ||
337 | struct TraitDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeParamsOwner, TypeBoundsOwner { | 353 | struct TraitDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeParamsOwner, TypeBoundsOwner { |
354 | UnsafeKw, | ||
355 | AutoKw, | ||
356 | TraitKw, | ||
338 | ItemList, | 357 | ItemList, |
339 | } | 358 | } |
340 | 359 | ||
341 | struct Module: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner { | 360 | struct Module: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner { |
361 | ModKw, | ||
342 | ItemList, | 362 | ItemList, |
363 | Semi | ||
343 | } | 364 | } |
344 | 365 | ||
345 | struct ItemList: FnDefOwner, ModuleItemOwner { | 366 | struct ItemList: FnDefOwner, ModuleItemOwner { |
367 | LCurly, | ||
346 | impl_items: [ImplItem], | 368 | impl_items: [ImplItem], |
369 | RCurly | ||
347 | } | 370 | } |
348 | 371 | ||
349 | struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { | 372 | struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { |
373 | DefaultKw, | ||
374 | ConstKw, | ||
375 | Eq, | ||
350 | body: Expr, | 376 | body: Expr, |
377 | Semi | ||
351 | } | 378 | } |
352 | 379 | ||
353 | struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { | 380 | struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { |
381 | StaticKw, | ||
382 | MutKw, | ||
383 | Eq, | ||
354 | body: Expr, | 384 | body: Expr, |
385 | Semi | ||
355 | } | 386 | } |
356 | 387 | ||
357 | struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner { | 388 | struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner { |
389 | DefaultKw, | ||
390 | TypeKw, | ||
391 | Eq, | ||
358 | TypeRef, | 392 | TypeRef, |
393 | Semi | ||
359 | } | 394 | } |
360 | 395 | ||
361 | struct ImplDef: TypeParamsOwner, AttrsOwner { | 396 | struct ImplDef: TypeParamsOwner, AttrsOwner { |
397 | DefaultKw, | ||
398 | ConstKw, | ||
399 | UnsafeKw, | ||
400 | ImplKw, | ||
401 | Excl, | ||
402 | ForKw, | ||
362 | ItemList, | 403 | ItemList, |
363 | } | 404 | } |
364 | 405 | ||
365 | struct ParenType { TypeRef } | 406 | struct ParenType { LParen, TypeRef, RParen } |
366 | struct TupleType { fields: [TypeRef] } | 407 | struct TupleType { LParen, fields: [TypeRef], RParen } |
367 | struct NeverType { } | 408 | struct NeverType { Excl } |
368 | struct PathType { Path } | 409 | struct PathType { Path } |
369 | struct PointerType { TypeRef } | 410 | struct PointerType { Star, ConstKw, TypeRef } |
370 | struct ArrayType { TypeRef, Expr } | 411 | struct ArrayType { LBrack, TypeRef, Semi, Expr, RBrack } |
371 | struct SliceType { TypeRef } | 412 | struct SliceType { LBrack, TypeRef, RBrack } |
372 | struct ReferenceType { TypeRef } | 413 | struct ReferenceType { Amp, Lifetime, MutKw, TypeRef } |
373 | struct PlaceholderType { } | 414 | struct PlaceholderType { Underscore } |
374 | struct FnPointerType { ParamList, RetType } | 415 | struct FnPointerType { Abi, UnsafeKw, FnKw, ParamList, RetType } |
375 | struct ForType { TypeRef } | 416 | struct ForType { ForKw, TypeParamList, TypeRef } |
376 | struct ImplTraitType: TypeBoundsOwner {} | 417 | struct ImplTraitType: TypeBoundsOwner { ImplKw } |
377 | struct DynTraitType: TypeBoundsOwner {} | 418 | struct DynTraitType: TypeBoundsOwner { DynKw } |
378 | 419 | ||
379 | struct TupleExpr { exprs: [Expr] } | 420 | struct TupleExpr: AttrsOwner { LParen, exprs: [Expr], RParen } |
380 | struct ArrayExpr { exprs: [Expr] } | 421 | struct ArrayExpr: AttrsOwner { LBrack, exprs: [Expr], Semi, RBrack } |
381 | struct ParenExpr { Expr } | 422 | struct ParenExpr: AttrsOwner { LParen, Expr, RParen } |
382 | struct PathExpr { Path } | 423 | struct PathExpr { Path } |
383 | struct LambdaExpr { | 424 | struct LambdaExpr: AttrsOwner { |
425 | StaticKw, | ||
426 | AsyncKw, | ||
427 | MoveKw, | ||
384 | ParamList, | 428 | ParamList, |
385 | RetType, | 429 | RetType, |
386 | body: Expr, | 430 | body: Expr, |
387 | } | 431 | } |
388 | struct IfExpr { Condition } | 432 | struct IfExpr: AttrsOwner { IfKw, Condition } |
389 | struct LoopExpr: LoopBodyOwner { } | 433 | struct LoopExpr: AttrsOwner, LoopBodyOwner { LoopKw } |
390 | struct TryBlockExpr { body: BlockExpr } | 434 | struct TryBlockExpr: AttrsOwner { TryKw, body: BlockExpr } |
391 | struct ForExpr: LoopBodyOwner { | 435 | struct ForExpr: AttrsOwner, LoopBodyOwner { |
436 | ForKw, | ||
392 | Pat, | 437 | Pat, |
438 | InKw, | ||
393 | iterable: Expr, | 439 | iterable: Expr, |
394 | } | 440 | } |
395 | struct WhileExpr: LoopBodyOwner { Condition } | 441 | struct WhileExpr: AttrsOwner, LoopBodyOwner { WhileKw, Condition } |
396 | struct ContinueExpr {} | 442 | struct ContinueExpr: AttrsOwner { ContinueKw, Lifetime } |
397 | struct BreakExpr { Expr } | 443 | struct BreakExpr: AttrsOwner { BreakKw, Lifetime, Expr } |
398 | struct Label {} | 444 | struct Label { Lifetime } |
399 | struct BlockExpr { Block } | 445 | struct BlockExpr: AttrsOwner { Label, UnsafeKw, Block } |
400 | struct ReturnExpr { Expr } | 446 | struct ReturnExpr: AttrsOwner { Expr } |
401 | struct CallExpr: ArgListOwner { Expr } | 447 | struct CallExpr: ArgListOwner { Expr } |
402 | struct MethodCallExpr: ArgListOwner { | 448 | struct MethodCallExpr: AttrsOwner, ArgListOwner { |
403 | Expr, NameRef, TypeArgList, | 449 | Expr, Dot, NameRef, TypeArgList, |
404 | } | 450 | } |
405 | struct IndexExpr {} | 451 | struct IndexExpr: AttrsOwner { LBrack, RBrack } |
406 | struct FieldExpr { Expr, NameRef } | 452 | struct FieldExpr: AttrsOwner { Expr, Dot, NameRef } |
407 | struct AwaitExpr { Expr } | 453 | struct AwaitExpr: AttrsOwner { Expr, Dot, AwaitKw } |
408 | struct TryExpr { Expr } | 454 | struct TryExpr: AttrsOwner { TryKw, Expr } |
409 | struct CastExpr { Expr, TypeRef } | 455 | struct CastExpr: AttrsOwner { Expr, AsKw, TypeRef } |
410 | struct RefExpr { Expr } | 456 | struct RefExpr: AttrsOwner { Amp, RawKw, MutKw, Expr } |
411 | struct PrefixExpr { Expr } | 457 | struct PrefixExpr: AttrsOwner { PrefixOp, Expr } |
412 | struct BoxExpr { Expr } | 458 | struct BoxExpr: AttrsOwner { BoxKw, Expr } |
413 | struct RangeExpr {} | 459 | struct RangeExpr: AttrsOwner { RangeOp } |
414 | struct BinExpr {} | 460 | struct BinExpr: AttrsOwner { BinOp } |
415 | struct Literal {} | 461 | struct Literal { LiteralToken } |
416 | 462 | ||
417 | struct MatchExpr { Expr, MatchArmList } | 463 | struct MatchExpr: AttrsOwner { MatchKw, Expr, MatchArmList } |
418 | struct MatchArmList: AttrsOwner { arms: [MatchArm] } | 464 | struct MatchArmList: AttrsOwner { LCurly, arms: [MatchArm], RCurly } |
419 | struct MatchArm: AttrsOwner { | 465 | struct MatchArm: AttrsOwner { |
420 | pat: Pat, | 466 | pat: Pat, |
421 | guard: MatchGuard, | 467 | guard: MatchGuard, |
468 | FatArrow, | ||
422 | Expr, | 469 | Expr, |
423 | } | 470 | } |
424 | struct MatchGuard { Expr } | 471 | struct MatchGuard { IfKw, Expr } |
425 | 472 | ||
426 | struct RecordLit { Path, RecordFieldList } | 473 | struct RecordLit { Path, RecordFieldList} |
427 | struct RecordFieldList { | 474 | struct RecordFieldList { |
475 | LCurly, | ||
428 | fields: [RecordField], | 476 | fields: [RecordField], |
477 | Dotdot, | ||
429 | spread: Expr, | 478 | spread: Expr, |
479 | RCurly | ||
430 | } | 480 | } |
431 | struct RecordField { NameRef, Expr } | 481 | struct RecordField: AttrsOwner { NameRef, Colon, Expr } |
432 | 482 | ||
433 | struct OrPat { pats: [Pat] } | 483 | struct OrPat { pats: [Pat] } |
434 | struct ParenPat { Pat } | 484 | struct ParenPat { LParen, Pat, RParen } |
435 | struct RefPat { Pat } | 485 | struct RefPat { Amp, MutKw, Pat } |
436 | struct BoxPat { Pat } | 486 | struct BoxPat { BoxKw, Pat } |
437 | struct BindPat: NameOwner { Pat } | 487 | struct BindPat: AttrsOwner, NameOwner { RefKw, MutKw, Pat } |
438 | struct PlaceholderPat { } | 488 | struct PlaceholderPat { Underscore } |
439 | struct DotDotPat { } | 489 | struct DotDotPat { Dotdot } |
440 | struct PathPat { Path } | 490 | struct PathPat { Path } |
441 | struct SlicePat { args: [Pat] } | 491 | struct SlicePat { LBrack, args: [Pat], RBrack } |
442 | struct RangePat {} | 492 | struct RangePat { RangeSeparator } |
443 | struct LiteralPat { Literal } | 493 | struct LiteralPat { Literal } |
444 | struct MacroPat { MacroCall } | 494 | struct MacroPat { MacroCall } |
445 | 495 | ||
446 | struct RecordPat { RecordFieldPatList, Path } | 496 | struct RecordPat { RecordFieldPatList, Path } |
447 | struct RecordFieldPatList { | 497 | struct RecordFieldPatList { |
498 | LCurly, | ||
499 | pats: [RecordInnerPat], | ||
448 | record_field_pats: [RecordFieldPat], | 500 | record_field_pats: [RecordFieldPat], |
449 | bind_pats: [BindPat], | 501 | bind_pats: [BindPat], |
502 | Dotdot, | ||
503 | RCurly | ||
450 | } | 504 | } |
451 | struct RecordFieldPat: NameOwner { Pat } | 505 | struct RecordFieldPat: AttrsOwner, NameOwner { Colon, Pat } |
452 | 506 | ||
453 | struct TupleStructPat { Path, args: [Pat] } | 507 | struct TupleStructPat { Path, LParen, args: [Pat], RParen } |
454 | struct TuplePat { args: [Pat] } | 508 | struct TuplePat { LParen, args: [Pat], RParen } |
455 | 509 | ||
456 | struct Visibility {} | 510 | struct Visibility { PubKw, SuperKw, SelfKw, CrateKw } |
457 | struct Name {} | 511 | struct Name { Ident } |
458 | struct NameRef {} | 512 | struct NameRef { NameRefToken } |
459 | 513 | ||
460 | struct MacroCall: NameOwner, AttrsOwner,DocCommentsOwner { | 514 | struct MacroCall: NameOwner, AttrsOwner,DocCommentsOwner { |
461 | TokenTree, Path | 515 | Path, Excl, TokenTree, Semi |
462 | } | 516 | } |
463 | struct Attr { Path, input: AttrInput } | 517 | struct Attr { Pound, Excl, LBrack, Path, Eq, input: AttrInput, RBrack } |
464 | struct TokenTree {} | 518 | struct TokenTree {} |
465 | struct TypeParamList { | 519 | struct TypeParamList { |
520 | LAngle, | ||
521 | generic_params: [GenericParam], | ||
466 | type_params: [TypeParam], | 522 | type_params: [TypeParam], |
467 | lifetime_params: [LifetimeParam], | 523 | lifetime_params: [LifetimeParam], |
524 | const_params: [ConstParam], | ||
525 | RAngle | ||
468 | } | 526 | } |
469 | struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner { | 527 | struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner { |
528 | Eq, | ||
470 | default_type: TypeRef, | 529 | default_type: TypeRef, |
471 | } | 530 | } |
472 | struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner { | 531 | struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner { |
532 | Eq, | ||
473 | default_val: Expr, | 533 | default_val: Expr, |
474 | } | 534 | } |
475 | struct LifetimeParam: AttrsOwner { } | 535 | struct LifetimeParam: AttrsOwner { Lifetime} |
476 | struct TypeBound { TypeRef} | 536 | struct TypeBound { Lifetime, /* Question, */ ConstKw, /* Question, */ TypeRef} |
477 | struct TypeBoundList { bounds: [TypeBound] } | 537 | struct TypeBoundList { bounds: [TypeBound] } |
478 | struct WherePred: TypeBoundsOwner { TypeRef } | 538 | struct WherePred: TypeBoundsOwner { Lifetime, TypeRef } |
479 | struct WhereClause { predicates: [WherePred] } | 539 | struct WhereClause { WhereKw, predicates: [WherePred] } |
480 | struct ExprStmt { Expr } | 540 | struct Abi { String } |
481 | struct LetStmt: TypeAscriptionOwner { | 541 | struct ExprStmt: AttrsOwner { Expr, Semi } |
542 | struct LetStmt: AttrsOwner, TypeAscriptionOwner { | ||
543 | LetKw, | ||
482 | Pat, | 544 | Pat, |
545 | Eq, | ||
483 | initializer: Expr, | 546 | initializer: Expr, |
484 | } | 547 | } |
485 | struct Condition { Pat, Expr } | 548 | struct Condition { LetKw, Pat, Eq, Expr } |
486 | struct Block: AttrsOwner, ModuleItemOwner { | 549 | struct Block: AttrsOwner, ModuleItemOwner { |
550 | LCurly, | ||
487 | statements: [Stmt], | 551 | statements: [Stmt], |
552 | statements_or_semi: [StmtOrSemi], | ||
488 | Expr, | 553 | Expr, |
554 | RCurly, | ||
489 | } | 555 | } |
490 | struct ParamList { | 556 | struct ParamList { |
557 | LParen, | ||
491 | SelfParam, | 558 | SelfParam, |
492 | params: [Param], | 559 | params: [Param], |
560 | RParen | ||
493 | } | 561 | } |
494 | struct SelfParam: TypeAscriptionOwner, AttrsOwner { } | 562 | struct SelfParam: TypeAscriptionOwner, AttrsOwner { Amp, Lifetime, SelfKw } |
495 | struct Param: TypeAscriptionOwner, AttrsOwner { | 563 | struct Param: TypeAscriptionOwner, AttrsOwner { |
496 | Pat, | 564 | Pat, |
565 | Dotdotdot | ||
497 | } | 566 | } |
498 | struct UseItem: AttrsOwner, VisibilityOwner { | 567 | struct UseItem: AttrsOwner, VisibilityOwner { |
568 | UseKw, | ||
499 | UseTree, | 569 | UseTree, |
500 | } | 570 | } |
501 | struct UseTree { | 571 | struct UseTree { |
502 | Path, UseTreeList, Alias | 572 | Path, Star, UseTreeList, Alias |
503 | } | 573 | } |
504 | struct Alias: NameOwner { } | 574 | struct Alias: NameOwner { AsKw } |
505 | struct UseTreeList { use_trees: [UseTree] } | 575 | struct UseTreeList { LCurly, use_trees: [UseTree], RCurly } |
506 | struct ExternCrateItem: AttrsOwner, VisibilityOwner { | 576 | struct ExternCrateItem: AttrsOwner, VisibilityOwner { |
507 | NameRef, Alias, | 577 | ExternKw, CrateKw, NameRef, Alias, |
508 | } | 578 | } |
509 | struct ArgList { | 579 | struct ArgList { |
580 | LParen, | ||
510 | args: [Expr], | 581 | args: [Expr], |
582 | RParen | ||
511 | } | 583 | } |
512 | struct Path { | 584 | struct Path { |
513 | segment: PathSegment, | 585 | segment: PathSegment, |
514 | qualifier: Path, | 586 | qualifier: Path, |
515 | } | 587 | } |
516 | struct PathSegment { | 588 | struct PathSegment { |
517 | NameRef, TypeArgList, ParamList, RetType, PathType, | 589 | Coloncolon, LAngle, NameRef, TypeArgList, ParamList, RetType, PathType, RAngle |
518 | } | 590 | } |
519 | struct TypeArgList { | 591 | struct TypeArgList { |
592 | Coloncolon, | ||
593 | LAngle, | ||
594 | generic_args: [GenericArg], | ||
520 | type_args: [TypeArg], | 595 | type_args: [TypeArg], |
521 | lifetime_args: [LifetimeArg], | 596 | lifetime_args: [LifetimeArg], |
522 | assoc_type_args: [AssocTypeArg], | 597 | assoc_type_args: [AssocTypeArg], |
523 | const_arg: [ConstArg], | 598 | const_args: [ConstArg], |
599 | RAngle | ||
524 | } | 600 | } |
525 | struct TypeArg { TypeRef } | 601 | struct TypeArg { TypeRef } |
526 | struct AssocTypeArg { NameRef, TypeRef } | 602 | struct AssocTypeArg : TypeBoundsOwner { NameRef, Eq, TypeRef } |
527 | struct LifetimeArg {} | 603 | struct LifetimeArg { Lifetime } |
528 | struct ConstArg { Literal, BlockExpr } | 604 | struct ConstArg { Literal, Eq, BlockExpr } |
529 | 605 | ||
530 | struct MacroItems: ModuleItemOwner, FnDefOwner { } | 606 | struct MacroItems: ModuleItemOwner, FnDefOwner { } |
531 | 607 | ||
@@ -533,12 +609,44 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
533 | statements: [Stmt], | 609 | statements: [Stmt], |
534 | Expr, | 610 | Expr, |
535 | } | 611 | } |
612 | |||
613 | struct ExternItemList: FnDefOwner, ModuleItemOwner { | ||
614 | LCurly, | ||
615 | extern_items: [ExternItem], | ||
616 | RCurly | ||
617 | } | ||
618 | |||
619 | struct ExternBlock { | ||
620 | Abi, | ||
621 | ExternItemList | ||
622 | } | ||
623 | |||
624 | struct MetaItem { | ||
625 | Path, Eq, AttrInput, nested_meta_items: [MetaItem] | ||
626 | } | ||
627 | |||
628 | struct MacroDef { | ||
629 | Name, TokenTree | ||
630 | } | ||
536 | }, | 631 | }, |
537 | enums: &ast_enums! { | 632 | enums: &ast_enums! { |
538 | enum NominalDef: NameOwner, TypeParamsOwner, AttrsOwner { | 633 | enum NominalDef: NameOwner, TypeParamsOwner, AttrsOwner { |
539 | StructDef, EnumDef, UnionDef, | 634 | StructDef, EnumDef, UnionDef, |
540 | } | 635 | } |
541 | 636 | ||
637 | enum GenericParam { | ||
638 | LifetimeParam, | ||
639 | TypeParam, | ||
640 | ConstParam | ||
641 | } | ||
642 | |||
643 | enum GenericArg { | ||
644 | LifetimeArg, | ||
645 | TypeArg, | ||
646 | ConstArg, | ||
647 | AssocTypeArg | ||
648 | } | ||
649 | |||
542 | enum TypeRef { | 650 | enum TypeRef { |
543 | ParenType, | 651 | ParenType, |
544 | TupleType, | 652 | TupleType, |
@@ -555,7 +663,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
555 | DynTraitType, | 663 | DynTraitType, |
556 | } | 664 | } |
557 | 665 | ||
558 | enum ModuleItem: AttrsOwner, VisibilityOwner { | 666 | enum ModuleItem: NameOwner, AttrsOwner, VisibilityOwner { |
559 | StructDef, | 667 | StructDef, |
560 | UnionDef, | 668 | UnionDef, |
561 | EnumDef, | 669 | EnumDef, |
@@ -569,13 +677,20 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
569 | StaticDef, | 677 | StaticDef, |
570 | Module, | 678 | Module, |
571 | MacroCall, | 679 | MacroCall, |
680 | ExternBlock | ||
572 | } | 681 | } |
573 | 682 | ||
574 | enum ImplItem: AttrsOwner { | 683 | /* impl blocks can also contain MacroCall */ |
575 | FnDef, TypeAliasDef, ConstDef, | 684 | enum ImplItem: NameOwner, AttrsOwner { |
685 | FnDef, TypeAliasDef, ConstDef | ||
576 | } | 686 | } |
577 | 687 | ||
578 | enum Expr { | 688 | /* extern blocks can also contain MacroCall */ |
689 | enum ExternItem: NameOwner, AttrsOwner, VisibilityOwner { | ||
690 | FnDef, StaticDef | ||
691 | } | ||
692 | |||
693 | enum Expr: AttrsOwner { | ||
579 | TupleExpr, | 694 | TupleExpr, |
580 | ArrayExpr, | 695 | ArrayExpr, |
581 | ParenExpr, | 696 | ParenExpr, |
@@ -627,7 +742,93 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
627 | MacroPat, | 742 | MacroPat, |
628 | } | 743 | } |
629 | 744 | ||
745 | enum RecordInnerPat { | ||
746 | RecordFieldPat, | ||
747 | BindPat | ||
748 | } | ||
749 | |||
630 | enum AttrInput { Literal, TokenTree } | 750 | enum AttrInput { Literal, TokenTree } |
631 | enum Stmt { ExprStmt, LetStmt } | 751 | enum Stmt { |
752 | ModuleItem, | ||
753 | LetStmt, | ||
754 | ExprStmt, | ||
755 | // macro calls are parsed as expression statements */ | ||
756 | } | ||
757 | enum StmtOrSemi {Stmt, Semi} | ||
758 | |||
759 | enum LeftDelimiter { LParen, LBrack, LCurly } | ||
760 | enum RightDelimiter { RParen, RBrack, RCurly } | ||
761 | enum RangeSeparator { Dotdot, Dotdotdot, Dotdoteq} | ||
762 | |||
763 | enum BinOp { | ||
764 | Pipepipe, | ||
765 | Ampamp, | ||
766 | Eqeq, | ||
767 | Neq, | ||
768 | Lteq, | ||
769 | Gteq, | ||
770 | LAngle, | ||
771 | RAngle, | ||
772 | Plus, | ||
773 | Star, | ||
774 | Minus, | ||
775 | Slash, | ||
776 | Percent, | ||
777 | Shl, | ||
778 | Shr, | ||
779 | Caret, | ||
780 | Pipe, | ||
781 | Amp, | ||
782 | Eq, | ||
783 | Pluseq, | ||
784 | Slasheq, | ||
785 | Stareq, | ||
786 | Percenteq, | ||
787 | Shreq, | ||
788 | Shleq, | ||
789 | Minuseq, | ||
790 | Pipeeq, | ||
791 | Ampeq, | ||
792 | Careteq, | ||
793 | } | ||
794 | |||
795 | enum PrefixOp { | ||
796 | Minus, | ||
797 | Excl, | ||
798 | Star | ||
799 | } | ||
800 | |||
801 | enum RangeOp { | ||
802 | Dotdot, | ||
803 | Dotdoteq | ||
804 | } | ||
805 | |||
806 | enum LiteralToken { | ||
807 | IntNumber, | ||
808 | FloatNumber, | ||
809 | String, | ||
810 | RawString, | ||
811 | TrueKw, | ||
812 | FalseKw, | ||
813 | ByteString, | ||
814 | RawByteString, | ||
815 | Char, | ||
816 | Byte | ||
817 | } | ||
818 | |||
819 | enum NameRefToken { | ||
820 | Ident, | ||
821 | IntNumber | ||
822 | } | ||
823 | |||
824 | enum FieldDefList { | ||
825 | RecordFieldDefList, | ||
826 | TupleFieldDefList, | ||
827 | } | ||
828 | |||
829 | enum AttrOrComment { | ||
830 | Attr, | ||
831 | Comment | ||
832 | } | ||
632 | }, | 833 | }, |
633 | }; | 834 | }; |