refactored import syntax

This commit is contained in:
2026-05-07 18:08:58 +02:00
parent 4a5f3b7445
commit 2ccec652da
4 changed files with 4 additions and 5 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ pub struct TopLevel(pub TopLevelKind, pub Vec<Attribute>);
#[derive(Debug, Clone, Serialize)]
pub enum TopLevelKind {
ModAttribute,
Include(Path),
Import(Path),
StructDecl {
visibility: Visibility,
name: String,
+1 -2
View File
@@ -14,7 +14,6 @@ static_path = { identifier ~ ("::" ~ identifier)* }
export = { "public" }
mutable = { "mut" }
sharp = _{ "#" }
var = { "var" }
var_decl = { (var | type_expr) ~ mutable? ~ identifier }
semicolon = _{ ";" }
@@ -58,7 +57,7 @@ meta_list = {
attributes = { attribute* }
import = { sharp ~ "include" ~ "<" ~ static_path ~ ">" }
import = { "use" ~ "<" ~ static_path ~ ">" ~ semicolon }
field_list = { field ~ ("," ~ field)* ~ ","? }
field = { export? ~ type_expr ~ identifier }
+1 -1
View File
@@ -229,7 +229,7 @@ impl From<pest::iterators::Pair<'_, Rule>> for TopLevelKind {
let mut inner = pair.clone().into_inner();
match rule {
Rule::import => TopLevelKind::Include(Path::from(inner.next().unwrap())),
Rule::import => TopLevelKind::Import(Path::from(inner.next().unwrap())),
Rule::function_decl => TopLevelKind::FunctionDecl(FunctionDecl::from(pair)),