]> git.tdb.fi Git - libs/datafile.git/commitdiff
Build error strings with operator+ and ostringstream
authorMikko Rasa <tdb@tdb.fi>
Wed, 23 Aug 2006 12:26:01 +0000 (12:26 +0000)
committerMikko Rasa <tdb@tdb.fi>
Wed, 23 Aug 2006 12:26:01 +0000 (12:26 +0000)
Package
source/parser.cpp

diff --git a/Package b/Package
index 2f68107b4666b56efe88d925eca59dd925244488..85665ebe7d164ec5e835eaab13ffb3b5cada3216 100644 (file)
--- a/Package
+++ b/Package
@@ -1,5 +1,5 @@
 package="mspparser"
 version="0.2"
 description="Mikkosoft Productions datafile parser"
-requires=("mspmisc","mspstreams")
+requires=("mspmisc",)
 tarballfiles=("License.txt",)
index 8707cedae643d829a32dbf193d2474b03593c133..ef2daa3e0ab8bd5dbb75ce8696a64c789c8417ab 100644 (file)
@@ -4,16 +4,14 @@ Copyright © 2006 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 #include <cctype>
+#include <sstream>
 #include <msp/error.h>
-#include <msp/streams/format.h>
 #include "parser.h"
 #include "statement.h"
 #include "token.h"
 
 using namespace std;
 
-#include <iostream>
-
 namespace Msp {
 namespace Parser {
 
@@ -61,7 +59,7 @@ Statement Parser::parse_(const Token *t)
                        if(token.str.empty())
                                break;
                        else if(token.type!=Token::IDENTIFIER)
-                               throw DataError(get_location()+format(": Syntax error at token '%S' (expected an identifier)", &token.str).str());
+                               throw DataError(get_location()+": Syntax error at token '"+token.str+"' (expected an identifier)");
                        result.keyword=token.str;
                        result.valid=true;
                        result.source=src;
@@ -83,7 +81,7 @@ Statement Parser::parse_(const Token *t)
                else if(finish)
                {
                        if(token.str!=";")
-                               throw DataError(get_location()+format(": Syntax error at token '%S' (Expected a ';')", &token.str).str());
+                               throw DataError(get_location()+": Syntax error at token '"+token.str+"' (Expected a ';')");
                        break;
                }
                else if(token.str=="{")
@@ -336,7 +334,9 @@ string Parser::get_location()
 
 void Parser::parse_error(int c, int state)
 {
-       throw DataError(get_location()+format(": Parse error at '%c' (state %d)", c, state).str());
+       ostringstream ss;
+       ss<<get_location()<<": Parse error at '"<<c<<"' (state "<<state<<')';
+       throw DataError(ss.str());
 }
 
 } // namespace Parser