<commit_before>#include "lpg_console.h"
#include "lpg_cursor.h"
#include "lpg_allocate.h"
#include <stdio.h>
#include "lpg_for.h"
#include <stdlib.h>
#include <string.h>

static console_color yellow_or(int const condition,
                               console_color const otherwise)
{
    if (condition)
    {
        return console_color_yellow;
    }
    return otherwise;
}

static void render_expression(console_printer *const printer,
                              expression const *const source,
                              cursor_list const cursor)
{
    int const is_selected = (cursor.size == 1);
    switch (source->type)
    {
    case expression_type_lambda:
        console_print_char(
            printer, '/', yellow_or(is_selected, console_color_cyan));
        render_expression(
            printer, source->lambda.parameter_type, descend(cursor, 0));
        console_print_char(printer, ' ', console_color_grey);
        render_expression(
            printer, source->lambda.parameter_name, descend(cursor, 1));
        console_new_line(printer);
        console_print_char(printer, ' ', console_color_grey);
        render_expression(printer, source->lambda.result, descend(cursor, 2));
        break;

    case expression_type_builtin:
        switch (source->builtin)
        {
        case builtin_unit:
            console_print_char(
                printer, '(', yellow_or(is_selected, console_color_grey));
            console_print_char(
                printer, ')', yellow_or(is_selected, console_color_grey));
            break;

        case builtin_empty_structure:
            console_print_char(
                printer, '{', yellow_or(is_selected, console_color_grey));
            console_print_char(
                printer, '}', yellow_or(is_selected, console_color_grey));
            break;

        case builtin_empty_variant:
            console_print_char(
                printer, '[', yellow_or(is_selected, console_color_grey));
            console_print_char(
                printer, ']', yellow_or(is_selected, console_color_grey));
            break;
        }
        break;
    case expression_type_call:
        abort();

    case expression_type_local:
        abort();

    case expression_type_integer_literal:
    {
        char buffer[2 + (4 * 8) + 1];
        if (snprintf(buffer, sizeof(buffer), "0x%08X%08X%08X%08X",
                     (unsigned)(source->integer_literal.high >> 32u),
                     (unsigned)source->integer_literal.high,
                     (unsigned)(source->integer_literal.low >> 32u),
                     (unsigned)source->integer_literal.low) !=
            (sizeof(buffer) - 1))
        {
            abort();
        }
        LPG_FOR(size_t, i, sizeof(buffer) - 1)
        {
            console_print_char(printer, (unicode_code_point)buffer[i],
                               yellow_or(is_selected, console_color_white));
        }
        break;
    }

    case expression_type_integer_range:
        abort();

    case expression_type_function:
        abort();

    case expression_type_add_member:
        abort();

    case expression_type_fill_structure:
        abort();

    case expression_type_access_structure:
        abort();

    case expression_type_add_to_variant:
        abort();

    case expression_type_match:
        abort();

    case expression_type_assignment:
        abort();

    case expression_type_string:
        LPG_FOR(size_t, i, source->string.length)
        {
            if (cursor.size == 1 && (cursor.head->child == i))
            {
                console_print_char(printer, '>', console_color_yellow);
            }
            console_print_char(
                printer, source->string.data[i], console_color_white);
        }
        if (cursor.size == 1 && (cursor.head->child == source->string.length))
        {
            console_print_char(printer, '>', console_color_yellow);
        }
        break;

    case expression_type_identifier:
        abort();
    }
}

enum
{
    console_width = 80,
    console_height = 24
};

static void render(expression const *source, cursor_list const cursors)<commit_msg>add missing switch cases<commit_after>#include "lpg_console.h"
#include "lpg_cursor.h"
#include "lpg_allocate.h"
#include <stdio.h>
#include "lpg_for.h"
#include <stdlib.h>
#include <string.h>

static console_color yellow_or(int const condition,
                               console_color const otherwise)
{
    if (condition)
    {
        return console_color_yellow;
    }
    return otherwise;
}

static void render_expression(console_printer *const printer,
                              expression const *const source,
                              cursor_list const cursor)
{
    int const is_selected = (cursor.size == 1);
    switch (source->type)
    {
    case expression_type_lambda:
        console_print_char(
            printer, '/', yellow_or(is_selected, console_color_cyan));
        render_expression(
            printer, source->lambda.parameter_type, descend(cursor, 0));
        console_print_char(printer, ' ', console_color_grey);
        render_expression(
            printer, source->lambda.parameter_name, descend(cursor, 1));
        console_new_line(printer);
        console_print_char(printer, ' ', console_color_grey);
        render_expression(printer, source->lambda.result, descend(cursor, 2));
        break;

    case expression_type_builtin:
        switch (source->builtin)
        {
        case builtin_unit:
            console_print_char(
                printer, '(', yellow_or(is_selected, console_color_grey));
            console_print_char(
                printer, ')', yellow_or(is_selected, console_color_grey));
            break;

        case builtin_empty_structure:
            console_print_char(
                printer, '{', yellow_or(is_selected, console_color_grey));
            console_print_char(
                printer, '}', yellow_or(is_selected, console_color_grey));
            break;

        case builtin_empty_variant:
            console_print_char(
                printer, '[', yellow_or(is_selected, console_color_grey));
            console_print_char(
                printer, ']', yellow_or(is_selected, console_color_grey));
            break;
        }
        break;
    case expression_type_call:
        abort();

    case expression_type_local:
        abort();

    case expression_type_integer_literal:
    {
        char buffer[2 + (4 * 8) + 1];
        if (snprintf(buffer, sizeof(buffer), "0x%08X%08X%08X%08X",
                     (unsigned)(source->integer_literal.high >> 32u),
                     (unsigned)source->integer_literal.high,
                     (unsigned)(source->integer_literal.low >> 32u),
                     (unsigned)source->integer_literal.low) !=
            (sizeof(buffer) - 1))
        {
            abort();
        }
        LPG_FOR(size_t, i, sizeof(buffer) - 1)
        {
            console_print_char(printer, (unicode_code_point)buffer[i],
                               yellow_or(is_selected, console_color_white));
        }
        break;
    }

    case expression_type_integer_range:
        abort();

    case expression_type_function:
        abort();

    case expression_type_add_member:
        abort();

    case expression_type_fill_structure:
        abort();

    case expression_type_access_structure:
        abort();

    case expression_type_add_to_variant:
        abort();

    case expression_type_match:
        abort();

    case expression_type_assignment:
        abort();

    case expression_type_string:
        LPG_FOR(size_t, i, source->string.length)
        {
            if (cursor.size == 1 && (cursor.head->child == i))
            {
                console_print_char(printer, '>', console_color_yellow);
            }
            console_print_char(
                printer, source->string.data[i], console_color_white);
        }
        if (cursor.size == 1 && (cursor.head->child == source->string.length))
        {
            console_print_char(printer, '>', console_color_yellow);
        }
        break;

    case expression_type_identifier:
    case expression_assign:
    case expression_return:
    case expression_loop:
    case expression_break:
    case expression_sequence:
        abort();
    }
}

enum
{
    console_width = 80,
    console_height = 24
};

static void render(expression const *source, cursor_list const cursors)
{'fraction_non_alphanumeric': 0.10033011082291912, 'fraction_numerical': 0.0068380099033246875, 'mean_word_length': 2.125644804716286, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 49, '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': '1936858', 'n_tokens_mistral': 2475, 'n_tokens_neox': 2397, 'n_words': 432}