|
|
@ -23,9 +23,7 @@ static blaze::EnvironmentPtr s_outer_env = blaze::Environment::create(); |
|
|
|
static auto cleanup(int signal) -> void; |
|
|
|
static auto cleanup(int signal) -> void; |
|
|
|
static auto installLambdas(blaze::EnvironmentPtr env) -> void; |
|
|
|
static auto installLambdas(blaze::EnvironmentPtr env) -> void; |
|
|
|
static auto rep(std::string_view input, blaze::EnvironmentPtr env) -> std::string; |
|
|
|
static auto rep(std::string_view input, blaze::EnvironmentPtr env) -> std::string; |
|
|
|
static auto read(std::string_view input) -> blaze::ASTNodePtr; |
|
|
|
static auto print(blaze::ValuePtr exp) -> std::string; |
|
|
|
static auto eval(blaze::ASTNodePtr ast, blaze::EnvironmentPtr env) -> blaze::ASTNodePtr; |
|
|
|
|
|
|
|
static auto print(blaze::ASTNodePtr exp) -> std::string; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto main(int argc, char* argv[]) -> int |
|
|
|
auto main(int argc, char* argv[]) -> int |
|
|
|
{ |
|
|
|
{ |
|
|
@ -93,35 +91,39 @@ static auto rep(std::string_view input, blaze::EnvironmentPtr env) -> std::strin |
|
|
|
blaze::Error::the().clearErrors(); |
|
|
|
blaze::Error::the().clearErrors(); |
|
|
|
blaze::Error::the().setInput(input); |
|
|
|
blaze::Error::the().setInput(input); |
|
|
|
|
|
|
|
|
|
|
|
return print(eval(read(input), env)); |
|
|
|
return print(blaze::eval(blaze::read(input), env)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static auto read(std::string_view input) -> blaze::ASTNodePtr |
|
|
|
namespace blaze { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto read(std::string_view input) -> ValuePtr |
|
|
|
{ |
|
|
|
{ |
|
|
|
blaze::Lexer lexer(input); |
|
|
|
Lexer lexer(input); |
|
|
|
lexer.tokenize(); |
|
|
|
lexer.tokenize(); |
|
|
|
if (blaze::Settings::the().get("dump-lexer") == "1") { |
|
|
|
if (Settings::the().get("dump-lexer") == "1") { |
|
|
|
lexer.dump(); |
|
|
|
lexer.dump(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
blaze::Reader reader(std::move(lexer.tokens())); |
|
|
|
Reader reader(std::move(lexer.tokens())); |
|
|
|
reader.read(); |
|
|
|
reader.read(); |
|
|
|
if (blaze::Settings::the().get("dump-reader") == "1") { |
|
|
|
if (Settings::the().get("dump-reader") == "1") { |
|
|
|
reader.dump(); |
|
|
|
reader.dump(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return reader.node(); |
|
|
|
return reader.node(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static auto eval(blaze::ASTNodePtr ast, blaze::EnvironmentPtr env) -> blaze::ASTNodePtr |
|
|
|
auto eval(ValuePtr ast, EnvironmentPtr env) -> ValuePtr |
|
|
|
{ |
|
|
|
{ |
|
|
|
blaze::Eval eval(ast, env); |
|
|
|
Eval eval(ast, env); |
|
|
|
eval.eval(); |
|
|
|
eval.eval(); |
|
|
|
|
|
|
|
|
|
|
|
return eval.ast(); |
|
|
|
return eval.ast(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static auto print(blaze::ASTNodePtr exp) -> std::string |
|
|
|
} // namespace blaze
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static auto print(blaze::ValuePtr exp) -> std::string |
|
|
|
{ |
|
|
|
{ |
|
|
|
blaze::Printer printer; |
|
|
|
blaze::Printer printer; |
|
|
|
|
|
|
|
|
|
|
|