Pub mod and pub use
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
mod app;
|
pub mod app;
|
||||||
mod task;
|
pub mod task;
|
||||||
mod plugin;
|
pub mod plugin;
|
||||||
mod logger;
|
pub mod logger;
|
||||||
mod event;
|
pub mod event;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
var mut app_instance = new app::Application("mist-app");
|
var mut app_instance = new app::Application("mist-app");
|
||||||
|
|||||||
+2
-2
@@ -73,8 +73,8 @@ pub struct TopLevel(pub TopLevelKind, pub Vec<Attribute>);
|
|||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub enum TopLevelKind {
|
pub enum TopLevelKind {
|
||||||
ModAttribute,
|
ModAttribute,
|
||||||
Import(Path),
|
Import(Visibility, Path),
|
||||||
Mod(Identifier),
|
Mod(Visibility, Identifier),
|
||||||
ImplDecl(ImplDecl),
|
ImplDecl(ImplDecl),
|
||||||
TraitDecl {
|
TraitDecl {
|
||||||
visibility: Visibility,
|
visibility: Visibility,
|
||||||
|
|||||||
@@ -170,11 +170,11 @@ param_list = {
|
|||||||
// ======================================================
|
// ======================================================
|
||||||
|
|
||||||
import = {
|
import = {
|
||||||
"use" ~ "<" ~ static_path ~ ">" ~ semicolon
|
visibility? ~ "use" ~ "<" ~ static_path ~ ">" ~ semicolon
|
||||||
}
|
}
|
||||||
|
|
||||||
mod_package = {
|
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();
|
let mut inner = pair.clone().into_inner();
|
||||||
|
|
||||||
match rule {
|
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)),
|
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(),
|
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)),
|
Rule::impl_for_decl | Rule::impl_decl => TopLevelKind::ImplDecl(ImplDecl::from(pair)),
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -312,8 +312,10 @@ impl ToRust for TopLevelKind {
|
|||||||
fn to_rust(&self, cg: &mut RustCodegen) {
|
fn to_rust(&self, cg: &mut RustCodegen) {
|
||||||
match self {
|
match self {
|
||||||
Self::ModAttribute => {}
|
Self::ModAttribute => {}
|
||||||
Self::Import(path) => cg.addln(&format!("use {};", path.get_rust())),
|
Self::Import(vis, path) => {
|
||||||
Self::Mod(id) => cg.addln(&format!("mod {};", id.get_rust())),
|
cg.addln(&format!("{} use {};", vis.get_rust(), path.get_rust()))
|
||||||
|
}
|
||||||
|
Self::Mod(vis, id) => cg.addln(&format!("{} mod {};", vis.get_rust(), id.get_rust())),
|
||||||
Self::FunctionDecl(decl) => decl.to_rust(cg),
|
Self::FunctionDecl(decl) => decl.to_rust(cg),
|
||||||
Self::ImplDecl(impl_) => impl_.to_rust(cg),
|
Self::ImplDecl(impl_) => impl_.to_rust(cg),
|
||||||
Self::StructDecl {
|
Self::StructDecl {
|
||||||
|
|||||||
Reference in New Issue
Block a user