From ec2bce20b19a20b4ebc17e4cb82a0bfbcda15c50 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 1 Dec 2006 19:45:31 +0000 Subject: [PATCH] Remove old build info Convert exception types --- Package | 5 ----- source/Module | 4 ---- source/parser.cpp | 41 +++++++++++++++++++++-------------------- source/value.h | 4 +++- 4 files changed, 24 insertions(+), 30 deletions(-) delete mode 100644 Package delete mode 100644 source/Module diff --git a/Package b/Package deleted file mode 100644 index 85665eb..0000000 --- a/Package +++ /dev/null @@ -1,5 +0,0 @@ -package="mspparser" -version="0.2" -description="Mikkosoft Productions datafile parser" -requires=("mspmisc",) -tarballfiles=("License.txt",) diff --git a/source/Module b/source/Module deleted file mode 100644 index 11b9baf..0000000 --- a/source/Module +++ /dev/null @@ -1,4 +0,0 @@ -type="library" -target="mspparser" -installheaders="parser" -installtarget=1 diff --git a/source/parser.cpp b/source/parser.cpp index f74be86..c47969b 100644 --- a/source/parser.cpp +++ b/source/parser.cpp @@ -5,7 +5,7 @@ Distributed under the LGPL */ #include #include -#include +#include "error.h" #include "parser.h" #include "statement.h" #include "token.h" @@ -25,7 +25,7 @@ Statement Parser::parse() { if(!good) throw Exception("Parser is not good"); - + try { return parse_(0); @@ -42,7 +42,7 @@ Statement Parser::parse_(const Token *t) Statement result; bool sub=false; bool finish=false; - + while(in) { Token token; @@ -53,13 +53,13 @@ Statement Parser::parse_(const Token *t) } else token=parse_token(); - + if(result.keyword.empty()) { if(token.str.empty()) break; else if(token.type!=Token::IDENTIFIER) - throw DataError(get_location()+": Syntax error at token '"+token.str+"' (expected an identifier)"); + throw ParseError(get_location()+": Syntax error at token '"+token.str+"' (expected an identifier)", src, in.get_line_number()); result.keyword=token.str; result.valid=true; result.source=src; @@ -81,7 +81,7 @@ Statement Parser::parse_(const Token *t) else if(finish) { if(token.str!=";") - throw DataError(get_location()+": Syntax error at token '"+token.str+"' (Expected a ';')"); + throw ParseError(get_location()+": Syntax error at token '"+token.str+"' (Expected a ';')", src, in.get_line_number()); break; } else if(token.str=="{") @@ -105,9 +105,9 @@ Statement Parser::parse_(const Token *t) //result.args.push_back(resolve_identifiertoken.str); } else if(token.str=="") - throw DataError(src+": Unexcepted EOF"); + throw ParseError(src+": Unexcepted EOF", src, in.get_line_number()); else - throw DataError(get_location()+": Syntax error"); + throw ParseError(get_location()+": Syntax error", src, in.get_line_number()); } return result; @@ -115,15 +115,15 @@ Statement Parser::parse_(const Token *t) Token Parser::parse_token() { - int c; + int c=0; unsigned comment=0; + + // Skip over comments and whitespace while(in) { c=in.get(); int next=in.peek(); - //cout<='A' && *i<='F') digit=*i-'A'+10; else - throw DataError("Invalid hex digit"); + throw ParseError("Invalid hex digit", src, in.get_line_number()); hexcape=(hexcape<<4)|digit; if(hexcape&0x10000) @@ -371,7 +372,7 @@ void Parser::parse_error(int c, int state) { ostringstream ss; ss< #include #include +#include "error.h" namespace Msp { namespace Parser { @@ -64,7 +65,8 @@ inline T Value::get() const T result; ss>>result; if(ss.fail()) - throw ValueError("Invalid value"); + //XXX + throw Exception("Invalid value"); return result; } -- 2.45.2