Mercurial > projects > dang
changeset 71:010f46b6641c new_gen
Handled a few more error cases on input.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Thu, 01 May 2008 19:51:22 +0200 |
parents | 70a002b3fba4 |
children | 628cb46ab13b |
files | parser/Parser.d |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/parser/Parser.d Thu May 01 19:30:51 2008 +0200 +++ b/parser/Parser.d Thu May 01 19:51:22 2008 +0200 @@ -180,7 +180,7 @@ Token n = lexer.peek(1); // Must be an decl, if we start with a basic type, or two // identifiers in a row - if (iden.isBasicType() || n.isIdentifier()) + if (iden.isBasicType() && iden.isIdentifier() || n.isIdentifier()) { // manually hardcoded to only support "type id [= exp];" // as that is the only thing the codegen understands @@ -209,7 +209,7 @@ default: if (t.isBasicType()) goto case Tok.Identifier; - throw error(__LINE__, ":(").tok(lexer.peek); + throw error(__LINE__, "Unexpexted begining of statement.").tok(lexer.peek); } throw error(__LINE__, "").tok(t); return null; @@ -379,6 +379,7 @@ return action.actOnNumericConstant(next); Stdout.formatln("{}", next.getType); + throw error(__LINE__, "Expected expression, not '"~next.getType~"'").tok(next); assert(0, "Should not happen"); } @@ -451,7 +452,8 @@ if (lexer.peek().type != t) throw error(__LINE__, PE.UnexpectedTokSingle) .arg(lexer.peek.getType) - .arg(t); + .arg(t) + .tok(lexer.peek); return lexer.next(); }