Rmoved package
This commit is contained in:
@@ -31,7 +31,6 @@ pub enum BinaryOp {
|
|||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub enum TopLevel {
|
pub enum TopLevel {
|
||||||
Import(String),
|
Import(String),
|
||||||
Package(String),
|
|
||||||
StructDecl {
|
StructDecl {
|
||||||
export: bool,
|
export: bool,
|
||||||
name: String,
|
name: String,
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ inner_str = @{ (!"\"" ~ ANY)* }
|
|||||||
|
|
||||||
// ================= TOP LEVEL =================
|
// ================= TOP LEVEL =================
|
||||||
|
|
||||||
top_level = _{ import | function_decl | struct_decl | package }
|
top_level = _{ import | function_decl | struct_decl }
|
||||||
|
|
||||||
package = { "package" ~ identifier ~ ";" }
|
|
||||||
|
|
||||||
export = { "public" }
|
export = { "public" }
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ use pest::Parser;
|
|||||||
use pest_derive::Parser;
|
use pest_derive::Parser;
|
||||||
|
|
||||||
pub mod ast;
|
pub mod ast;
|
||||||
pub mod script_parser;
|
|
||||||
|
|
||||||
use ast::*;
|
use ast::*;
|
||||||
|
|
||||||
@@ -79,10 +78,6 @@ impl TryFrom<pest::iterators::Pair<'_, Rule>> for TopLevel {
|
|||||||
let path = pair.into_inner().next().unwrap().as_str().to_string();
|
let path = pair.into_inner().next().unwrap().as_str().to_string();
|
||||||
Ok(TopLevel::Import(path))
|
Ok(TopLevel::Import(path))
|
||||||
}
|
}
|
||||||
Rule::package => {
|
|
||||||
let name = pair.into_inner().next().unwrap().as_str().to_string();
|
|
||||||
Ok(TopLevel::Package(name))
|
|
||||||
}
|
|
||||||
Rule::function_decl => {
|
Rule::function_decl => {
|
||||||
let mut inner = pair.into_inner();
|
let mut inner = pair.into_inner();
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ pub fn walk_ast(top_scope: Arc<Scope>, tl: &mut Vec<parser::ast::TopLevel>) {
|
|||||||
for tl in tl {
|
for tl in tl {
|
||||||
match tl {
|
match tl {
|
||||||
parser::ast::TopLevel::Import(_) => {}
|
parser::ast::TopLevel::Import(_) => {}
|
||||||
parser::ast::TopLevel::Package(_) => {}
|
|
||||||
|
|
||||||
parser::ast::TopLevel::FunctionDecl {
|
parser::ast::TopLevel::FunctionDecl {
|
||||||
params, body, name, ..
|
params, body, name, ..
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ impl TopLevelSymbolScope {
|
|||||||
.imports
|
.imports
|
||||||
.insert(json_scope.package_name.clone(), json_scope);
|
.insert(json_scope.package_name.clone(), json_scope);
|
||||||
}
|
}
|
||||||
TopLevel::Package(_) => {}
|
|
||||||
|
|
||||||
TopLevel::FunctionDecl {
|
TopLevel::FunctionDecl {
|
||||||
export,
|
export,
|
||||||
|
|||||||
@@ -102,10 +102,6 @@ impl GoCodegen {
|
|||||||
self.indent -= 1;
|
self.indent -= 1;
|
||||||
self.addln("}\n");
|
self.addln("}\n");
|
||||||
}
|
}
|
||||||
TopLevel::Package(pkg) => {
|
|
||||||
self.addln(&format!("package {}", pkg));
|
|
||||||
self.addln("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-5
@@ -47,11 +47,7 @@ pub fn build() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let parser_result = if script {
|
let parser_result = parser::parse(&source).map_err(|e| e.to_string());
|
||||||
parser::script_parser::parse(&source).map_err(|e| e.to_string())
|
|
||||||
} else {
|
|
||||||
parser::parse(&source).map_err(|e| e.to_string())
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut ast = match parser_result {
|
let mut ast = match parser_result {
|
||||||
Ok(ast) => ast,
|
Ok(ast) => ast,
|
||||||
|
|||||||
Reference in New Issue
Block a user