diff options
Diffstat (limited to 'crates/ra_parser/src/grammar.rs')
-rw-r--r-- | crates/ra_parser/src/grammar.rs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index e1762633e..67eae749d 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs | |||
@@ -95,6 +95,37 @@ pub(crate) fn stmt(p: &mut Parser, with_semi: bool) { | |||
95 | expressions::stmt(p, with_semi) | 95 | expressions::stmt(p, with_semi) |
96 | } | 96 | } |
97 | 97 | ||
98 | pub(crate) fn block(p: &mut Parser) { | ||
99 | expressions::block(p); | ||
100 | } | ||
101 | |||
102 | // Parse a meta item , which excluded [], e.g : #[ MetaItem ] | ||
103 | pub(crate) fn meta_item(p: &mut Parser) { | ||
104 | fn is_delimiter(p: &mut Parser) -> bool { | ||
105 | match p.current() { | ||
106 | L_CURLY | L_PAREN | L_BRACK => true, | ||
107 | _ => false, | ||
108 | } | ||
109 | } | ||
110 | |||
111 | if is_delimiter(p) { | ||
112 | items::token_tree(p); | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | let m = p.start(); | ||
117 | while !p.at(EOF) { | ||
118 | if is_delimiter(p) { | ||
119 | items::token_tree(p); | ||
120 | break; | ||
121 | } else { | ||
122 | p.bump(); | ||
123 | } | ||
124 | } | ||
125 | |||
126 | m.complete(p, TOKEN_TREE); | ||
127 | } | ||
128 | |||
98 | pub(crate) fn item(p: &mut Parser) { | 129 | pub(crate) fn item(p: &mut Parser) { |
99 | items::item_or_macro(p, true, items::ItemFlavor::Mod) | 130 | items::item_or_macro(p, true, items::ItemFlavor::Mod) |
100 | } | 131 | } |
@@ -136,7 +167,7 @@ impl BlockLike { | |||
136 | } | 167 | } |
137 | } | 168 | } |
138 | 169 | ||
139 | fn opt_visibility(p: &mut Parser) -> bool { | 170 | pub(crate) fn opt_visibility(p: &mut Parser) -> bool { |
140 | match p.current() { | 171 | match p.current() { |
141 | PUB_KW => { | 172 | PUB_KW => { |
142 | let m = p.start(); | 173 | let m = p.start(); |