diff src/dil/ast/NodesEnum.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/ast/NodesEnum.d@cf2ad5df025c
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/dil/ast/NodesEnum.d	Sun Mar 09 00:12:19 2008 +0100
@@ -0,0 +1,234 @@
+/++
+  Author: Aziz Köksal
+  License: GPL3
++/
+module dil.ast.NodesEnum;
+
+/// Enumerates the categories of a node.
+enum NodeCategory : ushort
+{
+  Undefined,
+  Declaration,
+  Statement,
+  Expression,
+  Type,
+  Other
+}
+
+/// A list of all class names that inherit from Node.
+static const char[][] g_classNames = [
+  // Declarations:
+  "CompoundDeclaration",
+  "EmptyDeclaration",
+  "IllegalDeclaration",
+  "ModuleDeclaration",
+  "ImportDeclaration",
+  "AliasDeclaration",
+  "TypedefDeclaration",
+  "EnumDeclaration",
+  "EnumMemberDeclaration",
+  "ClassDeclaration",
+  "InterfaceDeclaration",
+  "StructDeclaration",
+  "UnionDeclaration",
+  "ConstructorDeclaration",
+  "StaticConstructorDeclaration",
+  "DestructorDeclaration",
+  "StaticDestructorDeclaration",
+  "FunctionDeclaration",
+  "VariablesDeclaration",
+  "InvariantDeclaration",
+  "UnittestDeclaration",
+  "DebugDeclaration",
+  "VersionDeclaration",
+  "StaticIfDeclaration",
+  "StaticAssertDeclaration",
+  "TemplateDeclaration",
+  "NewDeclaration",
+  "DeleteDeclaration",
+  "ProtectionDeclaration",
+  "StorageClassDeclaration",
+  "LinkageDeclaration",
+  "AlignDeclaration",
+  "PragmaDeclaration",
+  "MixinDeclaration",
+
+  // Statements:
+  "CompoundStatement",
+  "IllegalStatement",
+  "EmptyStatement",
+  "FuncBodyStatement",
+  "ScopeStatement",
+  "LabeledStatement",
+  "ExpressionStatement",
+  "DeclarationStatement",
+  "IfStatement",
+  "WhileStatement",
+  "DoWhileStatement",
+  "ForStatement",
+  "ForeachStatement",
+  "ForeachRangeStatement", // D2.0
+  "SwitchStatement",
+  "CaseStatement",
+  "DefaultStatement",
+  "ContinueStatement",
+  "BreakStatement",
+  "ReturnStatement",
+  "GotoStatement",
+  "WithStatement",
+  "SynchronizedStatement",
+  "TryStatement",
+  "CatchStatement",
+  "FinallyStatement",
+  "ScopeGuardStatement",
+  "ThrowStatement",
+  "VolatileStatement",
+  "AsmBlockStatement",
+  "AsmStatement",
+  "AsmAlignStatement",
+  "IllegalAsmStatement",
+  "PragmaStatement",
+  "MixinStatement",
+  "StaticIfStatement",
+  "StaticAssertStatement",
+  "DebugStatement",
+  "VersionStatement",
+
+  // Expressions:
+  "IllegalExpression",
+  "CondExpression",
+  "CommaExpression",
+  "OrOrExpression",
+  "AndAndExpression",
+  "OrExpression",
+  "XorExpression",
+  "AndExpression",
+  "EqualExpression",
+  "IdentityExpression",
+  "RelExpression",
+  "InExpression",
+  "LShiftExpression",
+  "RShiftExpression",
+  "URShiftExpression",
+  "PlusExpression",
+  "MinusExpression",
+  "CatExpression",
+  "MulExpression",
+  "DivExpression",
+  "ModExpression",
+  "AssignExpression",
+  "LShiftAssignExpression",
+  "RShiftAssignExpression",
+  "URShiftAssignExpression",
+  "OrAssignExpression",
+  "AndAssignExpression",
+  "PlusAssignExpression",
+  "MinusAssignExpression",
+  "DivAssignExpression",
+  "MulAssignExpression",
+  "ModAssignExpression",
+  "XorAssignExpression",
+  "CatAssignExpression",
+  "AddressExpression",
+  "PreIncrExpression",
+  "PreDecrExpression",
+  "PostIncrExpression",
+  "PostDecrExpression",
+  "DerefExpression",
+  "SignExpression",
+  "NotExpression",
+  "CompExpression",
+  "CallExpression",
+  "NewExpression",
+  "NewAnonClassExpression",
+  "DeleteExpression",
+  "CastExpression",
+  "IndexExpression",
+  "SliceExpression",
+  "ModuleScopeExpression",
+  "IdentifierExpression",
+  "SpecialTokenExpression",
+  "DotExpression",
+  "TemplateInstanceExpression",
+  "ThisExpression",
+  "SuperExpression",
+  "NullExpression",
+  "DollarExpression",
+  "BoolExpression",
+  "IntExpression",
+  "RealExpression",
+  "ComplexExpression",
+  "CharExpression",
+  "StringExpression",
+  "ArrayLiteralExpression",
+  "AArrayLiteralExpression",
+  "AssertExpression",
+  "MixinExpression",
+  "ImportExpression",
+  "TypeofExpression",
+  "TypeDotIdExpression",
+  "TypeidExpression",
+  "IsExpression",
+  "ParenExpression",
+  "FunctionLiteralExpression",
+  "TraitsExpression", // D2.0
+  "VoidInitExpression",
+  "ArrayInitExpression",
+  "StructInitExpression",
+  "AsmTypeExpression",
+  "AsmOffsetExpression",
+  "AsmSegExpression",
+  "AsmPostBracketExpression",
+  "AsmBracketExpression",
+  "AsmLocalSizeExpression",
+  "AsmRegisterExpression",
+
+  // Types:
+  "IllegalType",
+  "IntegralType",
+  "QualifiedType",
+  "ModuleScopeType",
+  "IdentifierType",
+  "TypeofType",
+  "TemplateInstanceType",
+  "PointerType",
+  "ArrayType",
+  "FunctionType",
+  "DelegateType",
+  "CFuncPointerType",
+  "BaseClassType",
+  "ConstType", // D2.0
+  "InvariantType", // D2.0
+
+  // Other:
+  "Parameter",
+  "Parameters",
+  "TemplateAliasParameter",
+  "TemplateTypeParameter",
+  "TemplateThisParameter", // D2.0
+  "TemplateValueParameter",
+  "TemplateTupleParameter",
+  "TemplateParameters",
+  "TemplateArguments",
+];
+
+/// Generates the members of enum NodeKind.
+char[] generateNodeKindMembers()
+{
+  char[] text;
+  foreach (className; g_classNames)
+    text ~= className ~ ",";
+  return text;
+}
+// pragma(msg, generateNodeKindMembers());
+
+version(DDoc)
+  /// The node kind identifies every class that inherits from Node.
+  enum NodeKind : ushort;
+else
+mixin(
+  "enum NodeKind : ushort"
+  "{"
+    ~ generateNodeKindMembers ~
+  "}"
+);