aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/doer.h8
-rw-r--r--src/include/parser.h3
-rw-r--r--src/include/tree.h5
3 files changed, 10 insertions, 6 deletions
diff --git a/src/include/doer.h b/src/include/doer.h
index 641abed..2bdad56 100644
--- a/src/include/doer.h
+++ b/src/include/doer.h
@@ -63,9 +63,9 @@ static tree_type_t blin_print_args[] = { TREE_TYPE_LSTR };
// `printl`: print a string, and add a newline.
void blin_printl(doer_t* doer);
static tree_type_t blin_printl_args[] = { TREE_TYPE_LSTR };
-// `to_str`: convert any (primitive) type to a string.
-void blin_to_str(doer_t* doer);
-static tree_type_t blin_to_str_args[] = { TREE_TYPE_CALL };
+// `str_cat`: concatenate strings.
+void blin_str_cat(doer_t* doer);
+static tree_type_t blin_str_cat_args[] = { TREE_TYPE_LSTR, TREE_TYPE_LSTR };
void doer_do_block(doer_t* tree);
void doer_do_expr(doer_t* tree);
@@ -81,7 +81,7 @@ static blinf_t blinfs[] = {
{ blin_die, TREE_TYPE_LINT, NULL, "die" },
{ blin_print, TREE_TYPE_LSTR, blin_print_args, "print" },
{ blin_printl, TREE_TYPE_LSTR, blin_printl_args, "printl" },
- { blin_to_str, TREE_TYPE_LSTR, blin_to_str_args, "to_str" },
+ { blin_str_cat, TREE_TYPE_LSTR, blin_str_cat_args, "str_cat" },
};
#endif
diff --git a/src/include/parser.h b/src/include/parser.h
index 6961be8..3891a5c 100644
--- a/src/include/parser.h
+++ b/src/include/parser.h
@@ -27,6 +27,9 @@ typedef struct PARSER {
/* The AST being produced. */
tree_t* tree;
+
+ /* The current parent tree node. */
+ tree_t* ltree;
} parser_t;
/* Creates a new parser. */
diff --git a/src/include/tree.h b/src/include/tree.h
index 2a62f26..e1adf85 100644
--- a/src/include/tree.h
+++ b/src/include/tree.h
@@ -19,6 +19,8 @@ typedef enum TREE_TYPE {
typedef struct TREE {
tree_type_t type;
+ struct TREE* parent;
+
union TREE_DATA{
/* Block. */
struct TREE_DATA_BLOCK {
@@ -77,12 +79,11 @@ typedef struct TREE {
char* target;
struct TREE* arg; /* CARG */
} call;
-
} data;
} tree_t;
/* Create a new AST. */
-tree_t* tree_init(tree_type_t type);
+tree_t* tree_init(tree_type_t type, tree_t* parent);
/* Destroy the AST (if it exists). */
void tree_destroy(tree_t* tree);