wip:
Add type system and refator for having only epression
This commit is contained in:
+10
-11
@@ -1,13 +1,12 @@
|
||||
mod backend;
|
||||
mod common;
|
||||
mod frontend;
|
||||
mod logging;
|
||||
mod middleend;
|
||||
|
||||
pub mod backend;
|
||||
pub mod common;
|
||||
pub mod frontend;
|
||||
pub mod logging;
|
||||
pub mod middleend;
|
||||
use crate::{
|
||||
backend::interpreter::{EvaluateInterpreter, Interpreter},
|
||||
common::{
|
||||
ast::{AstNode, Stmt},
|
||||
ast::AstNode,
|
||||
lox_result::{LoxError, LoxResult},
|
||||
},
|
||||
frontend::{
|
||||
@@ -175,7 +174,7 @@ impl LoxInterpreter {
|
||||
}
|
||||
|
||||
// Funzione per parsare fino all'AST
|
||||
fn parse_to_ast(&self, source_id: SourceId) -> LoxResult<Vec<AstNode<Stmt>>> {
|
||||
fn parse_to_ast(&self, source_id: SourceId) -> LoxResult<Vec<AstNode>> {
|
||||
let tokens = self.tokenize(source_id)?;
|
||||
|
||||
Parser::new(tokens).parse().or_else(|err| {
|
||||
@@ -185,7 +184,7 @@ impl LoxInterpreter {
|
||||
}
|
||||
|
||||
// Funzione per eseguire l'AST
|
||||
fn execute_ast(&self, ast: Vec<AstNode<Stmt>>, debug: bool) -> LoxResult<String> {
|
||||
fn execute_ast(&self, ast: Vec<AstNode>, debug: bool) -> LoxResult<String> {
|
||||
// Static resolution pass: compute variable scope distances and report
|
||||
// any resolution errors before executing.
|
||||
let locals = self.resolve(&ast)?;
|
||||
@@ -212,7 +211,7 @@ impl LoxInterpreter {
|
||||
// Static variable resolution; prints and returns the first error, if any.
|
||||
fn resolve(
|
||||
&self,
|
||||
ast: &[AstNode<Stmt>],
|
||||
ast: &[AstNode],
|
||||
) -> LoxResult<std::collections::HashMap<crate::common::ast::NodeId, usize>> {
|
||||
Resolver::resolve_program(ast).map_err(|errors| {
|
||||
for err in &errors {
|
||||
@@ -295,7 +294,7 @@ fn format_tokens(tokens: &[crate::frontend::tokens::Token]) -> String {
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
fn format_ast(ast: &[AstNode<Stmt>]) -> String {
|
||||
fn format_ast(ast: &[AstNode]) -> String {
|
||||
use crate::logging::display_ast::{pretty_print_with_config, PrettyConfig};
|
||||
|
||||
let config = PrettyConfig {
|
||||
|
||||
Reference in New Issue
Block a user