Mercurial > projects > dang
diff parser/Parser.d @ 150:6c5a3c0bb4fb
Make switch work again
Also added locations to statements (only filled out for switch)
Added a verification pass
Removed some comments
author | Anders Halager <halager@gmail.com> |
---|---|
date | Mon, 21 Jul 2008 20:35:03 +0200 |
parents | 8c09fdaa724e |
children | aeeef0dea14e |
line wrap: on
line diff
--- a/parser/Parser.d Mon Jul 21 19:17:56 2008 +0200 +++ b/parser/Parser.d Mon Jul 21 20:35:03 2008 +0200 @@ -632,26 +632,27 @@ require(Tok.Seperator); return action.actOnExprStmt(exp); } - else if(t.isSwitch) + else if (t.isSwitch) { - next; + next(); require(Tok.OpenParentheses); auto target = parseExpression(); - auto res = action.actOnStartOfSwitchStmt(target); + auto res = action.actOnStartOfSwitchStmt(t, target); require(Tok.CloseParentheses); require(Tok.OpenBrace); while (true) { Stmt[] statements; - if (skip(Tok.Default)) + if (isa(Tok.Default)) { + Token _default = next(); require(Tok.Colon); statements.length = 0; while (peek.type != Tok.Case && peek.type != Tok.Default && peek.type != Tok.CloseBrace) statements ~= parseStatement(); - action.actOnDefaultStmt(res, statements); + action.actOnDefaultStmt(res, _default, statements); continue; } @@ -664,10 +665,6 @@ do { Exp e = parseExpression(); -// IntegerLit lit = cast(IntegerLit)e; -// if (lit is null) -// messages.report(CaseValueMustBeInt, peek.location).arg(next.getType); -// else literals ~= e; } while (skip(Tok.Comma)); @@ -678,7 +675,7 @@ && peek.type != Tok.CloseBrace) statements ~= parseStatement(); - action.actOnCaseStmt(res, literals, statements); + action.actOnCaseStmt(res, _case, literals, statements); if (peek.type == Tok.CloseBrace) break;