This commit is contained in:
2026-04-21 11:28:26 +02:00
parent 508b180d63
commit 18fedba119
7 changed files with 38 additions and 32 deletions
+1
View File
@@ -31,6 +31,7 @@ pub enum BinaryOp {
#[derive(Debug, Clone, Serialize)]
pub enum TopLevel {
Import(String),
Package(String),
StructDecl {
export: bool,
name: String,
+3 -1
View File
@@ -13,7 +13,9 @@ inner_str = @{ (!"\"" ~ ANY)* }
// ================= TOP LEVEL =================
top_level = _{ import | function_decl | struct_decl }
top_level = _{ import | function_decl | struct_decl | package }
package = { "package" ~ identifier ~ ";" }
export = { "export" }
+4
View File
@@ -70,6 +70,10 @@ impl TopLevel {
let path = pair.into_inner().next().unwrap().as_str().to_string();
Some(TopLevel::Import(path))
}
Rule::package => {
let name = pair.into_inner().next().unwrap().as_str().to_string();
Some(TopLevel::Package(name))
}
Rule::function_decl => {
let mut inner = pair.into_inner();