|
libpulsar
A modular compiler for the pulsar programming language
|
Abstract syntax tree. More...
#include "def.h"#include "enum/make.h"#include "frontend/analyzer/type.h"#include "frontend/lexer/token.h"#include "util/dynarr.h"#include "util/print.h"#include "lit_type.h"#include "expr_type.h"#include "node_type.h"Go to the source code of this file.
Data Structures | |
| struct | ps_node_let |
| Parses "let `name`: `type` = `value`". More... | |
| struct | ps_node_fn |
| struct | ps_node_import |
| struct | ps_node_extern |
| A reference to an external C function. More... | |
| struct | ps_node_expr_stm |
| struct | ps_node_struct |
| struct | ps_node_enum |
| struct | ps_node_for |
| struct | ps_node_while |
| struct | ps_node_if |
| struct | ps_node_return |
| struct | ps_expr_id |
| A variable name. More... | |
| struct | ps_expr_lit |
| An expression literal. More... | |
| union | ps_expr_lit::ps_expr_lit_value |
| struct | ps_expr_binary |
| A binary operator. More... | |
| struct | ps_expr_unary |
| An unary operator. More... | |
| struct | ps_expr_call |
| A function invocation. More... | |
| struct | ps_expr |
| Expression nodes are represented with tagged unions. More... | |
| struct | ps_node |
| AST nodes are represented with tagged unions. More... | |
Macros | |
| #define | ps_name_new() ps_dynarr_new(struct ps_name) |
| #define | ps_name_free(arr) ps_dynarr_free(arr) |
| #define | ps_node_fn_arr_new() ps_dynarr_new(struct ps_node_fn_arr) |
| #define | ps_node_fn_arr_free(arr) ps_dynarr_free(arr) |
| #define | ENUM TO_ENUM |
| #define | ENUM TO_ENUM |
| #define | ENUM TO_ENUM |
| #define | ps_node_arr_new() ps_dynarr_new(struct ps_node_arr) |
| #define | ps_node_arr_free(arr) ps_dynarr_free(arr) |
| #define | ps_node_block_new() ps_dynarr_new(struct ps_node_block) |
| #define | ps_node_block_free(arr) ps_dynarr_free(arr) |
| #define | ps_interp_str_new() ps_dynarr_new(struct ps_interp_str) |
| #define | ps_interp_str_free(arr) ps_dynarr_free(arr) |
| #define | ps_expr_arr_new() ps_dynarr_new(struct ps_expr_arr) |
| #define | ps_expr_arr_free(arr) ps_dynarr_free(arr) |
Enumerations | |
| enum | ps_fn_qualifiers { PS_FN_PUBLIC = 1 << 0 , PS_FN_PRIVATE = 1 << 1 , PS_FN_STATIC = 1 << 2 , PS_FN_INLINE = 1 << 3 } |
| Function qualifier flags. More... | |
Functions | |
| struct ps_name | ps_dynarr (struct ps_token *) |
| A name is a list of identifiers. | |
| PS_PRINT_DECL (ps_name) | |
| struct ps_node_fn_arr | ps_dynarr (struct ps_node_fn) |
| Represents a list of functions. | |
| struct ps_node_arr | ps_dynarr (struct ps_node *) |
| Represents an array of nodes. | |
| struct ps_interp_str | ps_dynarr (struct ps_expr *) |
| Represents a list of expressions concatenated as a string literal. | |
| PS_PRINT_DECL (ps_interp_str) | |
| 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. | |
| struct ps_node * | ps_node_import_new (struct ps_name *name) |
| Creates a new import statement. | |
| 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_DECL (ps_node_let) | |
| PS_IPRINT_DECL (ps_node_fn) | |
| PS_IPRINT_DECL (ps_node_import) | |
| PS_IPRINT_DECL (ps_node_extern) | |
| PS_IPRINT_DECL (ps_node_expr_stm) | |
| PS_IPRINT_DECL (ps_node_struct) | |
| PS_IPRINT_DECL (ps_node_enum) | |
| PS_IPRINT_DECL (ps_node_for) | |
| PS_IPRINT_DECL (ps_node_while) | |
| PS_IPRINT_DECL (ps_node_if) | |
| PS_IPRINT_DECL (ps_node_return) | |
| PS_IPRINT_DECL (ps_node_block) | |
| Prints the given node block to standard out. | |
| PS_IPRINT_DECL (ps_node) | |
| struct ps_expr * | ps_expr_id_new (struct ps_token *name) |
| Creates a new id expression. | |
| 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_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_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_DECL (ps_expr_id) | |
| PS_PRINT_DECL (ps_expr_lit) | |
| PS_PRINT_DECL (ps_expr_binary) | |
| PS_PRINT_DECL (ps_expr_unary) | |
| PS_PRINT_DECL (ps_expr_call) | |
| PS_PRINT_DECL (ps_expr) | |
Abstract syntax tree.
Definition in file ast.h.
| #define ps_expr_arr_free | ( | arr | ) | ps_dynarr_free(arr) |
| #define ps_expr_arr_new | ( | ) | ps_dynarr_new(struct ps_expr_arr) |
| #define ps_interp_str_free | ( | arr | ) | ps_dynarr_free(arr) |
| #define ps_interp_str_new | ( | ) | ps_dynarr_new(struct ps_interp_str) |
| #define ps_name_free | ( | arr | ) | ps_dynarr_free(arr) |
| #define ps_name_new | ( | ) | ps_dynarr_new(struct ps_name) |
| #define ps_node_arr_free | ( | arr | ) | ps_dynarr_free(arr) |
| #define ps_node_arr_new | ( | ) | ps_dynarr_new(struct ps_node_arr) |
| #define ps_node_block_free | ( | arr | ) | ps_dynarr_free(arr) |
| #define ps_node_block_new | ( | ) | ps_dynarr_new(struct ps_node_block) |
| #define ps_node_fn_arr_free | ( | arr | ) | ps_dynarr_free(arr) |
| #define ps_node_fn_arr_new | ( | ) | ps_dynarr_new(struct ps_node_fn_arr) |
| enum ps_fn_qualifiers |
| struct ps_expr_arr ps_dynarr | ( | struct ps_expr * | ) |
Represents a list of expressions concatenated as a string literal.
Represents an array of expressions.
| struct ps_node_block ps_dynarr | ( | struct ps_node * | ) |
Represents an array of nodes.
Represents a block of nodes.
| struct ps_node_fn_arr ps_dynarr | ( | struct ps_node_fn | ) |
Represents a list of functions.
| struct ps_name ps_dynarr | ( | struct ps_token * | ) |
A name is a list of identifiers.
| struct ps_expr * ps_expr_lit_new_interp_str | ( | struct ps_interp_str * | value | ) |
| PS_IPRINT_DECL | ( | ps_node | ) |
| PS_IPRINT_DECL | ( | ps_node_block | ) |
Prints the given node block to standard out.
| PS_IPRINT_DECL | ( | ps_node_enum | ) |
| PS_IPRINT_DECL | ( | ps_node_expr_stm | ) |
| PS_IPRINT_DECL | ( | ps_node_extern | ) |
| PS_IPRINT_DECL | ( | ps_node_fn | ) |
| PS_IPRINT_DECL | ( | ps_node_for | ) |
| PS_IPRINT_DECL | ( | ps_node_if | ) |
| PS_IPRINT_DECL | ( | ps_node_import | ) |
| PS_IPRINT_DECL | ( | ps_node_let | ) |
| PS_IPRINT_DECL | ( | ps_node_return | ) |
| PS_IPRINT_DECL | ( | ps_node_struct | ) |
| PS_IPRINT_DECL | ( | ps_node_while | ) |
| struct ps_node * ps_node_block_stm_new | ( | struct ps_node_block * | block | ) |
| struct ps_node * ps_node_enum_new | ( | struct ps_type_enum * | type, |
| struct ps_node_fn_arr * | methods | ||
| ) |
| 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.
| ret_type | The return type of the function, or NULL if there is none. |
| qualifiers | Function qualifiers such as static. |
| 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 | ||
| ) |
| struct ps_node * ps_node_import_new | ( | struct ps_name * | name | ) |
Creates a new import statement.
| name | The name of the module to import. |
| struct ps_node * ps_node_struct_new | ( | struct ps_type_struct * | type, |
| struct ps_node_fn_arr * | methods | ||
| ) |
| PS_PRINT_DECL | ( | ps_expr | ) |
| PS_PRINT_DECL | ( | ps_expr_binary | ) |
| PS_PRINT_DECL | ( | ps_expr_call | ) |
| PS_PRINT_DECL | ( | ps_expr_id | ) |
| PS_PRINT_DECL | ( | ps_expr_lit | ) |
| PS_PRINT_DECL | ( | ps_expr_unary | ) |
| PS_PRINT_DECL | ( | ps_interp_str | ) |
| PS_PRINT_DECL | ( | ps_name | ) |