mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2024-11-10 00:45:36 +00:00
refactoring of string conversion functions
This commit is contained in:
parent
12bbd3ec7e
commit
ebb82aeefe
@ -6,8 +6,8 @@
|
||||
#include <latan/Global.hpp>
|
||||
#endif
|
||||
|
||||
#define SRC_LOC strfrom<const char*>(__FUNCTION__) + " at "\
|
||||
+ strfrom<const char*>(__FILE__) + ":" + strfrom<int>(__LINE__)
|
||||
#define SRC_LOC strFrom<const char*>(__FUNCTION__) + " at "\
|
||||
+ strFrom<const char*>(__FILE__) + ":" + strFrom<int>(__LINE__)
|
||||
#define LATAN_ERROR(exc,msg) throw(Exceptions::exc(msg,SRC_LOC))
|
||||
|
||||
#define DECL_EXC(name,base) \
|
||||
|
@ -26,7 +26,7 @@ namespace Env
|
||||
|
||||
// string conversions
|
||||
template <typename T>
|
||||
static T ato(std::string str)
|
||||
T strTo(std::string str)
|
||||
{
|
||||
T buf;
|
||||
std::istringstream stream(str);
|
||||
@ -37,7 +37,7 @@ static T ato(std::string str)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static std::string strfrom(T x)
|
||||
std::string strFrom(T x)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
|
||||
|
@ -50,8 +50,8 @@ BLANK [ \t]
|
||||
%%
|
||||
|
||||
{LMARK} {BEGIN(MARK);}
|
||||
{INT} {yylval->val_int = ato<int>(yytext); RETTOK(INT);}
|
||||
{FLOAT} {yylval->val_double = ato<double>(yytext); RETTOK(FLOAT);}
|
||||
{INT} {yylval->val_int = strTo<int>(yytext); RETTOK(INT);}
|
||||
{FLOAT} {yylval->val_double = strTo<double>(yytext); RETTOK(FLOAT);}
|
||||
({ALPHA}|{DIGIT})+ {strcpy(yylval->val_str,yytext); RETTOK(ID);}
|
||||
<MARK>latan_begin {BEGIN(TYPE); RETTOK(OPEN);}
|
||||
<MARK>latan_end {BEGIN(TYPE); RETTOK(CLOSE);}
|
||||
|
@ -254,7 +254,7 @@ void MathCompiler::compile(const MathNode& n)
|
||||
switch (n.getType())
|
||||
{
|
||||
case MathNode::Type::Constant:
|
||||
out_.push_back(new Push(ato<double>(n.getName())));
|
||||
out_.push_back(new Push(strTo<double>(n.getName())));
|
||||
break;
|
||||
case MathNode::Type::Variable:
|
||||
out_.push_back(new Push(n.getName()));
|
||||
|
Loading…
Reference in New Issue
Block a user