8 return (c ==
' ') || (c ==
'\r') || (c ==
'\f') || (c ==
'\n') || (c ==
'\t') || (c ==
',') || (c ==
';');
12 return (c ==
'!') || (c ==
'=') || (c ==
'<') || (c ==
'>');
24 return (c ==
'\r') || (c ==
'\n');
28 return (c ==
'\r') || (c ==
'\n') || (c ==
'\"');
32 return (c ==
'\r') || (c ==
'\n') || (c ==
'\'');
56 auto const decimal = std::find(start, end,
'.');
59 }
else if(decimal == start) {
66bool is_fp(
char const* start,
char const* end) {
76char const*
scan_for_match(
char const* start,
char const* end, int32_t& current_line, T&& condition) {
87char const*
scan_for_not_match(
char const* start,
char const* end, int32_t& current_line, T&& condition) {
89 if(!condition(*start))
109 while(position < end && *position ==
'#') {
120token_and_type token_generator::internal_next() {
121 if(position >= file_end)
125 if(non_ws < file_end) {
127 position = non_ws + 1;
129 }
else if(*non_ws ==
'}') {
130 position = non_ws + 1;
132 }
else if(*non_ws ==
'\"') {
134 position =
close + 1;
136 }
else if(*non_ws ==
'\'') {
138 position =
close + 1;
144 position = non_ws + 2;
146 }
else if(*non_ws ==
'<' || *non_ws ==
'>' || *non_ws ==
'=') {
148 position = non_ws + 1;
162 auto const temp = peek_1;
168 return internal_next();
173 peek_1 = internal_next();
180 peek_1 = internal_next();
183 peek_2 = internal_next();
189 int32_t brace_count = 0;
191 while(brace_count >= 0 && !
at_end()) {
202 if(content.length() == 0)
205 return (content[0] ==
'Y') || (content[0] ==
'y') || (content[0] ==
'1');
211 if(!
float_from_chars(content.data(), content.data() + content.length(), rvalue)) {
220 if(!
double_from_chars(content.data(), content.data() + content.length(), rvalue)) {
228 auto result = std::from_chars(content.data(), content.data() + content.length(), rvalue);
229 if(result.ec == std::errc::invalid_argument) {
237 auto result = std::from_chars(content.data(), content.data() + content.length(), rvalue);
238 if(result.ec == std::errc::invalid_argument) {
245 if(tag.length() != 3) {
247 err.
file_name +
" line " + std::to_string(line) +
": encountered a tag that was not three characters\n";
254 auto position = content.data();
255 auto value_end = position + content.length();
257 for(; position < value_end && !isdigit(*position); ++position)
259 auto year_start = position;
260 for(; position < value_end && isdigit(*position); ++position)
262 auto year_end = position;
264 for(; position < value_end && !isdigit(*position); ++position)
266 auto month_start = position;
267 for(; position < value_end && isdigit(*position); ++position)
269 auto month_end = position;
271 for(; position < value_end && !isdigit(*position); ++position)
273 auto day_start = position;
274 for(; position < value_end && isdigit(*position); ++position)
276 auto day_end = position;
279 uint16_t(
parsers::parse_uint(std::string_view(month_start, month_end - month_start), line, err)),
280 uint16_t(
parsers::parse_uint(std::string_view(day_start, day_end - day_start), line, err))};
284 return content.length() != 0 && content[0] == v;
288 if(content.length() == 1) {
289 if(content[0] ==
'>')
291 else if(content[0] ==
'<')
293 else if(content[0] ==
'=')
295 }
else if(content.length() == 2) {
296 if(content[0] ==
'=' && content[1] ==
'=')
298 else if(content[0] ==
'<' && content[1] ==
'=')
300 else if(content[0] ==
'>' && content[1] ==
'=')
302 else if(content[0] ==
'!' && content[1] ==
'=')
304 else if(content[0] ==
'<' && content[1] ==
'>')
325 while(start != end) {
328 else if(*start == seperator)
336char const*
csv_advance(
char const* start,
char const* end,
char seperator) {
337 while(start != end) {
340 else if(*start == seperator)
354 while(start != end) {
357 else if(*start == seperator) {
375 if(start == end || *start !=
'#')
382 char const* start = txt.data();
383 char const* end = txt.data() + txt.length();
384 for(; start < end; ++start) {
385 if(*start !=
' ' && *start !=
'\t' && *start !=
'\r' && *start !=
'\n')
388 for(; start < end; --end) {
389 if(*(end - 1) !=
' ' && *(end - 1) !=
'\t' && *(end - 1) !=
'\r' && *(end - 1) !=
'\n')
392 return std::string_view(start, end - start);
std::string accumulated_errors
void bad_int(std::string_view s, int32_t l)
void bad_association_token(std::string_view s, int32_t l)
void bad_float(std::string_view s, int32_t l)
void bad_unsigned_int(std::string_view s, int32_t l)
token_and_type next_next()
uint32_t tag_to_int(char first, char second, char third)
bool float_from_chars(char const *start, char const *end, float &float_out)
char const * advance_position_to_next_line(char const *start, char const *end, int32_t ¤t_line)
bool is_integer(char const *start, char const *end)
char const * scan_for_match(char const *start, char const *end, int32_t ¤t_line, T &&condition)
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)
bool special_identifier_char(char c)
bool breaking_char(char c)
bool is_positive_integer(char const *start, char const *end)
char const * csv_advance(char const *start, char const *end, char seperator)
bool ignorable_char(char c)
char const * advance_position_to_breaking_char(char const *start, char const *end, int32_t ¤t_line)
bool not_special_identifier_char(char c)
bool double_quote_termination(char c)
bool double_from_chars(char const *start, char const *end, double &dbl_out)
char const * advance_position_to_non_comment(char const *start, char const *end, int32_t ¤t_line)
char const * scan_for_not_match(char const *start, char const *end, int32_t ¤t_line, T &&condition)
sys::year_month_day parse_date(std::string_view content, int32_t line, error_handler &err)
bool line_termination(char c)
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)
float parse_float(std::string_view content, int32_t line, error_handler &err)
bool starts_with(std::string_view content, char v)
bool is_positive_fp(char const *start, char const *end)
uint32_t parse_uint(std::string_view content, int32_t line, error_handler &err)
bool single_quote_termination(char c)
bool is_fp(char const *start, char const *end)
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 * advance_position_to_non_whitespace(char const *start, char const *end, int32_t ¤t_line)
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])