1 /// Author: Aziz Köksal 2 /// License: GPL3 3 /// $(Maturity very high) 4 module dil.lexer.IDsList; 5 6 /// The list of keywords in D. 7 enum keywordIDs = (){ 8 enum words = [ 9 "__argTypes", // D2 10 "__gshared", // D2 11 "__overloadset", // D2 12 "__parameters", // D2 13 "__traits", // D2 14 "__vector", // D2 15 "abstract", 16 "alias", 17 "align", 18 "asm", 19 "assert", 20 "auto", 21 "body", 22 "bool", 23 "break", 24 "byte", 25 "case", 26 "cast", 27 "catch", 28 "cdouble", 29 "cent", 30 "cfloat", 31 "char", 32 "class", 33 "const", 34 "continue", 35 "creal", 36 "dchar", 37 "debug", 38 "default", 39 "delegate", 40 "delete", 41 "deprecated", 42 "do", 43 "double", 44 "else", 45 "enum", 46 "export", 47 "extern", 48 "false", 49 "final", 50 "finally", 51 "float", 52 "for", 53 "foreach", 54 "foreach_reverse", 55 "function", 56 "goto", 57 "idouble", 58 "if", 59 "ifloat", 60 "immutable", // D2 61 "import", 62 "in", 63 "inout", 64 "int", 65 "interface", 66 "invariant", 67 "ireal", 68 "is", 69 "lazy", 70 "long", 71 "macro", // D2 72 "mixin", 73 "module", 74 "new", 75 "nothrow", // D2 76 "null", 77 "out", 78 "override", 79 "package", 80 "pragma", 81 "private", 82 "protected", 83 "public", 84 "pure", // D2 85 "real", 86 "ref", 87 "return", 88 "scope", 89 "shared", // D2 90 "short", 91 "static", 92 "struct", 93 "super", 94 "switch", 95 "synchronized", 96 "template", 97 "this", 98 "throw", 99 "true", 100 "try", 101 "typedef", 102 "typeid", 103 "typeof", 104 "ubyte", 105 "ucent", 106 "uint", 107 "ulong", 108 "union", 109 "unittest", 110 "ushort", 111 "version", 112 "void", 113 "volatile", 114 "wchar", 115 "while", 116 "with", 117 ]; 118 119 auto list = new string[2][words.length]; 120 foreach (i, w; words) 121 { 122 auto n = w.dup; 123 if (n[0] == '_') 124 n = n[2..$]; // E.g.: "__gshared" -> "gshared" 125 n[0] -= 0x20; // E.g.: "gshared" -> "Gshared" 126 list[i] = [n.idup, w]; // E.g.: ["Gshared", "__gshared"] 127 } 128 return list; 129 }(); 130 131 enum specialIDs = [ 132 ["FILE", "__FILE__"], 133 ["LINE", "__LINE__"], 134 ["DATE", "__DATE__"], 135 ["TIME", "__TIME__"], 136 ["TIMESTAMP", "__TIMESTAMP__"], 137 ["VENDOR", "__VENDOR__"], 138 ["VERSION", "__VERSION__"], 139 ["MODULE", "__MODULE__"], // D2 140 ["FUNCTION", "__FUNCTION__"], // D2 141 ["PFUNCTION", "__PRETTY_FUNCTION__"], // D2 142 ["EOF", "__EOF__"], // D2 143 ]; 144 145 /// Table of common and often used identifiers. 146 /// 147 /// $(BNF 148 ////PredefinedIdentifier := SourceCodeName (":" IdText)? 149 ////SourceCodeName := Identifier # The name to be used in the source code. 150 ////IdText := Empty | Identifier # The actual text of the identifier. 151 ////Empty := "" # IdText may be empty. 152 ////Identifier := see module $(MODLINK dil.lexer.Identifier). 153 ////) 154 /// NB: If IdText is not defined it defaults to SourceCodeName. 155 enum predefinedIDs = (){ 156 enum pairs = [ 157 // Special empty identifier: 158 "Empty:", 159 // Just "Identifier" (with '_' to avoid symbol conflicts): 160 "Identifier_:Identifier", 161 "SpecialID", 162 // Predefined version identifiers: 163 "DigitalMars", "X86", "X86_64", 164 /*"Windows", */"Win32", "Win64", 165 "Linux:linux", "LittleEndian", "BigEndian", 166 "D_Coverage", "D_InlineAsm_X86", "D_Version2", 167 "none", "all", 168 // Variadic parameters: 169 "Arguments:_arguments", "Argptr:_argptr", 170 // scope(Identifier): 171 "exit", "success", "failure", 172 // pragma: 173 "msg", "lib", "startaddress", 174 // Linkage: 175 "C", "D", "Windows", "Pascal", "System", 176 // Con-/Destructor: 177 "Ctor:__ctor", "Dtor:__dtor", 178 // new() and delete() methods. 179 "NewFn:__new", "DeleteFn:__delete", 180 // Unittest and invariant. 181 "UnittestFn:__unittest", "InvariantFn:__invariant", 182 // Attributes (D2): 183 "disable", "property", /+"safe", "system",+/ "trusted", 184 // Operator overload names: 185 "opNeg", "opPos", "opCom", 186 "opEquals", "opCmp", "opAssign", 187 "opAdd", "opAdd_r", "opAddAssign", 188 "opSub", "opSub_r", "opSubAssign", 189 "opMul", "opMul_r", "opMulAssign", 190 "opDiv", "opDiv_r", "opDivAssign", 191 "opMod", "opMod_r", "opModAssign", 192 "opAnd", "opAnd_r", "opAndAssign", 193 "opOr", "opOr_r", "opOrAssign", 194 "opXor", "opXor_r", "opXorAssign", 195 "opShl", "opShl_r", "opShlAssign", 196 "opShr", "opShr_r", "opShrAssign", 197 "opUShr", "opUShr_r", "opUShrAssign", 198 "opCat", "opCat_r", "opCatAssign", 199 "opIn", "opIn_r", 200 "opIndex", "opIndexAssign", 201 "opSlice", "opSliceAssign", 202 "opPostInc", 203 "opPostDec", 204 "opCall", 205 "opCast", 206 "opStar", // D2 207 // foreach and foreach_reverse: 208 "opApply", "opApplyReverse", 209 // Entry functions: 210 "main", "WinMain", "DllMain", 211 // D2 module (system|safe) 212 "system", "safe", 213 // From object.d 214 "object", "Object", "Interface_:Interface", 215 "Throwable", "Exception", "Error", 216 "ClassInfo", "TypeInfo", "OffsetTypeInfo", 217 "ModuleInfo", "FrameInfo", "TraceInfo", 218 "ptrdiff_t", "size_t", "ssize_t", "hash_t", "equals_t", 219 // TypeInfo classes 220 "TypeInfo_Pointer", 221 "TypeInfo_Array", 222 "TypeInfo_StaticArray", 223 "TypeInfo_AssociativeArray", 224 "TypeInfo_Function", 225 "TypeInfo_Delegate", 226 "TypeInfo_Enum", 227 "TypeInfo_Class", 228 "TypeInfo_Interface", 229 "TypeInfo_Struct", 230 "TypeInfo_Tuple", 231 "TypeInfo_Typedef", 232 "TypeInfo_Vector", // D2 233 "TypeInfo_Const", // D2 234 "TypeInfo_Invariant", // D2 235 "TypeInfo_Shared", // D2 236 "TypeInfo_Inout", // D2 237 // Special properties 238 "Sizeof:sizeof", "Alignof:alignof", "Mangleof:mangleof", 239 // ASM identifiers: 240 "near", "far", "word", "dword", "qword", 241 "ptr", "offsetof", "seg", "__LOCAL_SIZE", 242 "FS", "ST", 243 "AL", "AH", "AX", "EAX", 244 "BL", "BH", "BX", "EBX", 245 "CL", "CH", "CX", "ECX", 246 "DL", "DH", "DX", "EDX", 247 "BP", "EBP", "SP", "ESP", 248 "DI", "EDI", "SI", "ESI", 249 "ES", "CS", "SS", "DS", "GS", 250 "CR0", "CR2", "CR3", "CR4", 251 "DR0", "DR1", "DR2", "DR3", "DR6", "DR7", 252 "TR3", "TR4", "TR5", "TR6", "TR7", 253 "MM0", "MM1", "MM2", "MM3", 254 "MM4", "MM5", "MM6", "MM7", 255 "XMM0", "XMM1", "XMM2", "XMM3", 256 "XMM4", "XMM5", "XMM6", "XMM7", 257 // ASM jump opcodes: 258 "ja", "jae", "jb", "jbe", "jc", 259 "jcxz", "je", "jecxz", "jg", "jge", 260 "jl", "jle", "jmp", "jna", "jnae", 261 "jnb", "jnbe", "jnc", "jne", "jng", 262 "jnge", "jnl", "jnle", "jno", "jnp", 263 "jns", "jnz", "jo", "jp", "jpe", 264 "jpo", "js", "jz", 265 ]; 266 /// Splits txt at ':' and returns a tuple. 267 string[2] getPair(string txt) 268 { 269 foreach (i, c; txt) 270 if (c == ':') 271 return [txt[0..i], txt[i+1..txt.length]]; 272 return [txt, txt]; 273 } 274 auto list = new string[2][pairs.length]; 275 foreach (i, pair; pairs) 276 list[i] = getPair(pair); 277 return list; 278 }();