Skip to content

Commit

Permalink
Update 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sygmei committed Jan 31, 2017
1 parent b5e762f commit e043673
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Kitanai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void Token::execute(Program* prg)
{
std::vector<Token> parametersExecution = parameters;
doChainAdoption();
if (getType() == TokenType::Condition) {
if (getType() == TokenType::Condition && prg->canExecute()) {
parametersExecution[0].execute(prg);
}
else if (getType() == TokenType::Function && getValue() == "func") {
Expand Down
15 changes: 10 additions & 5 deletions Kitanai.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ namespace StdLib
Token a = tokens[0];
Token b = tokens[1];
if (a.getType() == TokenType::Number && b.getType() == TokenType::Number)
return Token(TokenType::Number, std::to_string(std::stoi(a.getValue()) + std::stoi(b.getValue())));
return Token(TokenType::Number, std::to_string(std::stoll(a.getValue()) + std::stoll(b.getValue())));
else {
return Token(TokenType::String, a.getValue() + b.getValue());
}
Expand All @@ -154,25 +154,25 @@ namespace StdLib
Token a = tokens[0];
Token b = tokens[1];
if (a.getType() == TokenType::Number && b.getType() == TokenType::Number)
return Token(TokenType::Number, std::to_string(std::stoi(a.getValue()) - std::stoi(b.getValue())));
return Token(TokenType::Number, std::to_string(std::stoll(a.getValue()) - std::stoll(b.getValue())));
}
Token f_mul(const std::vector<Token> tokens) {
Token a = tokens[0];
Token b = tokens[1];
if (a.getType() == TokenType::Number && b.getType() == TokenType::Number)
return Token(TokenType::Number, std::to_string((int)(std::stod(a.getValue()) * std::stod(b.getValue()))));
return Token(TokenType::Number, std::to_string((long long int)(std::stod(a.getValue()) * std::stod(b.getValue()))));
}
Token f_div(const std::vector<Token> tokens) {
Token a = tokens[0];
Token b = tokens[1];
if (a.getType() == TokenType::Number && b.getType() == TokenType::Number)
return Token(TokenType::Number, std::to_string((int)std::stod(a.getValue()) / std::stod(b.getValue())));
return Token(TokenType::Number, std::to_string((long long int)std::stod(a.getValue()) / std::stod(b.getValue())));
}
Token f_mod(const std::vector<Token> tokens) {
Token a = tokens[0];
Token b = tokens[1];
if (a.getType() == TokenType::Number && b.getType() == TokenType::Number)
return Token(TokenType::Number, std::to_string(std::stoi(a.getValue()) % std::stoi(b.getValue())));
return Token(TokenType::Number, std::to_string(std::stoll(a.getValue()) % std::stoll(b.getValue())));
}
Token f_not(const std::vector<Token> tokens) {
Token a = tokens[0];
Expand Down Expand Up @@ -271,6 +271,10 @@ namespace StdLib
std::uniform_real_distribution<double> unif(0, 1);
return Token(TokenType::Number, std::to_string(unif(rng)));
}
Token f_time(const std::vector<Token> tokens) {
std::string retTime = std::to_string(std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1));
return Token(TokenType::Number, retTime);
}
Token f_split(const std::vector<Token> tokens) {
Token saveTo = tokens[0];
Token string = tokens[1];
Expand Down Expand Up @@ -322,6 +326,7 @@ namespace StdLib
f("string", f_string, 1),
f("int", f_int, 1),
f("random", f_random, 0),
f("time", f_time, 0),
f("split", f_split, 3),
};

Expand Down

0 comments on commit e043673

Please sign in to comment.