Reader+Env: Add dump function

This commit is contained in:
Riyyi
2023-11-19 21:44:17 +01:00
parent 536e55e75a
commit f5dc1168eb
6 changed files with 121 additions and 25 deletions
+16
View File
@@ -7,6 +7,7 @@
#include <iterator> // std::next
#include <string>
#include "reader.h"
#include "ruc/format/print.h"
#include "ast.h"
@@ -54,6 +55,21 @@ void Environment::loadFormat()
ADD_FUNCTION("prn", "", "", PRINTER_PRINT(true));
ADD_FUNCTION("println", "", "", PRINTER_PRINT(false));
// -------------------------------------
ADD_FUNCTION(
"dump",
"arg",
"Print AST of the value ARG.",
{
CHECK_ARG_COUNT_IS("dump", SIZE(), 1);
Reader reader;
reader.dump(*begin);
return nullptr;
});
}
} // namespace blaze