rtengine/src/asset_compiler/description_parser.h
Kevin Trogant 027ef8a46f Restructure the project
Move asset_compiler into its own (static) library.
This removes the dependency on it from the runtime and makes it possible
to have a standalone asset_compiler tool (useful for modding support).

Split meson.build into sub-files to improve readability.

Give each target its own pch directory.
This is more inline with what the meson manual recommends.

Export dependencies to make it possible to use the engine as a meson
subproject.
This is currently untested.
2024-02-07 13:56:06 +01:00

66 lines
1.4 KiB
C

#ifndef RT_ASSETC_DESCRIPTION_PARSER_H
#define RT_ASSETC_DESCRIPTION_PARSER_H
#include "runtime/runtime.h"
#ifdef __cplusplus
extern "C" {
#endif
struct rt_arena_s;
typedef enum {
RT_STMT_FORM_VALUE,
RT_STMT_FORM_LIST,
RT_STMT_FORM_BLOCK,
} rt_stmt_form;
typedef struct {
unsigned int first;
unsigned int count;
} rt_parsed_stmt_list;
typedef struct {
rt_stmt_form form;
rt_text_span attribute;
union {
rt_text_span value;
rt_text_span block;
unsigned int list_index;
};
/* For lists */
unsigned int next;
} rt_parsed_stmt;
typedef struct {
const char *file;
const char *text;
size_t at;
size_t length;
int line;
rt_parsed_stmt *statements;
unsigned int statement_count;
unsigned int statement_capacity;
rt_parsed_stmt_list *statement_lists;
unsigned int statement_list_count;
unsigned int statement_list_capacity;
} rt_parse_state;
rt_result rtParseDescription(const char *text,
size_t length,
const char *file_path,
unsigned int *root_list,
rt_parse_state *state,
struct rt_arena_s *arena);
const rt_parsed_stmt *
rtFindStatement(const rt_parse_state *state, unsigned int list_index, const char *attribute);
#ifdef __cplusplus
}
#endif
#endif