Mercurial > projects > dil
comparison trunk/src/dil/semantic/SymbolTable.d @ 798:c24be8d4f6ab
Added documentation comments.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sat, 01 Mar 2008 02:53:06 +0100 |
parents | 041eae272362 |
children |
comparison
equal
deleted
inserted
replaced
797:cf2ad5df025c | 798:c24be8d4f6ab |
---|---|
6 | 6 |
7 import dil.semantic.Symbol; | 7 import dil.semantic.Symbol; |
8 import dil.lexer.Identifier; | 8 import dil.lexer.Identifier; |
9 import common; | 9 import common; |
10 | 10 |
11 /++ | 11 /// Maps an identifier string to a Symbol. |
12 Maps an identifier string to a Symbol. | |
13 +/ | |
14 struct SymbolTable | 12 struct SymbolTable |
15 { | 13 { |
16 Symbol[char[]] table; | 14 Symbol[char[]] table; /// The table data structure. |
17 | 15 |
18 /// Look up ident in the table. | 16 /// Looks up ident in the table. |
17 /// Returns: the symbol if there, otherwise null. | |
19 Symbol lookup(Identifier* ident) | 18 Symbol lookup(Identifier* ident) |
20 { | 19 { |
21 assert(ident !is null); | 20 assert(ident !is null); |
22 auto psym = ident.str in table; | 21 auto psym = ident.str in table; |
23 return psym ? *psym : null; | 22 return psym ? *psym : null; |
24 } | 23 } |
25 | 24 |
26 void insert(Symbol s, Identifier* ident) | 25 /// Inserts a symbol into the table. |
26 void insert(Symbol symbol, Identifier* ident) | |
27 { | 27 { |
28 table[ident.str] = s; | 28 table[ident.str] = symbol; |
29 } | 29 } |
30 } | 30 } |