<commit_before>#include "shadowdive/stringparser.h"
#include "shadowdive/internal/helpers.h"
#include "shadowdive/error.h"

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <stdio.h>
#include <stdint.h>

// private structs
typedef struct tag_attribute_t {
    const sd_stringparser_tag_info *tag_info;

    // the fields in value get updated whenever the parser runs
    sd_stringparser_tag_value value;
} tag_attribute;

typedef struct tag_list_t {
    // traverse tag_chain to find whether a given tag is valid or not
    struct tag_list_t *tag_chain[256];
    tag_attribute attrib;
} tag_list;

typedef struct anim_frame_t {
    // is_done is set to 1 if this frame is completed also no further processing for this frame 
    int is_done;

    // the duration of this frame in "ticks"
    int duration;

    int start_tick;

    // frame letter is always uppercase
    char frame_letter;

    // a list of tags ready to be "interpreted"
    int num_tags;
    const char **tags;
    int *tag_params;
    
    // used for O(1) tag lookup
    tag_list *tag_list;
} anim_frame;

typedef struct frame_list_t {
    unsigned int num_frames;
    anim_frame *frames;

    int next_frame;
    unsigned int last_tick;
} frame_list;

enum {
    TAG_TAG=0,
    TAG_FRAME,
    TAG_MARKER,
    TAG_END
};

static tag_list *static_taglist = NULL;

static const sd_stringparser_tag_value null_tag = {0,0};

