From 64d07c1bd475c4945db8d7cd1fa1a61e467b079b Mon Sep 17 00:00:00 2001 From: darksv Date: Mon, 10 Sep 2018 20:14:09 +0200 Subject: Implement reparsing for remaining blocks --- crates/libsyntax2/src/grammar/expressions/atom.rs | 2 +- crates/libsyntax2/src/grammar/expressions/mod.rs | 3 ++- crates/libsyntax2/src/grammar/items/mod.rs | 15 ++++++++++----- crates/libsyntax2/src/grammar/items/nominal.rs | 2 +- crates/libsyntax2/src/grammar/items/traits.rs | 4 ++-- crates/libsyntax2/src/grammar/items/use_item.rs | 2 +- crates/libsyntax2/src/grammar/mod.rs | 17 +++++++++++++++-- 7 files changed, 32 insertions(+), 13 deletions(-) (limited to 'crates/libsyntax2/src/grammar') diff --git a/crates/libsyntax2/src/grammar/expressions/atom.rs b/crates/libsyntax2/src/grammar/expressions/atom.rs index 8335c700f..f01df56bc 100644 --- a/crates/libsyntax2/src/grammar/expressions/atom.rs +++ b/crates/libsyntax2/src/grammar/expressions/atom.rs @@ -287,7 +287,7 @@ fn match_expr(p: &mut Parser) -> CompletedMarker { m.complete(p, MATCH_EXPR) } -fn match_arm_list(p: &mut Parser) { +pub(crate) fn match_arm_list(p: &mut Parser) { assert!(p.at(L_CURLY)); let m = p.start(); p.eat(L_CURLY); diff --git a/crates/libsyntax2/src/grammar/expressions/mod.rs b/crates/libsyntax2/src/grammar/expressions/mod.rs index d5ee91ad8..20e0fa328 100644 --- a/crates/libsyntax2/src/grammar/expressions/mod.rs +++ b/crates/libsyntax2/src/grammar/expressions/mod.rs @@ -2,6 +2,7 @@ mod atom; use super::*; pub(super) use self::atom::{literal, LITERAL_FIRST}; +pub(crate) use self::atom::match_arm_list; const EXPR_FIRST: TokenSet = LHS_FIRST; @@ -419,7 +420,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker { // S { x, y: 32, }; // S { x, y: 32, ..Default::default() }; // } -fn named_field_list(p: &mut Parser) { +pub(crate) fn named_field_list(p: &mut Parser) { assert!(p.at(L_CURLY)); let m = p.start(); p.bump(); diff --git a/crates/libsyntax2/src/grammar/items/mod.rs b/crates/libsyntax2/src/grammar/items/mod.rs index 85d7fe770..8c19aa179 100644 --- a/crates/libsyntax2/src/grammar/items/mod.rs +++ b/crates/libsyntax2/src/grammar/items/mod.rs @@ -5,7 +5,12 @@ mod traits; mod use_item; use super::*; -pub(crate) use self::nominal::named_field_def_list; +pub(crate) use self::{ + expressions::{named_field_list, match_arm_list}, + nominal::{enum_variant_list, named_field_def_list}, + traits::{trait_item_list, impl_item_list}, + use_item::use_tree_list, +}; // test mod_contents // fn foo() {} @@ -223,7 +228,7 @@ fn extern_crate_item(p: &mut Parser) { p.expect(SEMI); } -fn extern_item_list(p: &mut Parser) { +pub(crate) fn extern_item_list(p: &mut Parser) { assert!(p.at(L_CURLY)); let m = p.start(); p.bump(); @@ -295,7 +300,7 @@ fn type_def(p: &mut Parser) { p.expect(SEMI); } -fn mod_item(p: &mut Parser) { +pub(crate) fn mod_item(p: &mut Parser) { assert!(p.at(MOD_KW)); p.bump(); @@ -307,7 +312,7 @@ fn mod_item(p: &mut Parser) { } } -fn mod_item_list(p: &mut Parser) { +pub(crate) fn mod_item_list(p: &mut Parser) { assert!(p.at(L_CURLY)); let m = p.start(); p.bump(); @@ -343,7 +348,7 @@ pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike { flavor } -pub(super) fn token_tree(p: &mut Parser) { +pub(crate) fn token_tree(p: &mut Parser) { let closing_paren_kind = match p.current() { L_CURLY => R_CURLY, L_PAREN => R_PAREN, diff --git a/crates/libsyntax2/src/grammar/items/nominal.rs b/crates/libsyntax2/src/grammar/items/nominal.rs index 3db5b24af..11c43e371 100644 --- a/crates/libsyntax2/src/grammar/items/nominal.rs +++ b/crates/libsyntax2/src/grammar/items/nominal.rs @@ -51,7 +51,7 @@ pub(super) fn enum_def(p: &mut Parser) { } } -fn enum_variant_list(p: &mut Parser) { +pub(crate) fn enum_variant_list(p: &mut Parser) { assert!(p.at(L_CURLY)); let m = p.start(); p.bump(); diff --git a/crates/libsyntax2/src/grammar/items/traits.rs b/crates/libsyntax2/src/grammar/items/traits.rs index 9d21d4d36..c21cfb1a9 100644 --- a/crates/libsyntax2/src/grammar/items/traits.rs +++ b/crates/libsyntax2/src/grammar/items/traits.rs @@ -25,7 +25,7 @@ pub(super) fn trait_def(p: &mut Parser) { // fn foo() {} // fn bar(&self); // } -fn trait_item_list(p: &mut Parser) { +pub(crate) fn trait_item_list(p: &mut Parser) { assert!(p.at(L_CURLY)); let m = p.start(); p.bump(); @@ -74,7 +74,7 @@ pub(super) fn impl_item(p: &mut Parser) { // fn foo() {} // fn bar(&self) {} // } -fn impl_item_list(p: &mut Parser) { +pub(crate) fn impl_item_list(p: &mut Parser) { assert!(p.at(L_CURLY)); let m = p.start(); p.bump(); diff --git a/crates/libsyntax2/src/grammar/items/use_item.rs b/crates/libsyntax2/src/grammar/items/use_item.rs index 2fbf2234a..1ee4349fd 100644 --- a/crates/libsyntax2/src/grammar/items/use_item.rs +++ b/crates/libsyntax2/src/grammar/items/use_item.rs @@ -53,7 +53,7 @@ fn use_tree(p: &mut Parser) { m.complete(p, USE_TREE); } -fn use_tree_list(p: &mut Parser) { +pub(crate) fn use_tree_list(p: &mut Parser) { assert!(p.at(L_CURLY)); let m = p.start(); p.bump(); diff --git a/crates/libsyntax2/src/grammar/mod.rs b/crates/libsyntax2/src/grammar/mod.rs index e19805b9d..2cb11dc1e 100644 --- a/crates/libsyntax2/src/grammar/mod.rs +++ b/crates/libsyntax2/src/grammar/mod.rs @@ -37,8 +37,21 @@ use { SyntaxKind::{self, *}, }; pub(crate) use self::{ - expressions::block, - items::named_field_def_list, + expressions::{ + block, + }, + items::{ + enum_variant_list, + extern_item_list, + impl_item_list, + match_arm_list, + mod_item_list, + named_field_def_list, + named_field_list, + token_tree, + trait_item_list, + use_tree_list, + }, }; pub(crate) fn root(p: &mut Parser) { -- cgit v1.2.3