Skip to content

Commit

Permalink
Add SymbolTable::dump
Browse files Browse the repository at this point in the history
For diagnostics
  • Loading branch information
jlapeyre committed Mar 28, 2024
1 parent 233f71d commit ad7d786
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/oq3_semantics/examples/semdemo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ fn main() {
result.program(),
result.symbol_table()
));
// result.take_context().symbol_table().dump();
}

Some(Commands::SemanticPretty { file_name }) => {
Expand Down
8 changes: 7 additions & 1 deletion crates/oq3_semantics/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ impl SymbolMap {
self.table.len()
}

/// Re
pub fn contains_name(&self, name: &str) -> bool {
self.table.contains_key(name)
}
Expand Down Expand Up @@ -411,6 +410,13 @@ impl SymbolTable {
Err(_) => self.new_binding_no_check(name, typ),
}
}

/// Simple dump of all symbols. This could be improved.
pub fn dump(&self) {
for (n, sym) in self.all_symbols.iter().enumerate() {
println!("{n} {:?}", sym);
}
}
}

impl Default for SymbolTable {
Expand Down

0 comments on commit ad7d786

Please sign in to comment.