@@ -98,7 +98,7 @@ Variable *runtime(Node *NODE, Token *p_tokens, Node *AST) {
9898 }
9999 }
100100 if (!var_found ) {
101- printf ("\nError at line %d:\n\tVariable '%s' does not exist\n" , p_tokens [NODE -> start_t ].start , identifier );
101+ printf ("\033[1;31m\ nError at line %d:\n\tVariable '%s' does not exist\n\033[0m " , p_tokens [NODE -> start_t ].start , identifier );
102102 exit (1 );
103103 }
104104 break ;
@@ -181,9 +181,12 @@ Variable *runtime(Node *NODE, Token *p_tokens, Node *AST) {
181181 }
182182 result -> value .string_value = new_string ;
183183 } else {
184- printf ("Error: Unsupported operation\n" );
185- printf ("Cannot perform operation of type %s and %s\n" ,
186- left -> type == VAR_INT ? "int" : left -> type == VAR_FLOAT ? "float" : left -> type == VAR_STRING ? "string" : left -> type == VAR_BOOLEAN ? "boolean" : "null" , right -> type == VAR_INT ? "int" : right -> type == VAR_FLOAT ? "float" : right -> type == VAR_STRING ? "string" : right -> type == VAR_BOOLEAN ? "boolean" : "null" );
184+ printf (
185+ "\033[1;31m\nError at line %d: OperationError\n\tCannot perform operation of type %s and %s\n\033[0m" ,
186+ p_tokens [NODE -> childs [0 ].start_t ].start ,
187+ left -> type == VAR_INT ? "int" : left -> type == VAR_FLOAT ? "float" : left -> type == VAR_STRING ? "string" : left -> type == VAR_BOOLEAN ? "boolean" : "null" ,
188+ right -> type == VAR_INT ? "int" : right -> type == VAR_FLOAT ? "float" : right -> type == VAR_STRING ? "string" : right -> type == VAR_BOOLEAN ? "boolean" : "null"
189+ );
187190 exit (1 );
188191 }
189192 return result ;
@@ -328,7 +331,7 @@ Variable *runtime(Node *NODE, Token *p_tokens, Node *AST) {
328331 }
329332 }
330333 if (!function_found ) {
331- printf ("\nError at line %d:\n\tFunction '%s' does not exist\n" , p_tokens [NODE -> start_t ].start , func_name );
334+ printf ("\033[1;31m\ nError at line %d:\n\tFunction '%s' does not exist\n\033[0m " , p_tokens [NODE -> start_t ].start , func_name );
332335 exit (1 );
333336 }
334337 free (args );
@@ -448,9 +451,13 @@ Variable *runtime(Node *NODE, Token *p_tokens, Node *AST) {
448451 result_cond -> value .boolean_value = strcmp (left_cond -> value .string_value , right_cond -> value .string_value ) != 0 ;
449452 }
450453 } else {
451- printf ("Error: Unsupported operation\n" );
452- printf ("Cannot perform comparison of type %s and %s\n" ,
453- left_cond -> type == VAR_INT ? "int" : left_cond -> type == VAR_FLOAT ? "float" : left_cond -> type == VAR_STRING ? "string" : left_cond -> type == VAR_BOOLEAN ? "boolean" : "null" , right_cond -> type == VAR_INT ? "int" : right_cond -> type == VAR_FLOAT ? "float" : right_cond -> type == VAR_STRING ? "string" : right_cond -> type == VAR_BOOLEAN ? "boolean" : "null" );
454+
455+ printf (
456+ "\033[1;31m\nError at line %d: CompareError\n\tCannot compare conditions of type %s and %s\n\033[0m" ,
457+ p_tokens [NODE -> childs [0 ].start_t ].start ,
458+ left_cond -> type == VAR_INT ? "int" : left_cond -> type == VAR_FLOAT ? "float" : left_cond -> type == VAR_STRING ? "string" : left_cond -> type == VAR_BOOLEAN ? "boolean" : "null" ,
459+ right_cond -> type == VAR_INT ? "int" : right_cond -> type == VAR_FLOAT ? "float" : right_cond -> type == VAR_STRING ? "string" : right_cond -> type == VAR_BOOLEAN ? "boolean" : "null"
460+ );
454461 exit (1 );
455462 }
456463 return result_cond ;
@@ -531,9 +538,12 @@ Variable *runtime(Node *NODE, Token *p_tokens, Node *AST) {
531538 result_short -> value .float_value = left_short -> value .float_value / right_short -> value .int_value ;
532539 }
533540 } else {
534- printf ("Error: Unsupported operation\n" );
535- printf ("Cannot perform operation of type %s and %s\n" ,
536- left_short -> type == VAR_INT ? "int" : left_short -> type == VAR_FLOAT ? "float" : left_short -> type == VAR_STRING ? "string" : left_short -> type == VAR_BOOLEAN ? "boolean" : "null" , right_short -> type == VAR_INT ? "int" : right_short -> type == VAR_FLOAT ? "float" : right_short -> type == VAR_STRING ? "string" : right_short -> type == VAR_BOOLEAN ? "boolean" : "null" );
541+ printf (
542+ "\033[1;31m\nError at line %d: OperationError\n\tCannot perform operation of type %s and %s\n\033[0m" ,
543+ p_tokens [NODE -> childs [0 ].start_t ].start ,
544+ left_short -> type == VAR_INT ? "int" : left_short -> type == VAR_FLOAT ? "float" : left_short -> type == VAR_STRING ? "string" : left_short -> type == VAR_BOOLEAN ? "boolean" : "null" ,
545+ right_short -> type == VAR_INT ? "int" : right_short -> type == VAR_FLOAT ? "float" : right_short -> type == VAR_STRING ? "string" : right_short -> type == VAR_BOOLEAN ? "boolean" : "null"
546+ );
537547 exit (1 );
538548 }
539549 // Saving the result to the left variable
0 commit comments