Mercurial > projects > dil
annotate trunk/src/dil/Identifier.d @ 502:4e14cd1b24da
Refactored code and added modules related to tabulated Identifiers.
Rearranged members of struct Identifier and added new member ID identID.
Moved idTableLookup to module dil.IdTable.
Renamed module TokenIDs to TokensEnum.
Added member Identifier* ident to struct Token.
Changed string switchtes in Parser to integer switches using enum ID.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Tue, 11 Dec 2007 14:19:30 +0100 |
parents | 52447db67938 |
children | 3bb94ba21490 |
rev | line source |
---|---|
274 | 1 /++ |
2 Author: Aziz Köksal | |
3 License: GPL3 | |
4 +/ | |
326 | 5 module dil.Identifier; |
502
4e14cd1b24da
Refactored code and added modules related to tabulated Identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
499
diff
changeset
|
6 import dil.TokensEnum; |
4e14cd1b24da
Refactored code and added modules related to tabulated Identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
499
diff
changeset
|
7 import dil.IdentsEnum; |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
327
diff
changeset
|
8 import common; |
274 | 9 |
502
4e14cd1b24da
Refactored code and added modules related to tabulated Identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
499
diff
changeset
|
10 align(1) |
274 | 11 struct Identifier |
12 { | |
502
4e14cd1b24da
Refactored code and added modules related to tabulated Identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
499
diff
changeset
|
13 string str; |
274 | 14 TOK type; |
502
4e14cd1b24da
Refactored code and added modules related to tabulated Identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
499
diff
changeset
|
15 ID identID; |
274 | 16 |
502
4e14cd1b24da
Refactored code and added modules related to tabulated Identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
499
diff
changeset
|
17 static Identifier* opCall(string str, TOK type, ID identID = ID.Null) |
274 | 18 { |
502
4e14cd1b24da
Refactored code and added modules related to tabulated Identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
499
diff
changeset
|
19 auto id = new Identifier; |
4e14cd1b24da
Refactored code and added modules related to tabulated Identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
499
diff
changeset
|
20 id.str = str; |
4e14cd1b24da
Refactored code and added modules related to tabulated Identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
499
diff
changeset
|
21 id.type = type; |
4e14cd1b24da
Refactored code and added modules related to tabulated Identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
499
diff
changeset
|
22 id.identID = identID; |
4e14cd1b24da
Refactored code and added modules related to tabulated Identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
499
diff
changeset
|
23 return id; |
274 | 24 } |
25 | |
26 uint toHash() | |
27 { | |
28 uint hash; | |
29 foreach(c; str) { | |
30 hash *= 9; | |
31 hash += c; | |
32 } | |
33 return hash; | |
34 } | |
35 } | |
502
4e14cd1b24da
Refactored code and added modules related to tabulated Identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
499
diff
changeset
|
36 // pragma(msg, Identifier.sizeof.stringof); |