aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/grammar
diff options
context:
space:
mode:
authordarksv <[email protected]>2018-09-10 19:14:09 +0100
committerdarksv <[email protected]>2018-09-10 19:14:09 +0100
commit64d07c1bd475c4945db8d7cd1fa1a61e467b079b (patch)
tree3184113f1d146e887eae6d667ff9c16b2138160b /crates/libsyntax2/src/grammar
parent4f647096665b2ca3725ba1f7415a21fbc46044bb (diff)
Implement reparsing for remaining blocks
Diffstat (limited to 'crates/libsyntax2/src/grammar')
-rw-r--r--crates/libsyntax2/src/grammar/expressions/atom.rs2
-rw-r--r--crates/libsyntax2/src/grammar/expressions/mod.rs3
-rw-r--r--crates/libsyntax2/src/grammar/items/mod.rs15
-rw-r--r--crates/libsyntax2/src/grammar/items/nominal.rs2
-rw-r--r--crates/libsyntax2/src/grammar/items/traits.rs4
-rw-r--r--crates/libsyntax2/src/grammar/items/use_item.rs2
-rw-r--r--crates/libsyntax2/src/grammar/mod.rs17
7 files changed, 32 insertions, 13 deletions
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 {
287 m.complete(p, MATCH_EXPR) 287 m.complete(p, MATCH_EXPR)
288} 288}
289 289
290fn match_arm_list(p: &mut Parser) { 290pub(crate) fn match_arm_list(p: &mut Parser) {
291 assert!(p.at(L_CURLY)); 291 assert!(p.at(L_CURLY));
292 let m = p.start(); 292 let m = p.start();
293 p.eat(L_CURLY); 293 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;
2 2
3use super::*; 3use super::*;
4pub(super) use self::atom::{literal, LITERAL_FIRST}; 4pub(super) use self::atom::{literal, LITERAL_FIRST};
5pub(crate) use self::atom::match_arm_list;
5 6
6const EXPR_FIRST: TokenSet = LHS_FIRST; 7const EXPR_FIRST: TokenSet = LHS_FIRST;
7 8
@@ -419,7 +420,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker {
419// S { x, y: 32, }; 420// S { x, y: 32, };
420// S { x, y: 32, ..Default::default() }; 421// S { x, y: 32, ..Default::default() };
421// } 422// }
422fn named_field_list(p: &mut Parser) { 423pub(crate) fn named_field_list(p: &mut Parser) {
423 assert!(p.at(L_CURLY)); 424 assert!(p.at(L_CURLY));
424 let m = p.start(); 425 let m = p.start();
425 p.bump(); 426 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;
5mod use_item; 5mod use_item;
6 6
7use super::*; 7use super::*;
8pub(crate) use self::nominal::named_field_def_list; 8pub(crate) use self::{
9 expressions::{named_field_list, match_arm_list},
10 nominal::{enum_variant_list, named_field_def_list},
11 traits::{trait_item_list, impl_item_list},
12 use_item::use_tree_list,
13};
9 14
10// test mod_contents 15// test mod_contents
11// fn foo() {} 16// fn foo() {}
@@ -223,7 +228,7 @@ fn extern_crate_item(p: &mut Parser) {
223 p.expect(SEMI); 228 p.expect(SEMI);
224} 229}
225 230
226fn extern_item_list(p: &mut Parser) { 231pub(crate) fn extern_item_list(p: &mut Parser) {
227 assert!(p.at(L_CURLY)); 232 assert!(p.at(L_CURLY));
228 let m = p.start(); 233 let m = p.start();
229 p.bump(); 234 p.bump();
@@ -295,7 +300,7 @@ fn type_def(p: &mut Parser) {
295 p.expect(SEMI); 300 p.expect(SEMI);
296} 301}
297 302
298fn mod_item(p: &mut Parser) { 303pub(crate) fn mod_item(p: &mut Parser) {
299 assert!(p.at(MOD_KW)); 304 assert!(p.at(MOD_KW));
300 p.bump(); 305 p.bump();
301 306
@@ -307,7 +312,7 @@ fn mod_item(p: &mut Parser) {
307 } 312 }
308} 313}
309 314
310fn mod_item_list(p: &mut Parser) { 315pub(crate) fn mod_item_list(p: &mut Parser) {
311 assert!(p.at(L_CURLY)); 316 assert!(p.at(L_CURLY));
312 let m = p.start(); 317 let m = p.start();
313 p.bump(); 318 p.bump();
@@ -343,7 +348,7 @@ pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
343 flavor 348 flavor
344} 349}
345 350
346pub(super) fn token_tree(p: &mut Parser) { 351pub(crate) fn token_tree(p: &mut Parser) {
347 let closing_paren_kind = match p.current() { 352 let closing_paren_kind = match p.current() {
348 L_CURLY => R_CURLY, 353 L_CURLY => R_CURLY,
349 L_PAREN => R_PAREN, 354 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) {
51 } 51 }
52} 52}
53 53
54fn enum_variant_list(p: &mut Parser) { 54pub(crate) fn enum_variant_list(p: &mut Parser) {
55 assert!(p.at(L_CURLY)); 55 assert!(p.at(L_CURLY));
56 let m = p.start(); 56 let m = p.start();
57 p.bump(); 57 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) {
25// fn foo() {} 25// fn foo() {}
26// fn bar(&self); 26// fn bar(&self);
27// } 27// }
28fn trait_item_list(p: &mut Parser) { 28pub(crate) fn trait_item_list(p: &mut Parser) {
29 assert!(p.at(L_CURLY)); 29 assert!(p.at(L_CURLY));
30 let m = p.start(); 30 let m = p.start();
31 p.bump(); 31 p.bump();
@@ -74,7 +74,7 @@ pub(super) fn impl_item(p: &mut Parser) {
74// fn foo() {} 74// fn foo() {}
75// fn bar(&self) {} 75// fn bar(&self) {}
76// } 76// }
77fn impl_item_list(p: &mut Parser) { 77pub(crate) fn impl_item_list(p: &mut Parser) {
78 assert!(p.at(L_CURLY)); 78 assert!(p.at(L_CURLY));
79 let m = p.start(); 79 let m = p.start();
80 p.bump(); 80 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) {
53 m.complete(p, USE_TREE); 53 m.complete(p, USE_TREE);
54} 54}
55 55
56fn use_tree_list(p: &mut Parser) { 56pub(crate) fn use_tree_list(p: &mut Parser) {
57 assert!(p.at(L_CURLY)); 57 assert!(p.at(L_CURLY));
58 let m = p.start(); 58 let m = p.start();
59 p.bump(); 59 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 {
37 SyntaxKind::{self, *}, 37 SyntaxKind::{self, *},
38}; 38};
39pub(crate) use self::{ 39pub(crate) use self::{
40 expressions::block, 40 expressions::{
41 items::named_field_def_list, 41 block,
42 },
43 items::{
44 enum_variant_list,
45 extern_item_list,
46 impl_item_list,
47 match_arm_list,
48 mod_item_list,
49 named_field_def_list,
50 named_field_list,
51 token_tree,
52 trait_item_list,
53 use_tree_list,
54 },
42}; 55};
43 56
44pub(crate) fn root(p: &mut Parser) { 57pub(crate) fn root(p: &mut Parser) {