error locations for wrong parameters
This commit is contained in:
+1
-14
@@ -1,17 +1,4 @@
|
|||||||
;; (when 1 (breakpoint))
|
|
||||||
|
|
||||||
;; (if (eval 1)
|
|
||||||
;; (apply prog ((breakpoint)))
|
|
||||||
;; nil))
|
|
||||||
|
|
||||||
;; (if (eval 1)
|
|
||||||
;; (eval (pair prog ((breakpoint)))))
|
|
||||||
;; nil))
|
|
||||||
|
|
||||||
|
|
||||||
(defun ! (n)
|
(defun ! (n)
|
||||||
(if (< n 2)
|
(ifs (< n 2)
|
||||||
1
|
1
|
||||||
(* n (! (- n 1)))))
|
(* n (! (- n 1)))))
|
||||||
|
|
||||||
(erros "alskdj")
|
|
||||||
@@ -145,6 +145,7 @@ Ast_Node* lookup_symbol(Ast_Node* node, Environment* env) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = create_ast_node_built_in_function(sym->identifier);
|
result = create_ast_node_built_in_function(sym->identifier);
|
||||||
|
result->sourceCodeLocation = node->sourceCodeLocation;
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
|||||||
+24
-20
@@ -366,6 +366,10 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
create_error(_type, node->sourceCodeLocation); \
|
create_error(_type, node->sourceCodeLocation); \
|
||||||
return nullptr; \
|
return nullptr; \
|
||||||
}
|
}
|
||||||
|
#define report_error_operator(_type) { \
|
||||||
|
create_error(_type, operator->sourceCodeLocation); \
|
||||||
|
return nullptr; \
|
||||||
|
}
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -416,7 +420,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
arguments_length = list_length(arguments);
|
arguments_length = list_length(arguments);
|
||||||
}
|
}
|
||||||
if (arguments_length != 1) {
|
if (arguments_length != 1) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
print(arguments->value.pair->first);
|
print(arguments->value.pair->first);
|
||||||
@@ -494,7 +498,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
arguments_length = list_length(arguments);
|
arguments_length = list_length(arguments);
|
||||||
}
|
}
|
||||||
if (arguments_length == 0)
|
if (arguments_length == 0)
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
|
|
||||||
|
|
||||||
Function* function = new(Function);
|
Function* function = new(Function);
|
||||||
@@ -632,7 +636,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
arguments_length = list_length(arguments);
|
arguments_length = list_length(arguments);
|
||||||
}
|
}
|
||||||
if (arguments_length != 1) {
|
if (arguments_length != 1) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
bool truthy;
|
bool truthy;
|
||||||
try {
|
try {
|
||||||
@@ -648,7 +652,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (arguments_length < 2) {
|
if (arguments_length < 2) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
Ast_Node* condition_part = arguments->value.pair->first;
|
Ast_Node* condition_part = arguments->value.pair->first;
|
||||||
Ast_Node* condition;
|
Ast_Node* condition;
|
||||||
@@ -674,7 +678,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
arguments_length = list_length(arguments);
|
arguments_length = list_length(arguments);
|
||||||
}
|
}
|
||||||
if (arguments_length != 2 && arguments_length != 3) {
|
if (arguments_length != 2 && arguments_length != 3) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ast_Node* condition = arguments->value.pair->first;
|
Ast_Node* condition = arguments->value.pair->first;
|
||||||
@@ -700,7 +704,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
case Built_In_Quote: {
|
case Built_In_Quote: {
|
||||||
arguments_length = list_length(arguments);
|
arguments_length = list_length(arguments);
|
||||||
if (arguments_length != 1) {
|
if (arguments_length != 1) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
return arguments->value.pair->first;
|
return arguments->value.pair->first;
|
||||||
}
|
}
|
||||||
@@ -709,7 +713,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
arguments_length = list_length(arguments);
|
arguments_length = list_length(arguments);
|
||||||
}
|
}
|
||||||
if (arguments_length != 2) {
|
if (arguments_length != 2) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ast_Node* try_part = arguments->value.pair->first;
|
Ast_Node* try_part = arguments->value.pair->first;
|
||||||
@@ -731,7 +735,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
arguments_length = list_length(arguments);
|
arguments_length = list_length(arguments);
|
||||||
}
|
}
|
||||||
if (arguments_length != 2) {
|
if (arguments_length != 2) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ast_Node* symbol = arguments->value.pair->first;
|
Ast_Node* symbol = arguments->value.pair->first;
|
||||||
@@ -804,7 +808,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
}
|
}
|
||||||
case Built_In_Mutate: {
|
case Built_In_Mutate: {
|
||||||
if (arguments_length != 2)
|
if (arguments_length != 2)
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
|
|
||||||
if (evaluated_arguments->value.pair->first->type == Ast_Node_Type_Nil ||
|
if (evaluated_arguments->value.pair->first->type == Ast_Node_Type_Nil ||
|
||||||
evaluated_arguments->value.pair->first->type == Ast_Node_Type_Keyword)
|
evaluated_arguments->value.pair->first->type == Ast_Node_Type_Keyword)
|
||||||
@@ -820,7 +824,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
}
|
}
|
||||||
case Built_In_Copy: {
|
case Built_In_Copy: {
|
||||||
if (arguments_length != 1)
|
if (arguments_length != 1)
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
|
|
||||||
if (evaluated_arguments->value.pair->first->type == Ast_Node_Type_Nil ||
|
if (evaluated_arguments->value.pair->first->type == Ast_Node_Type_Nil ||
|
||||||
evaluated_arguments->value.pair->first->type == Ast_Node_Type_Keyword)
|
evaluated_arguments->value.pair->first->type == Ast_Node_Type_Keyword)
|
||||||
@@ -836,7 +840,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
}
|
}
|
||||||
case Built_In_Load: {
|
case Built_In_Load: {
|
||||||
if (arguments_length != 1)
|
if (arguments_length != 1)
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
|
|
||||||
if (evaluated_arguments->value.pair->first->type != Ast_Node_Type_String)
|
if (evaluated_arguments->value.pair->first->type != Ast_Node_Type_String)
|
||||||
report_error(Error_Type_Type_Missmatch);
|
report_error(Error_Type_Type_Missmatch);
|
||||||
@@ -850,13 +854,13 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
}
|
}
|
||||||
case Built_In_Pair: {
|
case Built_In_Pair: {
|
||||||
if (arguments_length != 2) {
|
if (arguments_length != 2) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
return create_ast_node_pair(evaluated_arguments->value.pair->first, evaluated_arguments->value.pair->rest->value.pair->first);
|
return create_ast_node_pair(evaluated_arguments->value.pair->first, evaluated_arguments->value.pair->rest->value.pair->first);
|
||||||
}
|
}
|
||||||
case Built_In_First: {
|
case Built_In_First: {
|
||||||
if (arguments_length != 1) {
|
if (arguments_length != 1) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
if (evaluated_arguments->value.pair->first->type == Ast_Node_Type_Nil)
|
if (evaluated_arguments->value.pair->first->type == Ast_Node_Type_Nil)
|
||||||
return create_ast_node_nil();
|
return create_ast_node_nil();
|
||||||
@@ -867,7 +871,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
}
|
}
|
||||||
case Built_In_Rest: {
|
case Built_In_Rest: {
|
||||||
if (arguments_length != 1) {
|
if (arguments_length != 1) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
if (evaluated_arguments->value.pair->first->type == Ast_Node_Type_Nil)
|
if (evaluated_arguments->value.pair->first->type == Ast_Node_Type_Nil)
|
||||||
return create_ast_node_nil();
|
return create_ast_node_nil();
|
||||||
@@ -878,7 +882,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
}
|
}
|
||||||
case Built_In_Eval: {
|
case Built_In_Eval: {
|
||||||
if (arguments_length != 1) {
|
if (arguments_length != 1) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
Ast_Node* result;
|
Ast_Node* result;
|
||||||
try {
|
try {
|
||||||
@@ -905,13 +909,13 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
}
|
}
|
||||||
case Built_In_Error: {
|
case Built_In_Error: {
|
||||||
if (arguments_length != 0) {
|
if (arguments_length != 0) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
report_error(Error_Type_Unknown_Error);
|
report_error(Error_Type_Unknown_Error);
|
||||||
}
|
}
|
||||||
case Built_In_Print: {
|
case Built_In_Print: {
|
||||||
if (arguments_length != 1) {
|
if (arguments_length != 1) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
print(evaluated_arguments->value.pair->first);
|
print(evaluated_arguments->value.pair->first);
|
||||||
/* printf("\n"); */
|
/* printf("\n"); */
|
||||||
@@ -919,7 +923,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
}
|
}
|
||||||
case Built_In_Read: {
|
case Built_In_Read: {
|
||||||
if (arguments_length > 1) {
|
if (arguments_length > 1) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arguments_length == 1) {
|
if (arguments_length == 1) {
|
||||||
@@ -934,7 +938,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
}
|
}
|
||||||
case Built_In_Type: {
|
case Built_In_Type: {
|
||||||
if (arguments_length != 1) {
|
if (arguments_length != 1) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ast_Node_Type type = evaluated_arguments->value.pair->first->type;
|
Ast_Node_Type type = evaluated_arguments->value.pair->first->type;
|
||||||
@@ -956,7 +960,7 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) {
|
|||||||
}
|
}
|
||||||
case Built_In_Exit: {
|
case Built_In_Exit: {
|
||||||
if (arguments_length > 1) {
|
if (arguments_length > 1) {
|
||||||
report_error(Error_Type_Wrong_Number_Of_Arguments);
|
report_error_operator(Error_Type_Wrong_Number_Of_Arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arguments_length == 1) {
|
if (arguments_length == 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user