# HG changeset patch # User Anders Johnsen # Date 1209664282 -7200 # Node ID 010f46b6641c7ef6c0a549e209e0255197e57748 # Parent 70a002b3fba45c65bf8347d22871663266ce3070 Handled a few more error cases on input. diff -r 70a002b3fba4 -r 010f46b6641c parser/Parser.d --- 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(); }