X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fparser.cpp;h=c9ad188868a0bed69087879472b2741b67e07f46;hb=98f563736e0837a429714b98656215503c607710;hp=8707cedae643d829a32dbf193d2474b03593c133;hpb=5453824394771ca21de32088a2842486b63e6f6d;p=libs%2Fdatafile.git diff --git a/source/parser.cpp b/source/parser.cpp index 8707ced..c9ad188 100644 --- a/source/parser.cpp +++ b/source/parser.cpp @@ -1,19 +1,17 @@ /* This file is part of libmspparser -Copyright © 2006 Mikko Rasa, Mikkosoft Productions +Copyright © 2006 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ #include +#include #include -#include #include "parser.h" #include "statement.h" #include "token.h" using namespace std; -#include - 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=="{") @@ -98,6 +96,12 @@ Statement Parser::parse_(const Token *t) result.args.push_back(Value(Value::STRING, token.str)); else if(token.type==Token::IDENTIFIER) { + if(token.str=="true") + result.args.push_back(Value(Value::BOOLEAN, "1")); + else if(token.str=="false") + result.args.push_back(Value(Value::BOOLEAN, "0")); + else + result.args.push_back(Value(Value::ENUM, token.str)); //result.args.push_back(resolve_identifiertoken.str); } else if(token.str=="") @@ -336,7 +340,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<