Mercurial > projects > dil
view src/dil/lexer/Identifier.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/lexer/Identifier.d@9f61e8af55d5 |
children |
line wrap: on
line source
/++ Author: Aziz Köksal License: GPL3 +/ module dil.lexer.Identifier; import dil.lexer.TokensEnum; import dil.lexer.IdentsEnum; import common; /// Represents an identifier as defined in the D specs. /// ///<pre> /// Identifier := IdStart IdChar* /// IdStart := "_" | Letter /// IdChar := IdStart | "0"-"9" /// Letter := UniAlpha ///</pre> /// Unicode alphas are defined in Unicode 5.0.0. align(1) struct Identifier { string str; /// The UTF-8 string of the identifier. TOK kind; /// The token kind. IDK idKind; /// Only for predefined identifiers. static Identifier* opCall(string str, TOK kind) { auto id = new Identifier; id.str = str; id.kind = kind; return id; } static Identifier* opCall(string str, TOK kind, IDK idKind) { auto id = new Identifier; id.str = str; id.kind = kind; id.idKind = idKind; return id; } uint toHash() { uint hash; foreach(c; str) { hash *= 11; hash += c; } return hash; } } // pragma(msg, Identifier.sizeof.stringof);