diff --git a/parser/src/ast.rs b/parser/src/ast.rs index 05bca76..88aa6d8 100644 --- a/parser/src/ast.rs +++ b/parser/src/ast.rs @@ -67,7 +67,7 @@ pub struct TopLevel(pub TopLevelKind, pub Vec); #[derive(Debug, Clone, Serialize)] pub enum TopLevelKind { ModAttribute, - Include(Path), + Import(Path), StructDecl { visibility: Visibility, name: String, diff --git a/parser/src/grammar.pest b/parser/src/grammar.pest index 9913b8c..311b5bc 100644 --- a/parser/src/grammar.pest +++ b/parser/src/grammar.pest @@ -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 } diff --git a/parser/src/lib.rs b/parser/src/lib.rs index bb3f16d..b6dc717 100644 --- a/parser/src/lib.rs +++ b/parser/src/lib.rs @@ -229,7 +229,7 @@ impl From> 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)), diff --git a/src/codegen.rs b/src/codegen.rs index 6bfa172..1f4eab4 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -308,7 +308,7 @@ impl ToRust for TopLevelKind { fn to_rust(&self, cg: &mut RustCodegen) { match self { Self::ModAttribute => {} - Self::Include(path) => { + Self::Import(path) => { cg.addln(&format!("use {};", path.get_rust())); } Self::FunctionDecl(decl) => decl.to_rust(cg),