mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
add TopEntryPoint
This commit is contained in:
parent
8e7fc7be65
commit
afffa096f6
8 changed files with 96 additions and 52 deletions
|
@ -83,43 +83,47 @@ pub(crate) mod entry {
|
|||
attributes::meta(p);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod top {
|
||||
use super::*;
|
||||
|
||||
pub(crate) fn source_file(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
p.eat(SHEBANG);
|
||||
items::mod_contents(p, false);
|
||||
m.complete(p, SOURCE_FILE);
|
||||
}
|
||||
|
||||
pub(crate) fn macro_stmts(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
|
||||
while !p.at(EOF) {
|
||||
if p.at(T![;]) {
|
||||
p.bump(T![;]);
|
||||
continue;
|
||||
}
|
||||
|
||||
expressions::stmt(p, expressions::StmtWithSemi::Optional, true);
|
||||
}
|
||||
|
||||
m.complete(p, MACRO_STMTS);
|
||||
}
|
||||
|
||||
pub(crate) fn macro_items(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
items::mod_contents(p, false);
|
||||
m.complete(p, MACRO_ITEMS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod entry_points {
|
||||
use super::*;
|
||||
|
||||
pub(crate) fn source_file(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
p.eat(SHEBANG);
|
||||
items::mod_contents(p, false);
|
||||
m.complete(p, SOURCE_FILE);
|
||||
}
|
||||
|
||||
pub(crate) fn stmt_optional_semi(p: &mut Parser) {
|
||||
expressions::stmt(p, expressions::StmtWithSemi::Optional, false);
|
||||
}
|
||||
|
||||
pub(crate) fn macro_items(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
items::mod_contents(p, false);
|
||||
m.complete(p, MACRO_ITEMS);
|
||||
}
|
||||
|
||||
pub(crate) fn macro_stmts(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
|
||||
while !p.at(EOF) {
|
||||
if p.at(T![;]) {
|
||||
p.bump(T![;]);
|
||||
continue;
|
||||
}
|
||||
|
||||
expressions::stmt(p, expressions::StmtWithSemi::Optional, true);
|
||||
}
|
||||
|
||||
m.complete(p, MACRO_STMTS);
|
||||
}
|
||||
|
||||
pub(crate) fn attr(p: &mut Parser) {
|
||||
attributes::outer_attrs(p);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue