Support crate vis

This commit is contained in:
Aleksey Kladov 2018-08-08 22:09:47 +03:00
parent a5dc5f1b5c
commit 8c598d3d8a
3 changed files with 51 additions and 23 deletions

View File

@ -55,8 +55,9 @@ fn is_block(self) -> bool { self == BlockLike::Block }
}
fn visibility(p: &mut Parser) {
if p.at(PUB_KW) {
let vis = p.start();
match p.current() {
PUB_KW => {
let m = p.start();
p.bump();
if p.at(L_PAREN) {
match p.nth(1) {
@ -79,10 +80,18 @@ fn visibility(p: &mut Parser) {
_ => (),
}
}
vis.complete(p, VISIBILITY);
m.complete(p, VISIBILITY);
}
// test crate_keyword_vis
// crate fn main() { }
CRATE_KW => {
let m = p.start();
p.bump();
m.complete(p, VISIBILITY);
}
_ => (),
}
}
fn alias(p: &mut Parser) -> bool {
if p.at(AS_KW) {
let alias = p.start();

View File

@ -0,0 +1 @@
crate fn main() { }

View File

@ -0,0 +1,18 @@
FILE@[0; 20)
FN_ITEM@[0; 19)
VISIBILITY@[0; 5)
CRATE_KW@[0; 5)
WHITESPACE@[5; 6)
FN_KW@[6; 8)
WHITESPACE@[8; 9)
NAME@[9; 13)
IDENT@[9; 13) "main"
PARAM_LIST@[13; 15)
L_PAREN@[13; 14)
R_PAREN@[14; 15)
WHITESPACE@[15; 16)
BLOCK_EXPR@[16; 19)
L_CURLY@[16; 17)
WHITESPACE@[17; 18)
R_CURLY@[18; 19)
WHITESPACE@[19; 20)