#include <msp/strings/format.h>
#include "statement.h"
+#include "token.h"
#include "type.h"
using namespace std;
return result;
}
+Statement &Statement::append_from_token(const Token &token)
+{
+ if(token.type==Token::INTEGER)
+ return append(lexical_cast<IntType::Store>(token.str));
+ else if(token.type==Token::FLOAT)
+ return append(lexical_cast<FloatType::Store>(token.str));
+ else if(token.type==Token::STRING)
+ return append(token.str);
+ else if(token.type==Token::IDENTIFIER)
+ {
+ if(token.str=="true")
+ return append(true);
+ else if(token.str=="false")
+ return append(false);
+ else
+ return append(Symbol(token.str));
+ }
+ else
+ throw invalid_argument("Statement::append_from_token");
+}
+
StatementInfo::StatementInfo():
args_size(0)
namespace Msp {
namespace DataFile {
+struct Token;
+
class Statement
{
public:
return *this;
}
+ Statement &append_from_token(const Token &);
+
template<typename T>
Statement &operator,(const T &v)
{ return append(v); }
sub = 1;
else if(token.str==";")
break;
- else if(token.type==Token::INTEGER)
- result.append(lexical_cast<IntType::Store>(token.str));
- else if(token.type==Token::FLOAT)
- result.append(lexical_cast<FloatType::Store>(token.str));
- else if(token.type==Token::STRING)
- result.append(token.str);
- else if(token.type==Token::IDENTIFIER)
- {
- if(token.str=="true")
- result.append(true);
- else if(token.str=="false")
- result.append(false);
- else
- result.append(Symbol(token.str));
- }
+ else if(token.type!=Token::SPECIAL)
+ result.append_from_token(token);
else
throw syntax_error(token.str);
}