view 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
line wrap: on
line source

/++
  Author: Aziz Köksal
  License: GPL3
+/
module dil.Identifier;
import dil.TokensEnum;
import dil.IdentsEnum;
import common;

align(1)
struct Identifier
{
  string str;
  TOK type;
  ID identID;

  static Identifier* opCall(string str, TOK type, ID identID = ID.Null)
  {
    auto id = new Identifier;
    id.str = str;
    id.type = type;
    id.identID = identID;
    return id;
  }

  uint toHash()
  {
    uint hash;
    foreach(c; str) {
      hash *= 9;
      hash += c;
    }
    return hash;
  }
}
// pragma(msg, Identifier.sizeof.stringof);