|
|
|
@ -23,9 +23,7 @@ static blaze::EnvironmentPtr s_outer_env = blaze::Environment::create();
|
|
|
|
|
static auto cleanup(int signal) -> void; |
|
|
|
|
static auto installLambdas(blaze::EnvironmentPtr env) -> void; |
|
|
|
|
static auto rep(std::string_view input, blaze::EnvironmentPtr env) -> std::string; |
|
|
|
|
static auto read(std::string_view input) -> blaze::ASTNodePtr; |
|
|
|
|
static auto eval(blaze::ASTNodePtr ast, blaze::EnvironmentPtr env) -> blaze::ASTNodePtr; |
|
|
|
|
static auto print(blaze::ASTNodePtr exp) -> std::string; |
|
|
|
|
static auto print(blaze::ValuePtr exp) -> std::string; |
|
|
|
|
|
|
|
|
|
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().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(); |
|
|
|
|
if (blaze::Settings::the().get("dump-lexer") == "1") { |
|
|
|
|
if (Settings::the().get("dump-lexer") == "1") { |
|
|
|
|
lexer.dump(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
blaze::Reader reader(std::move(lexer.tokens())); |
|
|
|
|
Reader reader(std::move(lexer.tokens())); |
|
|
|
|
reader.read(); |
|
|
|
|
if (blaze::Settings::the().get("dump-reader") == "1") { |
|
|
|
|
if (Settings::the().get("dump-reader") == "1") { |
|
|
|
|
reader.dump(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
|
|
return eval.ast(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static auto print(blaze::ASTNodePtr exp) -> std::string |
|
|
|
|
} // namespace blaze
|
|
|
|
|
|
|
|
|
|
static auto print(blaze::ValuePtr exp) -> std::string |
|
|
|
|
{ |
|
|
|
|
blaze::Printer printer; |
|
|
|
|
|
|
|
|
|