view src/dil/semantic/SymbolTable.d @ 839:4063da6f3edd default tip

Refactored the config file and how it is loaded.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Thu, 21 Aug 2008 17:51:04 +0200
parents bcb74c9b895c
children
line wrap: on
line source

/++
  Author: Aziz Köksal
  License: GPL3
+/
module dil.semantic.SymbolTable;

import dil.semantic.Symbol;
import dil.lexer.Identifier;
import common;

/// Maps an identifier string to a Symbol.
struct SymbolTable
{
  Symbol[char[]] table; /// The table data structure.

  /// Looks up ident in the table.
  /// Returns: the symbol if there, otherwise null.
  Symbol lookup(Identifier* ident)
  {
    assert(ident !is null);
    auto psym = ident.str in table;
    return psym ? *psym : null;
  }

  /// Inserts a symbol into the table.
  void insert(Symbol symbol, Identifier* ident)
  {
    table[ident.str] = symbol;
  }
}