From ebb82aeefead7f5dc04bbccf338f0297cddeaff5 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Wed, 22 Jan 2014 17:58:26 +0100 Subject: [PATCH] refactoring of string conversion functions --- latan/Exceptions.hpp | 4 ++-- latan/Global.hpp | 4 ++-- latan/IoAsciiLexer.lpp | 4 ++-- latan/MathCompiler.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/latan/Exceptions.hpp b/latan/Exceptions.hpp index 190de94..3515dce 100644 --- a/latan/Exceptions.hpp +++ b/latan/Exceptions.hpp @@ -6,8 +6,8 @@ #include #endif -#define SRC_LOC strfrom(__FUNCTION__) + " at "\ - + strfrom(__FILE__) + ":" + strfrom(__LINE__) +#define SRC_LOC strFrom(__FUNCTION__) + " at "\ + + strFrom(__FILE__) + ":" + strFrom(__LINE__) #define LATAN_ERROR(exc,msg) throw(Exceptions::exc(msg,SRC_LOC)) #define DECL_EXC(name,base) \ diff --git a/latan/Global.hpp b/latan/Global.hpp index b3e6047..c43677b 100644 --- a/latan/Global.hpp +++ b/latan/Global.hpp @@ -26,7 +26,7 @@ namespace Env // string conversions template -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 -static std::string strfrom(T x) +std::string strFrom(T x) { std::ostringstream stream; diff --git a/latan/IoAsciiLexer.lpp b/latan/IoAsciiLexer.lpp index ccda1f4..663fe31 100644 --- a/latan/IoAsciiLexer.lpp +++ b/latan/IoAsciiLexer.lpp @@ -50,8 +50,8 @@ BLANK [ \t] %% {LMARK} {BEGIN(MARK);} -{INT} {yylval->val_int = ato(yytext); RETTOK(INT);} -{FLOAT} {yylval->val_double = ato(yytext); RETTOK(FLOAT);} +{INT} {yylval->val_int = strTo(yytext); RETTOK(INT);} +{FLOAT} {yylval->val_double = strTo(yytext); RETTOK(FLOAT);} ({ALPHA}|{DIGIT})+ {strcpy(yylval->val_str,yytext); RETTOK(ID);} latan_begin {BEGIN(TYPE); RETTOK(OPEN);} latan_end {BEGIN(TYPE); RETTOK(CLOSE);} diff --git a/latan/MathCompiler.cpp b/latan/MathCompiler.cpp index 99c7147..7735e9c 100644 --- a/latan/MathCompiler.cpp +++ b/latan/MathCompiler.cpp @@ -254,7 +254,7 @@ void MathCompiler::compile(const MathNode& n) switch (n.getType()) { case MathNode::Type::Constant: - out_.push_back(new Push(ato(n.getName()))); + out_.push_back(new Push(strTo(n.getName()))); break; case MathNode::Type::Variable: out_.push_back(new Push(n.getName()));