Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d28a465
Adicionar parser para funções de teste
The3rdMega Jun 20, 2025
00400ba
Corrigido retorno de Erro nas funções de parser de funções comuns e f…
The3rdMega Jun 20, 2025
040373c
Commit de teste do terminal
The3rdMega Jun 20, 2025
4a1af4d
Alterado Parser de Test Functions e Implementado Parser de Asserts
The3rdMega Jun 24, 2025
c3e2abb
Tipo de TestDef agora é sempre TVoid
The3rdMega Jun 25, 2025
e0ad684
Adicionado Interpretador de Assert e Hashmap de Testes no Scope
The3rdMega Jun 25, 2025
44909f9
Implementa Definição de Testes no Interpretador
The3rdMega Jun 25, 2025
f5d8110
Finalizada Implementação do Interpretador de Testes
The3rdMega Jun 26, 2025
31bf3ac
Update statement_type_checker.rs
michelenakagomi Jun 29, 2025
01648fe
[Fix] Asserts Type Checker now checks Error Messages in the Asserts
The3rdMega Jun 30, 2025
b6f55e6
Implementados Mais testes e agora cada Função de teste executa no seu…
The3rdMega Jun 30, 2025
d28184c
Implementação e Testes de DefTest no TypeChecker
Carlos-Vic Jul 1, 2025
d64cf50
Correção na função check_test_function_stmt
Carlos-Vic Jul 1, 2025
630ca36
Correção da implementação no TypeChecker
Carlos-Vic Jul 1, 2025
eec04f2
[Update] Prepared for Presentation
The3rdMega Jul 2, 2025
11e6eab
[Update] New Parser Assert Tests that check parse Error
The3rdMega Jul 2, 2025
a8d0f5b
[Update] Mais TODO's de Apresentação
The3rdMega Jul 2, 2025
3ecc4eb
Made cargo fmt
The3rdMega Jul 4, 2025
7a5671e
Alterações do Bonifácio
The3rdMega Jul 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ edition = "2021"
nom = "7.0"
approx = "0.5.1"
once_cell = "1.10"
indexmap = "2.2"
57 changes: 57 additions & 0 deletions src/environment/environment.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::ir::ast::Function;
use crate::ir::ast::Name;
use crate::ir::ast::ValueConstructor;
use indexmap::IndexMap;
use std::collections::HashMap;
use std::collections::LinkedList;

Expand All @@ -9,6 +10,7 @@ pub struct Scope<A> {
pub variables: HashMap<Name, (bool, A)>,
pub functions: HashMap<Name, Function>,
pub adts: HashMap<Name, Vec<ValueConstructor>>,
pub tests: IndexMap<Name, Function>,
}

impl<A: Clone> Scope<A> {
Expand All @@ -17,6 +19,7 @@ impl<A: Clone> Scope<A> {
variables: HashMap::new(),
functions: HashMap::new(),
adts: HashMap::new(),
tests: IndexMap::new(), //TODO: Apresentar Mudança no Environment
}
}

Expand All @@ -30,6 +33,11 @@ impl<A: Clone> Scope<A> {
return ();
}

fn map_test(&mut self, test: Function) -> () {
self.tests.insert(test.name.clone(), test);
return ();
}

fn map_adt(&mut self, name: Name, adt: Vec<ValueConstructor>) -> () {
self.adts.insert(name.clone(), adt);
return ();
Expand All @@ -45,6 +53,10 @@ impl<A: Clone> Scope<A> {
self.functions.get(name)
}

fn lookup_test(&self, name: &Name) -> Option<&Function> {
self.tests.get(name)
}

fn lookup_adt(&self, name: &Name) -> Option<&Vec<ValueConstructor>> {
self.adts.get(name)
}
Expand Down Expand Up @@ -78,6 +90,13 @@ impl<A: Clone> Environment<A> {
}
}

pub fn map_test(&mut self, test: Function) -> () {
match self.stack.front_mut() {
None => self.globals.map_test(test),
Some(top) => top.map_test(test),
}
}

pub fn map_adt(&mut self, name: Name, cons: Vec<ValueConstructor>) -> () {
match self.stack.front_mut() {
None => self.globals.map_adt(name, cons),
Expand All @@ -103,6 +122,28 @@ impl<A: Clone> Environment<A> {
self.globals.lookup_function(name)
}

pub fn lookup_test(&self, name: &Name) -> Option<&Function> {
for scope in self.stack.iter() {
if let Some(test) = scope.lookup_test(name) {
return Some(test);
}
}
self.globals.lookup_test(name)
}

pub fn get_all_tests(&self) -> Vec<Function> {
let mut tests = Vec::new();
for scope in self.stack.iter() {
for test in scope.tests.values() {
tests.push(test.clone());
}
}
for test in self.globals.tests.values() {
tests.push(test.clone());
}
tests
}

pub fn lookup_adt(&self, name: &Name) -> Option<&Vec<ValueConstructor>> {
for scope in self.stack.iter() {
if let Some(cons) = scope.lookup_adt(name) {
Expand Down Expand Up @@ -147,6 +188,22 @@ impl<A: Clone> Environment<A> {
}
}

pub struct TestResult {
pub name: Name,
pub result: bool,
pub error: Option<String>,
}

impl TestResult {
pub fn new(name: Name, result: bool, error: Option<String>) -> Self {
TestResult {
name,
result,
error,
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading
Loading