# HG changeset patch # User Aziz K?ksal # Date 1200697181 -3600 # Node ID 6b3e397229c509edf5d40dcb4550535be3e74fdd # Parent ff6971637f8855b83462b34c2676693afb9766e4 Renamed Statements, Declarations and EnumMember. Statements -> CompoundStatement. Declarations -> CompoundDeclaration. EnumMember -> EnumMemberDeclaration. diff -r ff6971637f88 -r 6b3e397229c5 trunk/src/cmd/Generate.d --- a/trunk/src/cmd/Generate.d Fri Jan 18 23:40:12 2008 +0100 +++ b/trunk/src/cmd/Generate.d Fri Jan 18 23:59:41 2008 +0100 @@ -97,16 +97,12 @@ { alias NodeCategory NC; case NC.Declaration: - if (node.kind == NodeKind.Declarations || - node.kind == NodeKind.EnumMember) - break; suffixLength = "Declaration".length; break; case NC.Statement: switch (node.kind) { - case NodeKind.Statements, - NodeKind.CatchBody, + case NodeKind.CatchBody, NodeKind.FinallyBody, NodeKind.FunctionBody, NodeKind.AsmInstruction, diff -r ff6971637f88 -r 6b3e397229c5 trunk/src/dil/ast/Declarations.d --- a/trunk/src/dil/ast/Declarations.d Fri Jan 18 23:40:12 2008 +0100 +++ b/trunk/src/dil/ast/Declarations.d Fri Jan 18 23:59:41 2008 +0100 @@ -15,7 +15,7 @@ import dil.Enums; import common; -class Declarations : Declaration +class CompoundDeclaration : Declaration { this() { @@ -28,7 +28,7 @@ addChild(d); } - void opCatAssign(Declarations ds) + void opCatAssign(CompoundDeclaration ds) { addChildren(ds.children); } @@ -159,8 +159,8 @@ { Identifier* name; TypeNode baseType; - EnumMember[] members; - this(Identifier* name, TypeNode baseType, EnumMember[] members, bool hasBody) + EnumMemberDeclaration[] members; + this(Identifier* name, TypeNode baseType, EnumMemberDeclaration[] members, bool hasBody) { super.hasBody = hasBody; mixin(set_kind); @@ -175,7 +175,7 @@ Enum symbol; } -class EnumMember : Declaration +class EnumMemberDeclaration : Declaration { Identifier* name; Expression value; @@ -193,8 +193,8 @@ { Identifier* name; TemplateParameters tparams; - Declarations decls; - this(Identifier* name, TemplateParameters tparams, Declarations decls) + CompoundDeclaration decls; + this(Identifier* name, TemplateParameters tparams, CompoundDeclaration decls) { super.hasBody = decls !is null; this.name = name; @@ -206,7 +206,7 @@ class ClassDeclaration : AggregateDeclaration { BaseClassType[] bases; - this(Identifier* name, TemplateParameters tparams, BaseClassType[] bases, Declarations decls) + this(Identifier* name, TemplateParameters tparams, BaseClassType[] bases, CompoundDeclaration decls) { super(name, tparams, decls); mixin(set_kind); @@ -223,7 +223,7 @@ class InterfaceDeclaration : AggregateDeclaration { BaseClassType[] bases; - this(Identifier* name, TemplateParameters tparams, BaseClassType[] bases, Declarations decls) + this(Identifier* name, TemplateParameters tparams, BaseClassType[] bases, CompoundDeclaration decls) { super(name, tparams, decls); mixin(set_kind); @@ -242,7 +242,7 @@ class StructDeclaration : AggregateDeclaration { uint alignSize; - this(Identifier* name, TemplateParameters tparams, Declarations decls) + this(Identifier* name, TemplateParameters tparams, CompoundDeclaration decls) { super(name, tparams, decls); mixin(set_kind); @@ -260,7 +260,7 @@ class UnionDeclaration : AggregateDeclaration { - this(Identifier* name, TemplateParameters tparams, Declarations decls) + this(Identifier* name, TemplateParameters tparams, CompoundDeclaration decls) { super(name, tparams, decls); mixin(set_kind); @@ -488,8 +488,8 @@ { Identifier* name; TemplateParameters tparams; - Declarations decls; - this(Identifier* name, TemplateParameters tparams, Declarations decls) + CompoundDeclaration decls; + this(Identifier* name, TemplateParameters tparams, CompoundDeclaration decls) { super.hasBody = true; mixin(set_kind); diff -r ff6971637f88 -r 6b3e397229c5 trunk/src/dil/ast/DefaultVisitor.d --- a/trunk/src/dil/ast/DefaultVisitor.d Fri Jan 18 23:40:12 2008 +0100 +++ b/trunk/src/dil/ast/DefaultVisitor.d Fri Jan 18 23:59:41 2008 +0100 @@ -28,7 +28,7 @@ static if (is(T : Declaration)) { alias T D; - static if (is(D == Declarations)) + static if (is(D == CompoundDeclaration)) foreach (node; d.children) visitN(node); //EmptyDeclaration, @@ -44,7 +44,7 @@ foreach (member; d.members) visitD(member); } - static if (is(D == EnumMember)) + static if (is(D == EnumMemberDeclaration)) d.value && visitE(d.value); static if (is(D == ClassDeclaration) || is( D == InterfaceDeclaration)) { @@ -194,7 +194,7 @@ static if (is(T : Statement)) { alias T S; - static if (is(S == Statements)) + static if (is(S == CompoundStatement)) foreach (node; s.children) visitS(cast(Statement)cast(void*)node); //IllegalStatement has no subnodes. diff -r ff6971637f88 -r 6b3e397229c5 trunk/src/dil/ast/Expressions.d --- a/trunk/src/dil/ast/Expressions.d Fri Jan 18 23:40:12 2008 +0100 +++ b/trunk/src/dil/ast/Expressions.d Fri Jan 18 23:59:41 2008 +0100 @@ -483,8 +483,8 @@ Expression[] newArgs; BaseClassType[] bases; Expression[] ctorArgs; - Declarations decls; - this(/*Expression e, */Expression[] newArgs, BaseClassType[] bases, Expression[] ctorArgs, Declarations decls) + CompoundDeclaration decls; + this(/*Expression e, */Expression[] newArgs, BaseClassType[] bases, Expression[] ctorArgs, CompoundDeclaration decls) { /*super(e);*/ mixin(set_kind); diff -r ff6971637f88 -r 6b3e397229c5 trunk/src/dil/ast/NodesEnum.d --- a/trunk/src/dil/ast/NodesEnum.d Fri Jan 18 23:40:12 2008 +0100 +++ b/trunk/src/dil/ast/NodesEnum.d Fri Jan 18 23:59:41 2008 +0100 @@ -17,7 +17,7 @@ /// Array of class names that inherit from Node. static const char[][] classNames = [ // Declarations: - "Declarations", + "CompoundDeclaration", "EmptyDeclaration", "IllegalDeclaration", "ModuleDeclaration", @@ -25,7 +25,7 @@ "AliasDeclaration", "TypedefDeclaration", "EnumDeclaration", - "EnumMember", + "EnumMemberDeclaration", "ClassDeclaration", "InterfaceDeclaration", "StructDeclaration", @@ -53,7 +53,7 @@ "MixinDeclaration", // Statements: - "Statements", + "CompoundStatement", "IllegalStatement", "EmptyStatement", "FunctionBody", diff -r ff6971637f88 -r 6b3e397229c5 trunk/src/dil/ast/Statements.d --- a/trunk/src/dil/ast/Statements.d Fri Jan 18 23:40:12 2008 +0100 +++ b/trunk/src/dil/ast/Statements.d Fri Jan 18 23:59:41 2008 +0100 @@ -12,7 +12,7 @@ import dil.ast.Parameters; import dil.lexer.IdTable; -class Statements : Statement +class CompoundStatement : Statement { this() { @@ -418,8 +418,8 @@ class AsmStatement : Statement { - Statements statements; - this(Statements statements) + CompoundStatement statements; + this(CompoundStatement statements) { mixin(set_kind); addChild(statements); diff -r ff6971637f88 -r 6b3e397229c5 trunk/src/dil/doc/Doc.d --- a/trunk/src/dil/doc/Doc.d Fri Jan 18 23:40:12 2008 +0100 +++ b/trunk/src/dil/doc/Doc.d Fri Jan 18 23:59:41 2008 +0100 @@ -34,13 +34,13 @@ token.kind == TOK.RBrace || token.kind == TOK.Semicolon || token.kind == TOK.HEAD || - (node.kind == NodeKind.EnumMember && token.kind == TOK.Comma)) + (node.kind == NodeKind.EnumMemberDeclaration && token.kind == TOK.Comma)) break; if (token.kind == TOK.Comment) { // Check that this comment doesn't belong to the previous declaration. - if (node.kind == NodeKind.EnumMember && token.kind == TOK.Comma) + if (node.kind == NodeKind.EnumMemberDeclaration && token.kind == TOK.Comma) break; switch (token.prev.kind) { @@ -56,7 +56,7 @@ token = node.end.next; if (token.kind == TOK.Comment && isDocComment(token)) comments ~= token; - else if (node.kind == NodeKind.EnumMember) + else if (node.kind == NodeKind.EnumMemberDeclaration) { token = node.end.nextNWS; if (token.kind == TOK.Comma) diff -r ff6971637f88 -r 6b3e397229c5 trunk/src/dil/parser/ImportParser.d --- a/trunk/src/dil/parser/ImportParser.d Fri Jan 18 23:40:12 2008 +0100 +++ b/trunk/src/dil/parser/ImportParser.d Fri Jan 18 23:59:41 2008 +0100 @@ -20,9 +20,9 @@ super(srcText, fileName); } - override Declarations start() + override CompoundDeclaration start() { - auto decls = new Declarations; + auto decls = new CompoundDeclaration; super.init(); if (token.kind == T.Module) decls ~= parseModuleDeclaration(); diff -r ff6971637f88 -r 6b3e397229c5 trunk/src/dil/parser/Parser.d --- a/trunk/src/dil/parser/Parser.d Fri Jan 18 23:40:12 2008 +0100 +++ b/trunk/src/dil/parser/Parser.d Fri Jan 18 23:59:41 2008 +0100 @@ -73,11 +73,11 @@ /++ Start the parser and return the parsed Declarations. +/ - Declarations start() + CompoundDeclaration start() { init(); auto begin = token; - auto decls = new Declarations; + auto decls = new CompoundDeclaration; if (token.kind == T.Module) decls ~= parseModuleDeclaration(); decls.addOptChildren(parseDeclarationDefinitions()); @@ -204,7 +204,7 @@ { } { DeclDefs } +/ - Declarations parseDeclarationDefinitionsBody() + CompoundDeclaration parseDeclarationDefinitionsBody() { // Save attributes. auto linkageType = this.linkageType; @@ -217,7 +217,7 @@ // Parse body. auto begin = token; - auto decls = new Declarations; + auto decls = new CompoundDeclaration; require(T.LBrace); while (token.kind != T.RBrace && token.kind != T.EOF) decls ~= parseDeclarationDefinition(); @@ -405,7 +405,7 @@ case T.LBrace: auto begin = token; nT(); - auto decls = new Declarations; + auto decls = new CompoundDeclaration; while (token.kind != T.RBrace && token.kind != T.EOF) decls ~= parseDeclarationDefinition(); require(T.RBrace); @@ -416,7 +416,7 @@ goto default; nT(); auto begin = token; - auto decls = new Declarations; + auto decls = new CompoundDeclaration; while (token.kind != T.RBrace && token.kind != T.EOF) decls ~= parseDeclarationDefinition(); d = set(decls, begin); @@ -995,7 +995,7 @@ Identifier* enumName; Type baseType; - EnumMember[] members; + EnumMemberDeclaration[] members; bool hasBody; enumName = optionalIdentifier(); @@ -1019,7 +1019,7 @@ else value = null; - members ~= set(new EnumMember(name, value), begin); + members ~= set(new EnumMemberDeclaration(name, value), begin); if (token.kind != T.Comma) break; @@ -1041,7 +1041,7 @@ Identifier* className; TemplateParameters tparams; BaseClassType[] bases; - Declarations decls; + CompoundDeclaration decls; className = requireIdentifier(MSG.ExpectedClassName); @@ -1102,7 +1102,7 @@ Identifier* name; TemplateParameters tparams; BaseClassType[] bases; - Declarations decls; + CompoundDeclaration decls; name = requireIdentifier(MSG.ExpectedInterfaceName); @@ -1130,7 +1130,7 @@ Identifier* name; TemplateParameters tparams; - Declarations decls; + CompoundDeclaration decls; name = optionalIdentifier(); @@ -1422,11 +1422,11 @@ + Statement parsing methods + +++++++++++++++++++++++++++++/ - Statements parseStatements() + CompoundStatement parseStatements() { auto begin = token; require(T.LBrace); - auto statements = new Statements(); + auto statements = new CompoundStatement(); while (token.kind != T.RBrace && token.kind != T.EOF) statements ~= parseStatement(); require(T.RBrace); @@ -1461,7 +1461,7 @@ else expected(T.Struct); - d = new AlignDeclaration(size, structDecl ? cast(Declaration)structDecl : new Declarations); + d = new AlignDeclaration(size, structDecl ? cast(Declaration)structDecl : new CompoundDeclaration); goto LreturnDeclarationStatement; /+ Not applicable for statements. T.Private, T.Package, T.Protected, T.Public, T.Export, @@ -1694,7 +1694,7 @@ Statement s; if (skipped(T.LBrace)) { - auto ss = new Statements(); + auto ss = new CompoundStatement(); while (token.kind != T.RBrace && token.kind != T.EOF) ss ~= parseStatement(); require(T.RBrace); @@ -1978,7 +1978,7 @@ { // This function is similar to parseNoScopeStatement() auto begin = token; - auto s = new Statements(); + auto s = new CompoundStatement(); while (token.kind != T.Case && token.kind != T.Default && token.kind != T.RBrace && @@ -2275,7 +2275,7 @@ assert(token.kind == T.Asm); nT(); // Skip asm keyword. require(T.LBrace); - auto ss = new Statements; + auto ss = new CompoundStatement; while (token.kind != T.RBrace && token.kind != T.EOF) ss ~= parseAsmInstruction(); require(T.RBrace); diff -r ff6971637f88 -r 6b3e397229c5 trunk/src/dil/semantic/Module.d --- a/trunk/src/dil/semantic/Module.d Fri Jan 18 23:40:12 2008 +0100 +++ b/trunk/src/dil/semantic/Module.d Fri Jan 18 23:59:41 2008 +0100 @@ -28,7 +28,7 @@ string packageName; string moduleName; - Declarations root; /// The root of the AST. + CompoundDeclaration root; /// The root of the AST. ImportDeclaration[] imports; ModuleDeclaration moduleDecl; private Parser parser; diff -r ff6971637f88 -r 6b3e397229c5 trunk/src/dil/semantic/Pass1.d --- a/trunk/src/dil/semantic/Pass1.d Fri Jan 18 23:40:12 2008 +0100 +++ b/trunk/src/dil/semantic/Pass1.d Fri Jan 18 23:59:41 2008 +0100 @@ -62,7 +62,7 @@ override { - Declaration visit(Declarations d) + Declaration visit(CompoundDeclaration d) { foreach (node; d.children) { @@ -151,7 +151,7 @@ return ed; } - Declaration visit(EnumMember) + Declaration visit(EnumMemberDeclaration) { return null; } Declaration visit(ClassDeclaration d)