/*
This file is part of libmspparser
-Copyright © 2006 Mikko Rasa, Mikkosoft Productions
+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 {
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;
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=="{")
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=="")
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 '"<<(char)c<<"' (state "<<state<<')';
+ throw DataError(ss.str());
}
} // namespace Parser