Mercurial > projects > dang
changeset 154:0ea5d2f3e96b
Parsing "this" as constructor. Also removed regex from the test run program(seg fault - dmd???)
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Mon, 21 Jul 2008 21:45:54 +0200 |
parents | ee202c72cd30 |
children | 2149f4a7b48d 2c5a8061aa4a |
files | lexer/Keyword.d lexer/Lexer.d lexer/Token.d parser/Parser.d tests/run.d |
diffstat | 5 files changed, 28 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/lexer/Keyword.d Mon Jul 21 21:32:20 2008 +0200 +++ b/lexer/Keyword.d Mon Jul 21 21:45:54 2008 +0200 @@ -45,6 +45,8 @@ "typeof" : Tok.Typeof, "sizeof" : Tok.Sizeof, "alias" : Tok.Alias, + "this" : Tok.This, +// "super" : Tok.Super, // control flow "if" : Tok.If,
--- a/lexer/Lexer.d Mon Jul 21 21:32:20 2008 +0200 +++ b/lexer/Lexer.d Mon Jul 21 21:45:54 2008 +0200 @@ -84,7 +84,7 @@ { case CharType.EOF: SLoc loc; - return Token(Tok.EOF, loc + 1, 0); + return Token(Tok.EOF, loc+1, 0); case CharType.Whitespace: position += 1;
--- a/lexer/Token.d Mon Jul 21 21:32:20 2008 +0200 +++ b/lexer/Token.d Mon Jul 21 21:45:54 2008 +0200 @@ -195,7 +195,7 @@ Void, - Struct, Function, Delegate, Class, + Struct, Function, Delegate, Class, This, Interface, Union, Typedef, Typeid, Typeof, Sizeof, Alias, @@ -290,6 +290,8 @@ Tok.Comma:"Comma", Tok.Return:"Return", Tok.Struct:"Struct", + Tok.Class:"Class", + Tok.This:"This", Tok.Colon:"Colon", Tok.Seperator:"Seperator", Tok.Cast:"Cast",
--- a/parser/Parser.d Mon Jul 21 21:32:20 2008 +0200 +++ b/parser/Parser.d Mon Jul 21 21:45:54 2008 +0200 @@ -101,7 +101,10 @@ else if ( isa(Tok.OpenParentheses) ) return parseFunc(type, iden, att); else - messages.report(UnexpectedTok, next().location).arg(next().getType); + { + auto n1 = next(); + messages.report(UnexpectedTok, n1.location).arg(n1.getType); + } return null; } t = peek(len); @@ -109,8 +112,12 @@ .arg(sm.getText(t.asRange)); while(len--) next(); - while(peek.type != Tok.Identifier) + while( !isa(Tok.Identifier) && !isa(Tok.EOF)) next(); + if ( isa(Tok.EOF ) ) + messages.report(UnexpectedTok, t.location) + .fatal(ExitLevel.Parser); + type = Id(peek); goto parseDeclAfterInvalidType; } @@ -356,8 +363,17 @@ while ( peek.isAttribute ) nes ~= parseAttribute(nes[$-1]); - auto m_decl = parseDecl(nes[$-1].a); - action.actOnClassMember(decl, m_decl); + switch(peek.type) + { + case Tok.This: + auto id = Id(next); + auto m_decl = parseFunc(iden, id, nes[$-1].a); + break; + + default: + auto m_decl = parseDecl(nes[$-1].a); + action.actOnClassMember(decl, m_decl); + } nes = parseAttributeScope(nes); }
--- a/tests/run.d Mon Jul 21 21:32:20 2008 +0200 +++ b/tests/run.d Mon Jul 21 21:45:54 2008 +0200 @@ -35,14 +35,14 @@ void main(char[][] args) { scope scan = new FileScan; - scope regex = new Regex(valid_filenames); +// scope regex = new Regex(valid_filenames); // DMD FAILS!! ?? // Return true for files/folders to include bool filter(FilePath p, bool isDir) { if (isDir) return p.name[0] != '.'; else - return p.ext == "d" && regex.test(p.name); + return p.ext == "d" ; //&& regex.test(p.name); } scan.sweep(test_folder, &filter, true); FilePath[] files = scan.files;