Semantics in check
This commit is contained in:
@@ -2,6 +2,7 @@ use std::sync::Arc;
|
||||
|
||||
use crate::top_level::TopLevelScope;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Scope {
|
||||
TopLevel(TopLevelScope),
|
||||
}
|
||||
|
||||
@@ -4,13 +4,16 @@ use parser::ast::TopLevel;
|
||||
|
||||
use parser::ast::{ParamList, TypeExpr};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct TypeSymbol(pub String);
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct VarSymbol {
|
||||
pub var_type: TypeSymbol,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct FunctionSymbol {
|
||||
pub export: bool,
|
||||
pub name: String,
|
||||
@@ -18,6 +21,7 @@ pub struct FunctionSymbol {
|
||||
pub return_type: Option<TypeSymbol>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct StructSymbol {
|
||||
pub export: bool,
|
||||
pub name: String,
|
||||
@@ -71,6 +75,7 @@ impl StructSymbol {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct TopLevelScope {
|
||||
pub structs: HashMap<String, StructSymbol>,
|
||||
pub functions: HashMap<String, FunctionSymbol>,
|
||||
|
||||
+4
-2
@@ -53,8 +53,10 @@ pub fn cmd_build() {
|
||||
fn cmd_check(path: &str) {
|
||||
let source = read_ms_file(path);
|
||||
match parser::parse(&source) {
|
||||
Ok(_) => {
|
||||
println!("ok");
|
||||
Ok(ast) => {
|
||||
println!("parse: ok");
|
||||
|
||||
println!("{:#?}", semantic::scope::Scope::from_top(&ast))
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("parse error:\n{}", e);
|
||||
|
||||
Reference in New Issue
Block a user