// list of valid tags and whether it has param or not
static const sd_stringparser_tag_info tags[] = {
    {"aa", 0, NULL},
    {"ab", 0, NULL},
    {"ac", 0, NULL},
    {"ad", 0, NULL},
    {"ae", 0, NULL}, 
    {"af", 0, NULL},
    {"ag", 0, NULL},
    {"ai", 0, NULL},
    {"am", 0, NULL},
    {"ao", 0, NULL},
    {"as", 0, NULL},
    {"at", 0, NULL},
    {"aw", 0, NULL},
    {"ax", 0, NULL},
    {"ar", 0, NULL},
    {"al", 0, NULL},

    {"b1", 0, NULL},
    {"b2", 0, NULL},
    {"bb", 1, NULL},
    {"be", 0, NULL},
    {"bf", 1, "Blend finish"},
    {"bh", 0, NULL},
    {"bl", 1, NULL},
    {"bm", 1, NULL},
    {"bj", 1, NULL},
    {"bs", 1, "Blend start"},
    {"bu", 0, NULL},
    {"bw", 0, NULL},
    {"bx", 0, NULL},

    {"bpd", 1, NULL},
    {"bps", 1, NULL},
    {"bpn", 1, NULL},
    {"bpf", 0, NULL},
    {"bpp", 1, NULL},
    {"bpb", 1, NULL},
    {"bpo", 0, NULL},
    {"bz",  0, NULL},

    {"ba", 1, NULL},
    {"bc", 1, NULL},
    {"bd", 0, NULL},
    {"bg", 0, NULL},
    {"bi", 1, NULL},
    {"bk", 1, NULL},
    {"bn", 0, NULL},
    {"bo", 1, NULL},
    {"br", 0, "Draw additively?"},
    {"bt", 0, NULL},
    {"by", 0, NULL},

    {"cf", 0, NULL},
    {"cg", 0, NULL},
    {"cl", 0, NULL},
    {"cp", 0, "Apply damage?"},
    {"cw", 0, NULL},
    {"cx", 1, NULL},
    {"cy", 1, NULL},

    {"d", 1, "Re-enter animation at N ticks"},
    {"e", 0, NULL},
    {"f", 0, "Flip sprite vertically?"},
    {"g", 0, NULL},
    {"h", 0, NULL},
    {"i", 0, NULL},

    {"jf2", 0, "Allow chaining to destruction?"},
    {"jf", 0, "Allow chaining to scrap?"},
    {"jg", 0, NULL},
    {"jh", 0, "Allow chaining to 'high' moves?"},
    {"jj", 0, NULL},
    {"jl", 0, "Allow chaining to 'low' moves?"},
    {"jm", 0, "Allow chaining to 'mid' moves?"},
    {"jp", 0, NULL},
    {"jz", 0, "Allow chaining to anything? (Katana head stomp)"},
    {"jn", 1, "Allow chaining to move N?"},

    {"k",   1, NULL},
    {"l",   1, "Sound loudness"},
    {"ma",  1, NULL},
    {"mc",  0, NULL},
    {"md",  1, "Destroy animation N?"},
    {"mg",  1, NULL},
    {"mi",  1, NULL},
    {"mm",  1, NULL},
    {"mn",  1, NULL},
    {"mo",  0, NULL},
    {"mp",  1, NULL},
    {"mrx", 1, NULL},
    {"mry", 1, NULL},
    {"ms",  0, NULL},
    {"mu",  1, NULL},
    {"mx",  1, "X position of new animation?"},
    {"my",  1, "Y position of new animation?"},
    {"m",   1, "Create instance of animation N"},
    {"n",   0, NULL},
    {"ox",  1, NULL},
    {"oy",  1, NULL},
    {"pa",  0, NULL},
    {"pb",  1, NULL},<commit_msg>mx and my tags can be relative<commit_after>#include "shadowdive/stringparser.h"
#include "shadowdive/internal/helpers.h"
#include "shadowdive/error.h"

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <stdio.h>
#include <stdint.h>

// private structs
typedef struct tag_attribute_t {
    const sd_stringparser_tag_info *tag_info;

    // the fields in value get updated whenever the parser runs
    sd_stringparser_tag_value value;
} tag_attribute;

typedef struct tag_list_t {
    // traverse tag_chain to find whether a given tag is valid or not
    struct tag_list_t *tag_chain[256];
    tag_attribute attrib;
} tag_list;

typedef struct anim_frame_t {
    // is_done is set to 1 if this frame is completed also no further processing for this frame 
    int is_done;

    // the duration of this frame in "ticks"
    int duration;

    int start_tick;

    // frame letter is always uppercase
    char frame_letter;

    // a list of tags ready to be "interpreted"
    int num_tags;
    const char **tags;
    int *tag_params;
    
    // used for O(1) tag lookup
    tag_list *tag_list;
} anim_frame;

typedef struct frame_list_t {
    unsigned int num_frames;
    anim_frame *frames;

    int next_frame;
    unsigned int last_tick;
} frame_list;

enum {
    TAG_TAG=0,
    TAG_FRAME,
    TAG_MARKER,
    TAG_END
};

static tag_list *static_taglist = NULL;

static const sd_stringparser_tag_value null_tag = {0,0};

// list of valid tags and whether it has param or not
static const sd_stringparser_tag_info tags[] = {
    {"aa", 0, NULL},
    {"ab", 0, NULL},
    {"ac", 0, NULL},
    {"ad", 0, NULL},
    {"ae", 0, NULL}, 
    {"af", 0, NULL},
    {"ag", 0, NULL},
    {"ai", 0, NULL},
    {"am", 0, NULL},
    {"ao", 0, NULL},
    {"as", 0, NULL},
    {"at", 0, NULL},
    {"aw", 0, NULL},
    {"ax", 0, NULL},
    {"ar", 0, NULL},
    {"al", 0, NULL},

    {"b1", 0, NULL},
    {"b2", 0, NULL},
    {"bb", 1, NULL},
    {"be", 0, NULL},
    {"bf", 1, "Blend finish"},
    {"bh", 0, NULL},
    {"bl", 1, NULL},
    {"bm", 1, NULL},
    {"bj", 1, NULL},
    {"bs", 1, "Blend start"},
    {"bu", 0, NULL},
    {"bw", 0, NULL},
    {"bx", 0, NULL},

    {"bpd", 1, NULL},
    {"bps", 1, NULL},
    {"bpn", 1, NULL},
    {"bpf", 0, NULL},
    {"bpp", 1, NULL},
    {"bpb", 1, NULL},
    {"bpo", 0, NULL},
    {"bz",  0, NULL},

    {"ba", 1, NULL},
    {"bc", 1, NULL},
    {"bd", 0, NULL},
    {"bg", 0, NULL},
    {"bi", 1, NULL},
    {"bk", 1, NULL},
    {"bn", 0, NULL},
    {"bo", 1, NULL},
    {"br", 0, "Draw additively?"},
    {"bt", 0, NULL},
    {"by", 0, NULL},

    {"cf", 0, NULL},
    {"cg", 0, NULL},
    {"cl", 0, NULL},
    {"cp", 0, "Apply damage?"},
    {"cw", 0, NULL},
    {"cx", 1, NULL},
    {"cy", 1, NULL},

    {"d", 1, "Re-enter animation at N ticks"},
    {"e", 0, NULL},
    {"f", 0, "Flip sprite vertically?"},
    {"g", 0, NULL},
    {"h", 0, NULL},
    {"i", 0, NULL},

    {"jf2", 0, "Allow chaining to destruction?"},
    {"jf", 0, "Allow chaining to scrap?"},
    {"jg", 0, NULL},
    {"jh", 0, "Allow chaining to 'high' moves?"},
    {"jj", 0, NULL},
    {"jl", 0, "Allow chaining to 'low' moves?"},
    {"jm", 0, "Allow chaining to 'mid' moves?"},
    {"jp", 0, NULL},
    {"jz", 0, "Allow chaining to anything? (Katana head stomp)"},
    {"jn", 1, "Allow chaining to move N?"},

    {"k",   1, NULL},
    {"l",   1, "Sound loudness"},
    {"ma",  1, NULL},
    {"mc",  0, NULL},
    {"md",  1, "Destroy animation N?"},
    {"mg",  1, NULL},
    {"mi",  1, NULL},
    {"mm",  1, NULL},
    {"mn",  1, NULL},
    {"mo",  0, NULL},
    {"mp",  1, NULL},
    {"mrx", 1, NULL},
    {"mry", 1, NULL},
    {"ms",  0, NULL},
    {"mu",  1, NULL},
    {"mx+",  1, "X position of new animation, relative to current one"},
    {"mx-",  1, "X position of new animation, relative to current one"},
    {"mx",  1, "X position of new animation, absolute coordinate"},
    {"my+",  1, "Y position of new animation, relative to current one"},
    {"my-",  1, "Y position of new animation, relative to current one"},
    {"my",  1, "Y position of new animation, absolute coordinate"},
    {"m",   1, "Create instance of animation N"},
    {"n",   0, NULL},
    {"ox",  1, NULL},
    {"oy",  1, NULL},
    {"pa",  0, NULL},
    {"pb",  1, NULL},
{'fraction_non_alphanumeric': 0.20829805249788316, 'fraction_numerical': 0.025886052981734606, 'mean_word_length': 2.6503311258278144, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '1830997', 'n_tokens_mistral': 3325, 'n_tokens_neox': 3084, 'n_words': 1055}