comparison 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
comparison
equal deleted inserted replaced
805:a3fab8b74a7d 806:bcb74c9b895c
1 /++
2 Author: Aziz Köksal
3 License: GPL3
4 +/
5 module dil.lexer.Identifier;
6
7 import dil.lexer.TokensEnum;
8 import dil.lexer.IdentsEnum;
9 import common;
10
11 /// Represents an identifier as defined in the D specs.
12 ///
13 ///<pre>
14 /// Identifier := IdStart IdChar*
15 /// IdStart := "_" | Letter
16 /// IdChar := IdStart | "0"-"9"
17 /// Letter := UniAlpha
18 ///</pre>
19 /// Unicode alphas are defined in Unicode 5.0.0.
20 align(1)
21 struct Identifier
22 {
23 string str; /// The UTF-8 string of the identifier.
24 TOK kind; /// The token kind.
25 IDK idKind; /// Only for predefined identifiers.
26
27 static Identifier* opCall(string str, TOK kind)
28 {
29 auto id = new Identifier;
30 id.str = str;
31 id.kind = kind;
32 return id;
33 }
34
35 static Identifier* opCall(string str, TOK kind, IDK idKind)
36 {
37 auto id = new Identifier;
38 id.str = str;
39 id.kind = kind;
40 id.idKind = idKind;
41 return id;
42 }
43
44 uint toHash()
45 {
46 uint hash;
47 foreach(c; str) {
48 hash *= 11;
49 hash += c;
50 }
51 return hash;
52 }
53 }
54 // pragma(msg, Identifier.sizeof.stringof);