mod decl
This commit is contained in:
@@ -68,6 +68,7 @@ pub struct TopLevel(pub TopLevelKind, pub Vec<Attribute>);
|
||||
pub enum TopLevelKind {
|
||||
ModAttribute,
|
||||
Import(Path),
|
||||
Mod(String),
|
||||
StructDecl {
|
||||
visibility: Visibility,
|
||||
name: String,
|
||||
|
||||
@@ -37,7 +37,7 @@ class_decl = {
|
||||
|
||||
// ================= TOP LEVEL =================
|
||||
|
||||
top_level = { (attributes ~ (import | function_decl | struct_decl | class_decl)) | mod_attribute }
|
||||
top_level = { (attributes ~ (import | function_decl | struct_decl | class_decl | mod_package)) | mod_attribute }
|
||||
|
||||
attribute = {
|
||||
"#" ~ "[" ~ meta ~ "]"
|
||||
@@ -59,6 +59,8 @@ attributes = { attribute* }
|
||||
|
||||
import = { "use" ~ "<" ~ static_path ~ ">" ~ semicolon }
|
||||
|
||||
mod_package = { "mod" ~ identifier ~ semicolon }
|
||||
|
||||
field_list = { field ~ ("," ~ field)* ~ ","? }
|
||||
field = { export? ~ type_expr ~ identifier }
|
||||
|
||||
|
||||
@@ -259,6 +259,8 @@ impl From<pest::iterators::Pair<'_, Rule>> for TopLevelKind {
|
||||
methods: inner.into_iter().map(FunctionDecl::from).collect(),
|
||||
},
|
||||
|
||||
Rule::mod_package => TopLevelKind::Mod(inner.next().unwrap().as_str().to_string()),
|
||||
|
||||
_ => unimplemented!("{rule:#?}"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user