/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #pragma onces #ifdef __cplusplus extern "C" { #endif #include "tlibtoml/toml.h" #include "tlibc/string/StringBuilder.h" #include "tlibc/collections/HashMap.h" #include "tlibc/collections/List.h" // TODO: get rid of libc assert #include #include typedef struct _TomlParser { cstr begin; cstr end; cstr ptr; i32 lineno; i32 colno; cstr filename; } TomlParser; TomlParser* toml_parser_new(str s, cstr filename); void toml_parser_free(TomlParser* self); void toml_move_next(TomlParser* self); void toml_next_n(TomlParser* self, i32 n); str toml_parse_bare_key(TomlParser* self); char toml_hex_char_to_int(char ch); Result(void) toml_encode_unicode_scalar(StringBuilder* sb_ptr, TomlParser* parser, i32 n); Result(str*) toml_parse_basic_string(TomlParser* self); Result(str*) toml_parse_literal_string(TomlParser* self); TomlValue toml_parse_basic_string_value(TomlParser* self); TomlValue toml_parse_literal_string_value(TomlParser* self); TomlValue toml_parse_multi_line_basic_string(TomlParser* self); TomlValue toml_parse_multi_line_literal_string(TomlParser* self); TomlValue toml_parse_datetime(str s); TomlValue toml_parse_int_or_float_or_time(TomlParser* self); TomlValue toml_parse_bool(TomlParser* self); TomlValue toml_parse_value(TomlParser* self); TomlValue toml_parse_array(TomlParser* self); TomlValue toml_parse_inline_table(TomlParser* self); Result(void) toml_parse_table(TomlParser* self, TomlTable* table); Result(void) toml_parse_key_value(TomlParser* self, TomlTable* table); Result(TomlTable*) toml_walk_table_path(TomlParser* parser, TomlTable* table, TomlArray* key_path, i32 is_array, i32 create_if_not_exist); #ifdef __cplusplus } #endif