38 char const* position =
nullptr;
39 char const* file_end =
nullptr;
40 int32_t current_line = 1;
49 token_generator(
char const* file_start,
char const* fe) : position(file_start), file_end(fe) { }
86 "tried to parse " + std::string(s) +
" as a date on line " + std::to_string(l) +
" of file " +
file_name +
"\n";
90 "tried to parse " + std::string(s) +
" as a float on line " + std::to_string(l) +
" of file " +
file_name +
"\n";
94 "tried to parse " + std::string(s) +
" as a double on line " + std::to_string(l) +
" of file " +
file_name +
"\n";
98 "tried to parse " + std::string(s) +
" as a boolean on line " + std::to_string(l) +
" of file " +
file_name +
"\n";
102 "tried to parse " + std::string(s) +
" as an integer on line " + std::to_string(l) +
" of file " +
file_name +
"\n";
105 accumulated_errors +=
"tried to parse " + std::string(s) +
" as an unsigned integer on line " + std::to_string(l) +
109 accumulated_errors +=
"tried to parse " + std::string(s) +
" as equality or comparison on line " + std::to_string(l) +
119float parse_float(std::string_view content, int32_t line, error_handler& err);
120double parse_double(std::string_view content, int32_t line, error_handler& err);
121bool parse_bool(std::string_view content, int32_t line, error_handler& err);
122int32_t
parse_int(std::string_view content, int32_t line, error_handler& err);
142char const*
csv_advance(
char const* start,
char const* end,
char seperator);
147template<
size_t count_values,
typename T>
149 std::string_view values[count_values];
150 for(
uint32_t i = 0; i < count_values; ++i) {
152 values[i] = std::string_view(start, r.new_position - start);
153 start = r.new_position + int32_t(r.found);
164 std::string_view first_value = std::string_view(start, first_separator.new_position - start);
166 start =
csv_advance_n(nth -
uint32_t(2), first_separator.new_position + int32_t(first_separator.found), end, separator);
170 function(first_value, std::string_view(start, second_end.new_position - start));
174template<
size_t count_values,
typename T>
177 std::string_view first_value = std::string_view(start, first_separator.new_position - start);
178 start = first_separator.new_position + int32_t(first_separator.found);
179 for(
uint32_t i = 0; i < count_values; ++i) {
181 function(first_value, std::string_view(start, r.new_position - start), i);
182 start = r.new_position + int32_t(r.found);
193bool is_integer(
char const* start,
char const* end);
197 if(end - start < ((std::ptrdiff_t)N - 1))
199 for(
unsigned int i = 0; i < N - 1; ++i) {
208 if(end - start < ((std::ptrdiff_t)N - 1))
210 for(
unsigned int i = 0; i < N - 1; ++i) {
211 if(tolower(start[i]) != t[i])
219 if(end - start < ((std::ptrdiff_t)N - 1))
221 for(int32_t i = 0; i < int32_t(N) - 1; ++i) {
222 if(end[-1 - i] != t[(N - i) - 2])
230 if(end - start < ((std::ptrdiff_t)N - 1))
232 for(int32_t i = 0; i < int32_t(N) - 1; ++i) {
233 if(tolower(end[-1 - i]) != t[(N - i) - 2])
242 if(end - start < ((std::ptrdiff_t)N - 1))
244 for(int32_t i = 0; i < int32_t(N) - 1; ++i) {
245 if(towlower(end[-1 - i]) != t[(N - i) - 2])
253 if(end - start < ((std::ptrdiff_t)N - 1))
255 for(int32_t i = 0; i < int32_t(N) - 1; ++i) {
256 if(tolower(end[-1 - i]) != t[(N - i) - 2])
265 if(end - start != (N - 1))
267 for(
unsigned int i = 0; i < N - 1; ++i) {
276 if(end - start != (N - 1))
278 for(
unsigned int i = 0; i < N - 1; ++i) {
279 if(tolower(start[i]) != t[i])
std::string accumulated_errors
void unhandled_group_key(token_and_type const &t)
std::string accumulated_warnings
void unhandled_free_group(token_and_type const &t)
void bad_int(std::string_view s, int32_t l)
void bad_date(std::string_view s, int32_t l)
void bad_double(std::string_view s, int32_t l)
void bad_association_token(std::string_view s, int32_t l)
void unhandled_association_key(token_and_type const &t)
void bad_float(std::string_view s, int32_t l)
void bad_bool(std::string_view s, int32_t l)
error_handler(std::string file_name)
void bad_unsigned_int(std::string_view s, int32_t l)
void unhandled_free_value(token_and_type const &t)
token_generator(char const *file_start, char const *fe)
token_and_type next_next()
bool float_from_chars(char const *start, char const *end, float &float_out)
bool is_integer(char const *start, char const *end)
bool has_fixed_suffix_ci(char const *start, char const *end, char const (&t)[N])
char const * parse_fixed_amount_csv_values(char const *start, char const *end, char separator, T &&function)
char const * parse_first_and_nth_csv_values(uint32_t nth, char const *start, char const *end, char separator, T &&function)
char const * csv_advance_n(uint32_t n, char const *start, char const *end, char seperator)
separator_scan_result csv_find_separator_token(char const *start, char const *end, char seperator)
char const * parse_first_and_fixed_amount_csv_values(char const *start, char const *end, char separator, T &&function)
std::string_view parse_text(std::string_view content, int32_t line, error_handler &err)
char const * csv_advance(char const *start, char const *end, char seperator)
bool native_has_fixed_suffix_ci(char const *start, char const *end, char const (&t)[N])
bool is_fixed_token(char const *start, char const *end, char const (&t)[N])
bool double_from_chars(char const *start, char const *end, double &dbl_out)
bool is_fixed_token_ci(char const *start, char const *end, char const (&t)[N])
sys::year_month_day parse_date(std::string_view content, int32_t line, error_handler &err)
int32_t parse_int(std::string_view content, int32_t line, error_handler &err)
std::string_view remove_surrounding_whitespace(std::string_view txt)
bool parse_bool(std::string_view content, int32_t, error_handler &)
uint32_t parse_tag(std::string_view tag, int32_t line, error_handler &err)
bool has_fixed_suffix(char const *start, char const *end, char const (&t)[N])
float parse_float(std::string_view content, int32_t line, error_handler &err)
uint32_t parse_uint(std::string_view content, int32_t line, error_handler &err)
bool has_fixed_prefix_ci(char const *start, char const *end, char const (&t)[N])
association_type parse_association_type(std::string_view content, int32_t line, error_handler &err)
double parse_double(std::string_view content, int32_t line, error_handler &err)
char const * csv_advance_to_next_line(char const *start, char const *end)
bool has_fixed_prefix(char const *start, char const *end, char const (&t)[N])
char const * new_position