diff --git a/Cargo.toml b/Cargo.toml index eba24cb..81b16e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "simpla" +name = "simplac" version = "0.1.0" authors = ["Filippo Ranza "] edition = "2018" diff --git a/src/semantic_analysis/stat_check.rs b/src/semantic_analysis/stat_check.rs index 5e58ecc..dcb9140 100644 --- a/src/semantic_analysis/stat_check.rs +++ b/src/semantic_analysis/stat_check.rs @@ -41,7 +41,7 @@ fn stat_check<'b, 'a: 'b>( syntax_tree::StatType::IfStat(if_stat) => { check_if_stat(if_stat, table, contex, loop_contex, &stat.loc) } - syntax_tree::StatType::ReadStat(read_stat) => check_read_stat(read_stat, table), + syntax_tree::StatType::ReadStat(read_stat) => check_read_stat(read_stat, table, loop_contex), syntax_tree::StatType::ReturnStat(return_stat) => { check_return_stat(return_stat, table, contex, &stat.loc) } @@ -69,7 +69,7 @@ enum CheckStatus { Failure, } -struct LoopContext<'a> { +struct LoopContext<'a> { indexes: HashSet<&'a str>, nested_loops: usize, } @@ -220,9 +220,14 @@ fn check_if_stat<'b, 'a: 'b>( fn check_read_stat<'a>( read_stat: &'a syntax_tree::IdList, table: &'a LocalVariableTable, + contex: &LoopContext ) -> Result<(), SemanticError<'a>> { for id in read_stat { table.get_variable(id)?; + match contex.check_assign(id) { + CheckStatus::Success => {}, + CheckStatus::Failure => {} + } } Ok(()) }