view trunk/src/dil/lexer/Identifier.d @ 600:041eae272362

Moved dil.Identifier to dil.lexer.Identifier.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sun, 06 Jan 2008 00:52:20 +0100
parents trunk/src/dil/Identifier.d@4d50267f59c9
children c2e35c83c394
line wrap: on
line source

/++
  Author: Aziz Köksal
  License: GPL3
+/
module dil.lexer.Identifier;

import dil.lexer.TokensEnum;
import dil.IdentsEnum;
import common;

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

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

  static Identifier* opCall(string str, TOK type, ID identID)
  {
    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);