refactored import syntax
This commit is contained in:
+1
-1
@@ -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,
|
||||
|
||||
@@ -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
@@ -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)),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user