Added use include
This commit is contained in:
@@ -29,6 +29,7 @@ pub enum TopLevelKind {
|
||||
ModAttribute,
|
||||
Import(Visibility, Path),
|
||||
IncludeGlobal(Path),
|
||||
IncludeUse(Visibility, Path),
|
||||
DeclareModule(Visibility, Identifier),
|
||||
ImplDecl(ImplDecl),
|
||||
StaticDecl(VarDeclStmt),
|
||||
|
||||
@@ -262,6 +262,10 @@ include_global = {
|
||||
"#" ~ "include" ~ "<" ~ identifier ~ ("/" ~ identifier)* ~ ">"
|
||||
}
|
||||
|
||||
include_use_global = {
|
||||
visibility? ~ "#" ~ "use" ~ static_path ~ semicolon
|
||||
}
|
||||
|
||||
import = {
|
||||
visibility? ~ "use" ~ static_path ~ semicolon
|
||||
}
|
||||
@@ -388,7 +392,7 @@ type_alias = { "type" ~ identifier ~ generics_decl? ~ "=" ~ type_expr ~ ";" }
|
||||
|
||||
top_level = {
|
||||
mod_attribute
|
||||
| (attributes ~ (include_global | import | impl_for_decl | impl_decl | trait_decl | struct_decl | enum_decl | class_decl | declare_module | function_decl | const_decl | static_decl | type_alias))
|
||||
| (attributes ~ (include_global | include_use_global | import | impl_for_decl | impl_decl | trait_decl | struct_decl | enum_decl | class_decl | declare_module | function_decl | const_decl | static_decl | type_alias))
|
||||
}
|
||||
|
||||
// ======================================================
|
||||
|
||||
@@ -129,7 +129,14 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for TopLevelKind {
|
||||
ty: inner.next().unwrap().try_into()?,
|
||||
}),
|
||||
|
||||
Rule::include_global => Ok(TopLevelKind::IncludeGlobal(Path(collect_recovered(&mut inner)?))),
|
||||
Rule::include_global => Ok(TopLevelKind::IncludeGlobal(Path(collect_recovered(
|
||||
&mut inner,
|
||||
)?))),
|
||||
|
||||
Rule::include_use_global => Ok(TopLevelKind::IncludeUse(
|
||||
Visibility::try_from(&mut inner)?,
|
||||
Path::try_from(inner.next().unwrap())?,
|
||||
)),
|
||||
|
||||
_ => AstError::bug_unimplemented(pair),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user