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