Pub mod and pub use
This commit is contained in:
+2
-2
@@ -73,8 +73,8 @@ pub struct TopLevel(pub TopLevelKind, pub Vec<Attribute>);
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub enum TopLevelKind {
|
||||
ModAttribute,
|
||||
Import(Path),
|
||||
Mod(Identifier),
|
||||
Import(Visibility, Path),
|
||||
Mod(Visibility, Identifier),
|
||||
ImplDecl(ImplDecl),
|
||||
TraitDecl {
|
||||
visibility: Visibility,
|
||||
|
||||
@@ -48,9 +48,9 @@ program = {
|
||||
// MODIFIERS
|
||||
// ======================================================
|
||||
|
||||
visibility = { "pub" ~ ("(" ~ static_path ~ ")")? }
|
||||
mutable = { "mut" }
|
||||
var = { "var" }
|
||||
visibility = { "pub" ~ ("(" ~ static_path ~ ")")? }
|
||||
mutable = { "mut" }
|
||||
var = { "var" }
|
||||
|
||||
// ======================================================
|
||||
// GENERICS
|
||||
@@ -170,11 +170,11 @@ param_list = {
|
||||
// ======================================================
|
||||
|
||||
import = {
|
||||
"use" ~ "<" ~ static_path ~ ">" ~ semicolon
|
||||
visibility? ~ "use" ~ "<" ~ static_path ~ ">" ~ semicolon
|
||||
}
|
||||
|
||||
mod_package = {
|
||||
"mod" ~ identifier ~ semicolon
|
||||
visibility? ~ "mod" ~ identifier ~ semicolon
|
||||
}
|
||||
|
||||
// ======================================================
|
||||
|
||||
+8
-2
@@ -260,7 +260,10 @@ impl From<pest::iterators::Pair<'_, Rule>> for TopLevelKind {
|
||||
let mut inner = pair.clone().into_inner();
|
||||
|
||||
match rule {
|
||||
Rule::import => TopLevelKind::Import(Path::from(inner.next().unwrap())),
|
||||
Rule::import => TopLevelKind::Import(
|
||||
Visibility::from(&mut inner),
|
||||
Path::from(inner.next().unwrap()),
|
||||
),
|
||||
|
||||
Rule::function_decl => TopLevelKind::FunctionDecl(FunctionDecl::from(pair)),
|
||||
|
||||
@@ -301,7 +304,10 @@ impl From<pest::iterators::Pair<'_, Rule>> for TopLevelKind {
|
||||
fields: inner.map(EnumItem::from).collect(),
|
||||
},
|
||||
|
||||
Rule::mod_package => TopLevelKind::Mod(Identifier::from(inner.next().unwrap())),
|
||||
Rule::mod_package => TopLevelKind::Mod(
|
||||
Visibility::from(&mut inner),
|
||||
Identifier::from(inner.next().unwrap()),
|
||||
),
|
||||
|
||||
Rule::impl_for_decl | Rule::impl_decl => TopLevelKind::ImplDecl(ImplDecl::from(pair)),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user