|
| struct ps_node * | ps_node_let_new (struct ps_token *name, bool is_mutable, struct ps_type *type, struct ps_expr *value) |
| | Creates a new let statement initializing the variable name to the expression value.
|
| |
| struct ps_node * | ps_node_fn_new (struct ps_token *name, struct ps_type *ret_type, struct ps_type_field_arr *params, enum ps_fn_qualifiers qualifiers, struct ps_node_block *body) |
| | Creates a new function with the given name name, parameters params, and function body body.
|
| |
| | PS_PRINT_IMPL (ps_name, { for(usize i=0;i< self->length;i++) { if(i > 0) { printf("::");} ps_token_print(&self->contents[i], 0);} }) |
| |
| struct ps_node * | ps_node_extern_new (struct ps_token *name, struct ps_type_tuple *sig) |
| |
| struct ps_node * | ps_node_expr_stm_new (struct ps_expr *expr) |
| | Creates a new expression statement for expr.
|
| |
| struct ps_node * | ps_node_block_stm_new (struct ps_node_block *block) |
| | Creates a new block statement.
|
| |
| struct ps_node * | ps_node_struct_new (struct ps_type_struct *type, struct ps_node_fn_arr *methods) |
| | Creates a new structure declaration.
|
| |
| struct ps_node * | ps_node_enum_new (struct ps_type_enum *type, struct ps_node_fn_arr *methods) |
| | Creates a new enum declaration.
|
| |
| struct ps_node * | ps_node_for_new (struct ps_node_let *init, struct ps_expr *cond, struct ps_node_expr_stm *step, struct ps_node_block *body) |
| | Creates a new for loop.
|
| |
| struct ps_node * | ps_node_while_new (struct ps_expr *cond, struct ps_node_block *body) |
| | Creates a new while loop.
|
| |
| struct ps_node * | ps_node_if_new (struct ps_expr *cond, struct ps_node_block *body, struct ps_node_block *else_body) |
| | Creates a new if statement on condition cond.
|
| |
| struct ps_node * | ps_node_return_new (struct ps_expr *value) |
| | Creates a new return statement that returns the expression value.
|
| |
| | PS_IPRINT_IMPL (ps_node_let, { ps_print_indent();printf("let %s%s", self->is_mutable ? "mut " :"", self->name->start);if(self->type) { printf(": ");ps_type_print(self->type, 0);} printf(" = ");ps_expr_print(self->value, 0);}) |
| |
| | PS_IPRINT_IMPL (ps_node_import, { ps_print_indent();printf("import ");for(usize i=0;i< self->name->length;i++) { if(i) printf("::");printf("%s", $arr(self->name)[i]->start);} }) |
| |
| | PS_IPRINT_IMPL (ps_node_expr_stm, { ps_print_indent();ps_expr_print(self->expr, 0);}) |
| |
| | PS_IPRINT_IMPL (ps_node_struct, { ps_print_indent();ps_type_struct_print(self->type, 0, ps_next_indent());}) |
| |
| | PS_IPRINT_IMPL (ps_node_for, { ps_print_indent();}) |
| |
| | PS_IPRINT_IMPL (ps_node_if, { ps_print_indent();printf("if ");ps_expr_print(self->cond, 0);printf(" ");ps_node_block_print(self->body, 0, indent);if(self->else_body) { printf(" else ");ps_node_block_print(self->else_body, 0, indent);} }) |
| |
| | PS_IPRINT_IMPL (ps_node, { switch(self->type) { case PS_NODE_LET:ps_node_let_print(&self->value.let, 0, indent);break;case PS_NODE_FN:ps_node_fn_print(&self->value.fn, 0, indent);break;case PS_NODE_IMPORT:ps_node_import_print(&self->value.import, 0, indent);break;case PS_NODE_EXTERN:ps_node_extern_print(&self->value.extern_, 0, indent);break;case PS_NODE_EXPR_STM:ps_node_expr_stm_print(&self->value.expr_stm, 0, indent);break;case PS_NODE_BLOCK:ps_print_indent();ps_node_block_print(self->value.block, 0, indent);break;case PS_NODE_STRUCT:ps_node_struct_print(&self->value.struct_, 0, indent);break;case PS_NODE_ENUM:ps_node_enum_print(&self->value.enum_, 0, indent);break;case PS_NODE_FOR:ps_node_for_print(&self->value.for_, 0, indent);break;case PS_NODE_WHILE:ps_node_while_print(&self->value.while_, 0, indent);break;case PS_NODE_IF:ps_node_if_print(&self->value.if_, 0, indent);break;case PS_NODE_RETURN:ps_node_return_print(&self->value.return_, 0, indent);break;case PS_NODE_TRAIT:PS_NO_IMPL();case PS_NODE_EXPR:ps_abort("idk what this is");default:ps_abort("you're missing a case here");} }) |
| |
| struct ps_expr * | ps_expr_lit_new_u64 (u64 value, struct ps_token *token) |
| | Creates a new literal expression for an unsigned integer (of at most 64 bits).
|
| |
| struct ps_expr * | ps_expr_lit_new_i64 (i64 value, struct ps_token *token) |
| | Creates a new literal expression for a signed integer (of at most 64 bits).
|
| |
| struct ps_expr * | ps_expr_lit_new_f64 (f64 value, struct ps_token *token) |
| | Creates a new literal expression for a floating point number (of at most 64 bits).
|
| |
| struct ps_expr * | ps_expr_lit_new_bool (bool value, struct ps_token *token) |
| | Creates a new literal expression for a boolean.
|
| |
| struct ps_expr * | ps_expr_lit_new_str (STR value, struct ps_token *token) |
| | Creates a new literal expression for a string.
|
| |
| struct ps_expr * | ps_expr_lit_new_interp_str (struct ps_interp_str *value) |
| | Creates a new literal expression for an interpolated string.
|
| |
| struct ps_expr * | ps_expr_lit_new_unit (struct ps_token *token) |
| | Creates a new literal expression for a unit literal.
|
| |
| struct ps_expr * | ps_expr_binary_new (struct ps_expr *lhs, struct ps_token *op, struct ps_expr *rhs) |
| | Creates a new binary expression.
|
| |
| struct ps_expr * | ps_expr_unary_new (struct ps_token *op, struct ps_expr *rhs) |
| | Creates a new unary expression.
|
| |
| struct ps_expr * | ps_expr_call_new (struct ps_token *callee, struct ps_expr_arr *args) |
| | Creates a new call expression.
|
| |
| | PS_PRINT_IMPL (ps_interp_str, { putchar('"'); for (usize i = 0; i < self->length; i++) { struct ps_expr* part = self->contents[i]; if (part->expr_type == PS_EXPR_LIT_EXPR && part->value.lit_expr.type == PS_EXPR_LIT_STR) { printf("%s", part->value.lit_expr.value.str_val); } else { printf("\\("); ps_expr_print(part, ')'); } } putchar('"');}) |
| |
| | PS_PRINT_IMPL (ps_expr_binary, { putchar('(');ps_expr_print(self->lhs, 0);printf(" %s ", self->op->start);ps_expr_print(self->rhs, 0);putchar(')');}) |
| |
| | PS_PRINT_IMPL (ps_expr_call, { printf("%s(", self->callee->start);for(usize i=0;i< self->args->length;i++) { if(i > 0) { printf(", ");} ps_expr_print(self->args->contents[i], 0);} putchar(')');}) |
| |