X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fstatement.cpp;h=6d1c3b1f22767b5eba0d6cca5bb52b0ef0651794;hb=14f031aead619ce8a3fff1c283c3d205d421cd1f;hp=b1ff05826e314441fd3e93ced8c5117f295b5824;hpb=bb46b4a63a5bfcf6a2c0930f0e03046f385725f9;p=libs%2Fdatafile.git diff --git a/source/statement.cpp b/source/statement.cpp index b1ff058..6d1c3b1 100644 --- a/source/statement.cpp +++ b/source/statement.cpp @@ -1,5 +1,6 @@ #include #include "statement.h" +#include "token.h" #include "type.h" using namespace std; @@ -31,11 +32,32 @@ string Statement::get_location() const 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(token.str, Fmt().autobase())); + else if(token.type==Token::FLOAT) + return append(lexical_cast(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)