nodes for blocks

This commit is contained in:
Aleksey Kladov
2018-08-24 19:27:30 +03:00
parent 4d29300396
commit 7edab6ae6b
122 changed files with 1743 additions and 1535 deletions

View File

@@ -194,8 +194,8 @@ fn items_without_modifiers(p: &mut Parser) -> Option<SyntaxKind> {
// extern {}
EXTERN_KW if la == L_CURLY || ((la == STRING || la == RAW_STRING) && p.nth(2) == L_CURLY) => {
abi(p);
extern_block(p);
EXTERN_BLOCK_EXPR
extern_item_list(p);
EXTERN_BLOCK
}
_ => return None,
};
@@ -212,10 +212,12 @@ fn extern_crate_item(p: &mut Parser) {
p.expect(SEMI);
}
fn extern_block(p: &mut Parser) {
fn extern_item_list(p: &mut Parser) {
assert!(p.at(L_CURLY));
let m = p.start();
p.bump();
p.expect(R_CURLY);
m.complete(p, EXTERN_ITEM_LIST);
}
fn function(p: &mut Parser, flavor: ItemFlavor) {
@@ -284,14 +286,22 @@ fn mod_item(p: &mut Parser) {
p.bump();
name(p);
if !p.eat(SEMI) {
if p.expect(L_CURLY) {
mod_contents(p, true);
p.expect(R_CURLY);
}
if p.at(L_CURLY) {
mod_item_list(p);
} else if !p.eat(SEMI) {
p.error("expected `;` or `{`");
}
}
fn mod_item_list(p: &mut Parser) {
assert!(p.at(L_CURLY));
let m = p.start();
p.bump();
mod_contents(p, true);
p.expect(R_CURLY);
m.complete(p, ITEM_LIST);
}
fn macro_call(p: &mut Parser) -> BlockLike {
assert!(paths::is_path_start(p));
paths::use_path(p);