]> git.tdb.fi Git - libs/datafile.git/commitdiff
Remove old build info
authorMikko Rasa <tdb@tdb.fi>
Fri, 1 Dec 2006 19:45:31 +0000 (19:45 +0000)
committerMikko Rasa <tdb@tdb.fi>
Fri, 1 Dec 2006 19:45:31 +0000 (19:45 +0000)
Convert exception types

Package [deleted file]
source/Module [deleted file]
source/parser.cpp
source/value.h

diff --git a/Package b/Package
deleted file mode 100644 (file)
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 (file)
index 11b9baf..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-type="library"
-target="mspparser"
-installheaders="parser"
-installtarget=1
index f74be86396881917caf46fec861a923d954f5293..c47969bb2f3f30c5e194f534fbae6ff72884a3ad 100644 (file)
@@ -5,7 +5,7 @@ Distributed under the LGPL
 */
 #include <cctype>
 #include <sstream>
-#include <msp/error.h>
+#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<<c<<' '<<next<<'\n';
-
                if(c=='/' && next=='/')
                        comment=1;
                else if(c=='/' && next=='*')
@@ -137,9 +137,10 @@ Token Parser::parse_token()
                else if(!isspace(c) && !comment)
                        break;
        }
-       if(comment)
-               throw DataError(src+": Unfinished comment");
-       
+
+       if(comment)  // Didn't hit any non-whitespace
+               throw ParseError(src+": Unfinished comment", src, in.get_line_number());
+
        enum ParseState
        {
                INIT,
@@ -183,7 +184,7 @@ Token Parser::parse_token()
                if(state!=INIT)
                        c=in.get();
                int next=in.peek();
-               
+
                buf+=c;
 
                switch(state)
@@ -206,7 +207,7 @@ Token Parser::parse_token()
                        else
                                parse_error(c, state);
                        break;
-               
+
                case SIGN:
                        if(c=='0')
                                state=ZERO;
@@ -282,7 +283,7 @@ Token Parser::parse_token()
                        else
                                escape=false;
                        break;
-               
+
                case IDENTIFIER:
                        if(!isalpha(c) && !isdigit(c) && c!='_')
                                parse_error(c, state);
@@ -329,7 +330,7 @@ string Parser::unescape_string(const string &str)
                        else if(*i=='x')
                                hexcape=0x100;
                        else
-                               throw DataError("Invalid escape");
+                               throw ParseError("Invalid escape", src, in.get_line_number());
                        escape=false;
                }
                else if(hexcape)
@@ -342,7 +343,7 @@ string Parser::unescape_string(const string &str)
                        else if(*i>='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<<get_location()<<": Parse error at '"<<(char)c<<"' (state "<<state<<')';
-       throw DataError(ss.str());
+       throw ParseError(ss.str(), src, in.get_line_number());
 }
 
 } // namespace Parser
index be6a7a483f7768849f845051dbe563e9cea97ac9..5fc3540f763ee9a2a8d4de12f623d5b2f77eccb3 100644 (file)
@@ -9,6 +9,7 @@ Distributed under the LGPL
 #include <sstream>
 #include <string>
 #include <vector>
+#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;
 }