X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=crates%2Fparser%2Fsrc%2Fgrammar.rs;h=2b874d6e1c363df4c88225e27cccb3d199e3c5cf;hb=55c0b86cdec534aa0397e3d69335265cbfd0f5c3;hp=cc23bff667f0e7757845bdfcc163d1b783a24b97;hpb=104cd0ce883eef6060042bdf694d493d16be49a9;p=rust.git diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index cc23bff667f..2b874d6e1c3 100644 --- a/crates/parser/src/grammar.rs +++ b/crates/parser/src/grammar.rs @@ -34,14 +34,14 @@ mod params; mod paths; mod patterns; -mod type_args; -mod type_params; +mod generic_args; +mod generic_params; mod types; use crate::{ parser::{CompletedMarker, Marker, Parser}, SyntaxKind::{self, *}, - TokenSet, + TokenSet, T, }; pub(crate) mod entry_points { @@ -63,15 +63,15 @@ pub(crate) fn source_file(p: &mut Parser) { pub(crate) use types::type_; pub(crate) fn expr(p: &mut Parser) { - let _ = expressions::expr_with_attrs(p); + let _ = expressions::expr(p); } pub(crate) fn stmt(p: &mut Parser) { - expressions::stmt(p, expressions::StmtWithSemi::No, true) + expressions::stmt(p, expressions::StmtWithSemi::No, true); } pub(crate) fn stmt_optional_semi(p: &mut Parser) { - expressions::stmt(p, expressions::StmtWithSemi::Optional, false) + expressions::stmt(p, expressions::StmtWithSemi::Optional, false); } pub(crate) fn visibility(p: &mut Parser) { @@ -84,7 +84,7 @@ pub(crate) fn meta_item(p: &mut Parser) { } pub(crate) fn item(p: &mut Parser) { - items::item_or_macro(p, true) + items::item_or_macro(p, true); } pub(crate) fn macro_items(p: &mut Parser) { @@ -109,7 +109,7 @@ pub(crate) fn macro_stmts(p: &mut Parser) { } pub(crate) fn attr(p: &mut Parser) { - attributes::outer_attrs(p) + attributes::outer_attrs(p); } } @@ -166,22 +166,16 @@ fn opt_visibility(p: &mut Parser) -> bool { // struct B(pub (super::A)); // struct B(pub (crate::A,)); T![crate] | T![self] | T![super] | T![ident] if p.nth(2) != T![:] => { - p.bump_any(); - let path_m = p.start(); - let path_segment_m = p.start(); - let name_ref_m = p.start(); - p.bump_any(); - name_ref_m.complete(p, NAME_REF); - path_segment_m.complete(p, PATH_SEGMENT); - path_m.complete(p, PATH); + p.bump(T!['(']); + paths::use_path(p); p.expect(T![')']); } // test crate_visibility_in // pub(in super::A) struct S; // pub(in crate) struct S; T![in] => { - p.bump_any(); - p.bump_any(); + p.bump(T!['(']); + p.bump(T![in]); paths::use_path(p); p.expect(T![')']); } @@ -189,22 +183,25 @@ fn opt_visibility(p: &mut Parser) -> bool { } } m.complete(p, VISIBILITY); + true } // test crate_keyword_vis // crate fn main() { } // struct S { crate field: u32 } // struct T(crate u32); - // - // test crate_keyword_path - // fn foo() { crate::foo(); } - T![crate] if !p.nth_at(1, T![::]) => { + T![crate] => { + if p.nth_at(1, T![::]) { + // test crate_keyword_path + // fn foo() { crate::foo(); } + return false; + } let m = p.start(); p.bump(T![crate]); m.complete(p, VISIBILITY); + true } - _ => return false, + _ => false, } - true } fn opt_rename(p: &mut Parser) { @@ -249,7 +246,7 @@ fn name_r(p: &mut Parser, recovery: TokenSet) { } fn name(p: &mut Parser) { - name_r(p, TokenSet::EMPTY) + name_r(p, TokenSet::EMPTY); } fn name_ref(p: &mut Parser) {