fixes splicing of nil and macros dont expand at parse time fr now
This commit is contained in:
+17
-1
@@ -449,16 +449,32 @@ namespace Parser {
|
||||
} else {
|
||||
// if threre is a macro named like this, then macroexpand
|
||||
// if not it is regular code, dont touch.
|
||||
break;
|
||||
|
||||
Lisp_Object* macro = try_lookup_symbol(parsed_symbol, environment_for_macros);
|
||||
if (macro &&
|
||||
Memory::get_type(macro) == Lisp_Object_Type::Function &&
|
||||
macro->value.function.type == Function_Type::Macro)
|
||||
{
|
||||
// printf("Found macro: ") ;
|
||||
// printf("pretending to expand macro at %s %d %d: ",
|
||||
// Memory::get_c_str(parser_file),
|
||||
// parser_line, parser_col);
|
||||
// print(parsed_symbol);
|
||||
// printf("\n");
|
||||
// NOTE(Felix): Execute it as a special lambda,
|
||||
// because if we keep it as a macro, the evaluator
|
||||
// will think it is a stray macro that was not yet
|
||||
// expanded, and attempt to evaluate it twice (1.
|
||||
// for expanding, and 2. for evaluating)
|
||||
macro->value.function.type = Function_Type::Special_Lambda;
|
||||
// NOTE(Felix): deferred so even if eval expr
|
||||
// fails, and returns, the type will be be
|
||||
// resetted to macro.
|
||||
defer {
|
||||
macro->value.function.type = Function_Type::Macro;
|
||||
};
|
||||
try expression = eval_expr(expression, environment_for_macros);
|
||||
break;
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user