Mercurial > projects > dil
changeset 262:0f22269e76ff
- Changed some string types to Token*.
- Added and removed some calls to set().
author | aziz |
---|---|
date | Fri, 03 Aug 2007 17:01:05 +0000 |
parents | 966756c5d5d3 |
children | ebcf7941f1db |
files | trunk/src/Declarations.d trunk/src/Parser.d |
diffstat | 2 files changed, 17 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/Declarations.d Fri Aug 03 15:04:03 2007 +0000 +++ b/trunk/src/Declarations.d Fri Aug 03 17:01:05 2007 +0000 @@ -205,11 +205,11 @@ class FunctionDeclaration : Declaration { - string funcName; + Token* funcName; Type funcType; TemplateParameters tparams; FunctionBody funcBody; - this(string funcName, Type funcType, TemplateParameters tparams, FunctionBody funcBody) + this(Token* funcName, Type funcType, TemplateParameters tparams, FunctionBody funcBody) { super(funcBody.funcBody !is null); this.funcName = funcName; @@ -220,9 +220,9 @@ class VariableDeclaration : Declaration { - string[] idents; + Token*[] idents; Expression[] values; - this(string[] idents, Expression[] values) + this(Token*[] idents, Expression[] values) { super(false); this.idents = idents;
--- a/trunk/src/Parser.d Fri Aug 03 15:04:03 2007 +0000 +++ b/trunk/src/Parser.d Fri Aug 03 17:01:05 2007 +0000 @@ -113,6 +113,7 @@ if (token.type == T.Module) { + auto begin = token; ModuleName moduleName; do { @@ -120,7 +121,7 @@ moduleName ~= requireIdentifier(); } while (token.type == T.Dot) require(T.Semicolon); - decls ~= new ModuleDeclaration(moduleName); + decls ~= set(new ModuleDeclaration(moduleName), begin); } decls ~= parseDeclarationDefinitions(); return decls; @@ -151,6 +152,7 @@ Declaration parseDeclarationDefinition() { + auto begin = token; Declaration decl; switch (token.type) { @@ -280,6 +282,7 @@ nT(); } // writef("§%s§", decl.classinfo.name); + set(decl, begin); return decl; } @@ -312,20 +315,20 @@ Declaration parseDeclaration(StorageClass stc = StorageClass.None) { Type type; - string ident; + Token* ident; // Check for AutoDeclaration if (stc != StorageClass.None && token.type == T.Identifier && peekNext() == T.Assign) { - ident = token.identifier; + ident = token; nT(); } else { type = parseType(); - ident = requireIdentifier(); + ident = requireId(); // writefln("trying=%s,errorCount=%d", trying, errorCount); // writefln("ident=%s", ident); // Type FunctionName ( ParameterList ) FunctionBody @@ -351,13 +354,13 @@ } // It's a variable declaration. - string[] idents = [ident]; + Token*[] idents = [ident]; Expression[] values; goto LenterLoop; // We've already parsed an identifier. Jump to if statement and check for initializer. while (token.type == T.Comma) { nT(); - idents ~= requireIdentifier(); + idents ~= requireId(); LenterLoop: if (token.type == T.Assign) { @@ -1419,7 +1422,7 @@ auto e = parseAssignExpression(); require(T.RParen); require(T.Semicolon); - return set(new MixinDeclaration(e), begin); + return new MixinDeclaration(e); } Expression[] templateIdent; @@ -1460,7 +1463,7 @@ require(T.Semicolon); - return set(new Class(templateIdent, mixinIdent), begin); + return new Class(templateIdent, mixinIdent); } /+++++++++++++++++++++++++++++ @@ -1469,10 +1472,11 @@ Statements parseStatements() { + auto begin = token; auto statements = new Statements(); while (token.type != T.RBrace && token.type != T.EOF) statements ~= parseStatement(); - return statements; + return set(statements, begin); } Statement parseStatement()