<commit_before>#include "lily_ast.h"
#include "lily_impl.h"

lily_ast *lily_ast_init_call(lily_symbol *s)
{
    lily_ast *a = lily_impl_malloc(sizeof(lily_ast));

    a->expr_type = func_call;
    a->data.call.sym = s;
    a->data.call.num_args = 0;
    a->data.call.args = NULL;
}

lily_ast *lily_ast_init_var(lily_symbol *s)
{
    lily_ast *a = lily_impl_malloc(sizeof(lily_ast));

    a->expr_type = var;
    a->data.value = s;
}

void lily_ast_add_arg(lily_ast *func, lily_ast *tree)
{
    struct lily_ast_list *l = lily_impl_malloc(sizeof(struct lily_ast_list));

    l->ast = tree;
    l->next = func->data.call.args;
    func->data.call.num_args++;
    func->data.call.args = l;
}<commit_msg>lily_ast.c: Write a note about trees being walked backwards.<commit_after>#include "lily_ast.h"
#include "lily_impl.h"

lily_ast *lily_ast_init_call(lily_symbol *s)
{
    lily_ast *a = lily_impl_malloc(sizeof(lily_ast));

    a->expr_type = func_call;
    a->data.call.sym = s;
    a->data.call.num_args = 0;
    a->data.call.args = NULL;
}

lily_ast *lily_ast_init_var(lily_symbol *s)
{
    lily_ast *a = lily_impl_malloc(sizeof(lily_ast));

    a->expr_type = var;
    a->data.value = s;
}

void lily_ast_add_arg(lily_ast *func, lily_ast *tree)
{
    /* fixme: This starts from the last arg and goes to the first arg, so trees
       get walked backwards and args emitted in the wrong order. Fix this when
       there's a function that needs 2+ args. */
    struct lily_ast_list *l = lily_impl_malloc(sizeof(struct lily_ast_list));

    l->ast = tree;
    l->next = func->data.call.args;
    func->data.call.num_args++;
    func->data.call.args = l;
}
{'fraction_non_alphanumeric': 0.13732607380520268, 'fraction_numerical': 0.0018148820326678765, 'mean_word_length': 3.569060773480663, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5575860', 'n_tokens_mistral': 684, 'n_tokens_neox': 671, 'n_words': 133}