#include <msp/strings/format.h>
#include "statement.h"
+#include "token.h"
#include "type.h"
using namespace std;
Statement::Statement():
valid(false),
+ control(false),
line(0)
{ }
Statement::Statement(const string &kw):
keyword(kw),
valid(true),
+ control(!kw.compare(0, 2, "__")),
line(0)
{ }
string Statement::get_signature() const
{
string result;
- for(Arguments::const_iterator i = args.begin(); i!=args.end(); ++i)
+ for(Arguments::const_iterator i=args.begin(); i!=args.end(); ++i)
result += i->get_signature();
return result;
}
+Statement &Statement::append_from_token(const Token &token)
+{
+ if(token.type==Token::INTEGER)
+ return append(lexical_cast<IntType::Store>(token.str, Fmt().autobase()));
+ 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)