scribe_analysis/
symbols.rs1use std::collections::HashMap;
6
7#[derive(Debug, Clone)]
8pub struct Symbol {
9 pub name: String,
10 pub symbol_type: String,
11 pub scope: String,
12}
13
14impl Symbol {
15 pub fn new(name: String, symbol_type: String, scope: String) -> Self {
16 Self {
17 name,
18 symbol_type,
19 scope,
20 }
21 }
22}
23
24#[derive(Debug, Clone, Default)]
25pub struct SymbolTable {
26 symbols: HashMap<String, Symbol>,
27}
28
29impl SymbolTable {
30 pub fn new() -> Self {
31 Self::default()
32 }
33
34 pub fn insert(&mut self, symbol: Symbol) {
35 self.symbols.insert(symbol.name.clone(), symbol);
36 }
37
38 pub fn lookup(&self, name: &str) -> Option<&Symbol> {
39 self.symbols.get(name)
40 }
41}