Mercurial > projects > dil
diff src/dil/semantic/SymbolTable.d @ 806:bcb74c9b895c
Moved out files in the trunk folder to the root.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sun, 09 Mar 2008 00:12:19 +0100 |
parents | trunk/src/dil/semantic/SymbolTable.d@c24be8d4f6ab |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/dil/semantic/SymbolTable.d Sun Mar 09 00:12:19 2008 +0100 @@ -0,0 +1,30 @@ +/++ + 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; + } +}