Skip to content

Commit

Permalink
fixed expression printing for function params and param lists
Browse files Browse the repository at this point in the history
  • Loading branch information
reginaldford committed Aug 30, 2024
1 parent 57a1cfc commit 6fca72e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/main/object/sm_expr_sprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ uint32_t sm_expr_tuple_sprint(sm_expr *expr, char *buffer, bool fake) {

// Print description of prefix expression to buffer
uint32_t sm_prefix_sprint(sm_expr *expr, char *buffer, bool fake) {
if (!fake)
sm_strncpy(buffer, sm_global_fn_name(expr->op), sm_global_fn_name_len(expr->op));
uint32_t cursor = sm_global_fn_name_len(expr->op);
uint32_t cursor = 0;
if (!sm_global_fn_hidden(expr->op)) {
if (!fake)
sm_strncpy(buffer, sm_global_fn_name(expr->op), sm_global_fn_name_len(expr->op));
cursor = sm_global_fn_name_len(expr->op);
}
if (!fake)
buffer[cursor] = expr->op == SM_BLOCK_EXPR ? '{' : '(';
cursor++;
Expand Down
10 changes: 10 additions & 0 deletions src/main/sm_global.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ sm_stack *sm_global_lex_stack(sm_stack *replacement) {
return lex_stack;
}

bool sm_global_fn_hidden(uint32_t which) {
switch (which) {
case SM_FN_PARAMS_EXPR:
case SM_PARAM_LIST_EXPR:
return true;
break;
}
return false;
}

// Primitive_names
char *sm_global_fn_name(uint32_t which) {
const uint32_t num_functions = sm_global_num_fns();
Expand Down
2 changes: 2 additions & 0 deletions src/main/sm_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ struct termios *sm_global_term_attrs();
struct sm_string *sm_global_home_directory();
/// Global version string
sm_string *sms_global_version();
/// Returns whether fn name is hidden when containing expression is printed
bool sm_global_fn_hidden(uint32_t which);
2 changes: 1 addition & 1 deletion src/main/sm_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern uint32_t sms_num_symbols;

void sm_init(sm_env *env, int num_args, char **argv) {
// Set version number. Major.Minor.Patch
char *sms_version = "0.21.29";
char *sms_version = "0.21.30";
int sms_version_len = 7;
sm_strncpy(env->version, sms_version, sms_version_len);
env->version_len = sms_version_len;
Expand Down

0 comments on commit 6fca72e

Please sign in to comment.