Added global include

This commit is contained in:
2026-07-08 10:11:26 +02:00
parent 4b69bbaed0
commit bb006c1ba2
5 changed files with 40 additions and 2 deletions
+1
View File
@@ -28,6 +28,7 @@ pub struct TopLevel(pub Spanned<TopLevelKind>, pub Vec<Attribute>);
pub enum TopLevelKind {
ModAttribute,
Import(Visibility, Path),
IncludeGlobal(Path),
DeclareModule(Visibility, Identifier),
ImplDecl(ImplDecl),
StaticDecl(VarDeclStmt),
+5 -1
View File
@@ -258,6 +258,10 @@ param_list = {
// IMPORTS / MODULES
// ======================================================
include_global = {
"#" ~ "include" ~ "<" ~ identifier ~ ("/" ~ identifier)* ~ ">"
}
import = {
visibility? ~ "use" ~ static_path ~ semicolon
}
@@ -384,7 +388,7 @@ type_alias = { "type" ~ identifier ~ generics_decl? ~ "=" ~ type_expr ~ ";" }
top_level = {
mod_attribute
| (attributes ~ (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 | import | impl_for_decl | impl_decl | trait_decl | struct_decl | enum_decl | class_decl | declare_module | function_decl | const_decl | static_decl | type_alias))
}
// ======================================================
+2
View File
@@ -129,6 +129,8 @@ 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)?))),
_ => AstError::bug_unimplemented(pair),
}
}