f_array_length_t slash_last = 0;
f_array_length_t before_list_open = position_previous;
- // Designate that this is the first graph character.
- // 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set.
- uint8_t graph_first = 0x1;
- uint8_t is_open = F_false;
- uint8_t is_object = F_false;
+ // 0x0 = is false for all, 0x1 = is first graph, 0x2 = is delimited comment, 0x4 = is open, 0x8 = is object, 0x10 = is delimited close.
+ uint8_t is_state = 0x1;
// Initialize depth 1 start position.
// Positions_start.used is used as a max depth (such that positions_start.used == max depth + 1).
}
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- if (graph_first == 0x2) {
+ if (is_state & 0x2) {
status = f_array_lengths_increase(state.step_small, delimits);
if (F_status_is_error(status)) break;
delimits->array[delimits->used++] = comment_delimit;
}
- newline_last = range->start;
- position_previous = range->start++;
- graph_first = 0x1;
+ newline_last = position_previous = range->start++;
line_start = range->start;
-
- if (depth) {
- private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop);
- }
- else {
- private_macro_fl_fss_nest_return_on_overflow_delimited((buffer), (*range), (*found), positions_start, objects, slashes, F_none_eos, F_none_stop);
- }
-
- continue;
+ is_state = 0x1;
}
-
- if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0]) {
- slash_first = range->start;
- slash_last = range->start;
+ else if (buffer.string[range->start] == f_fss_delimit_slash_s.string[0] && (is_state & 0x1)) {
+ slash_first = slash_last = position_previous = range->start++;
slashes.array[depth] = 1;
- position_previous = range->start++;
for (; range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_delimit_placeholder_s.string[0] || buffer.string[range->start] == f_fss_delimit_slash_s.string[0]); ++range->start) {
}
} // for
- if (F_status_is_error(status)) break;
-
- if (depth) {
- private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop);
- }
- else {
- private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop);
- }
+ if (F_status_is_error(status) || range->start >= buffer.used || range->start > range->stop) break;
// All slashes for an open are delimited (because it could represent a slash in the object name).
// For example 'object {' = valid open, name 'object', 'object \{' represents 'object {', 'object \\{' = valid open, name 'object \', 'object \\\{' represents 'object \{', etc..
// For example '}' = valid close, '\}' represents '}', '\\}' represents '\}', '\\\}' represents '\\}', '\\\\}' represents '\\\}', and so on..
// When slash is odd and a (delimited) valid open/close is found, then save delimited positions and continue.
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- if (graph_first == 0x2) {
+ if (is_state & 0x2) {
status = f_array_lengths_increase(state.step_small, delimits);
if (F_status_is_error(status)) break;
delimits->array[delimits->used++] = comment_delimit;
}
- newline_last = range->start;
- position_previous = range->start++;
+ newline_last = position_previous = range->start++;
line_start = range->start;
- graph_first = 0x1;
+ is_state = 0x1;
}
else if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0] || buffer.string[range->start] == f_fss_embedded_list_close_s.string[0]) {
before_list_open = position_previous;
- is_open = F_false;
- graph_first = 0x0;
+ is_state &= ~0x15;
if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0]) {
- is_open = F_true;
+ is_state |= 0x4;
}
position_previous = range->start++;
}
}
- if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- if (graph_first == 0x2) {
- status = f_array_lengths_increase(state.step_small, delimits);
- if (F_status_is_error(status)) break;
-
- delimits->array[delimits->used++] = comment_delimit;
- }
-
- newline_last = range->start;
- line_start = range->start + 1;
- graph_first = 0x1;
-
- break;
- }
+ if (buffer.string[range->start] == f_fss_eol_s.string[0]) break;
if (buffer.string[range->start] != f_fss_delimit_placeholder_s.string[0]) {
status = f_fss_is_space(state, buffer, *range);
if (F_status_is_error(status)) break;
} // while
- if (F_status_is_error(status)) break;
-
- if (depth) {
- private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop);
- }
- else {
- private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop);
- }
+ if (F_status_is_error(status) || range->start >= buffer.used || range->start > range->stop) break;
// This is a valid object open/close that has been delimited, save the slash delimit positions.
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
newline_last = range->start;
- line_start = range->start + 1;
- graph_first = 0x1;
+ line_start = newline_last + 1;
+
+ if (is_state & 0x4) {
+ if (slashes.array[depth] % 2 == 0) {
+ is_state |= 0x8;
+ }
+ else {
+ is_state &= ~0x8;
+ }
- if (is_open) {
- is_object = slashes.array[depth] % 2 == 0 ? F_true : F_false;
range->start = slash_first;
status = f_array_lengths_increase_by((slashes.array[depth] / 2) + 1, delimits);
} // while
// When slashes are even, the object is valid and needs to be processed.
- if (is_object) {
+ if (is_state & 0x8) {
if (++depth >= objects.size) {
status = f_string_ranges_resize(depth + 2, &objects);
- if (F_status_is_error(status)) break;
}
if (depth >= positions_start.size) {
- status = f_array_lengths_resize(depth + 2, &positions_start);
- if (F_status_is_error(status)) break;
+ if (F_status_is_error_not(status)) {
+ status = f_array_lengths_resize(depth + 2, &positions_start);
+ }
}
if (depth >= slashes.size) {
- status = f_array_lengths_resize(depth + 2, &slashes);
- if (F_status_is_error(status)) break;
+ if (F_status_is_error_not(status)) {
+ status = f_array_lengths_resize(depth + 2, &slashes);
+ }
}
+ if (F_status_is_error(status)) break;
+
objects.array[depth].start = line_start;
objects.array[depth].stop = before_list_open;
positions_start.array[depth] = newline_last + 1;
}
}
else {
+ is_state |= 0x10;
+ }
+
+ if (is_state & 0x12) {
status = f_array_lengths_increase(state.step_small, delimits);
if (F_status_is_error(status)) break;
delimits->array[delimits->used++] = slash_last;
}
- range->start = newline_last;
+ range->start = line_start;
+ is_state = 0x1;
}
}
- else if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s.string[0]) {
- graph_first = 0x2;
+ else if (buffer.string[range->start] == f_fss_comment_s.string[0] && (is_state & 0x1)) {
+ is_state |= 0x2;
+ is_state &= ~0x1;
comment_delimit = slash_first;
}
else {
- graph_first = 0x0;
+ is_state &= ~0x1;
}
}
else if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0]) {
- graph_first = 0x0;
+ is_state &= ~0x1;
before_list_open = position_previous;
position_previous = range->start;
if (F_status_is_error(status)) break;
} // while
- if (F_status_is_error(status)) break;
-
- if (depth) {
- private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop);
- }
- else {
- private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop);
- }
+ if (F_status_is_error(status) || range->start >= buffer.used || range->start > range->stop) break;
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
if (++depth >= objects.size) {
}
if (depth >= positions_start.size) {
- status = f_array_lengths_resize(depth + 2, &positions_start);
- if (F_status_is_error(status)) break;
+ if (F_status_is_error_not(status)) {
+ status = f_array_lengths_resize(depth + 2, &positions_start);
+ }
}
if (depth >= slashes.size) {
- status = f_array_lengths_resize(depth + 2, &slashes);
- if (F_status_is_error(status)) break;
+ if (F_status_is_error_not(status)) {
+ status = f_array_lengths_resize(depth + 2, &slashes);
+ }
}
+ if (F_status_is_error(status)) break;
+
objects.array[depth].start = line_start;
objects.array[depth].stop = before_list_open;
positions_start.array[depth] = range->start + 1;
slashes.used = depth + 1;
}
- if (graph_first == 0x2) {
+ if (is_state & 0x2) {
status = f_array_lengths_increase(state.step_small, delimits);
if (F_status_is_error(status)) break;
}
newline_last = range->start;
- line_start = range->start + 1;
- graph_first = 0x1;
+ line_start = newline_last + 1;
+ is_state = 0x1;
}
else {
status = f_fss_seek_to_eol(state, buffer, range);
if (F_status_is_error(status)) break;
- if (graph_first == 0x2) {
+ if (is_state & 0x2) {
status = f_array_lengths_increase(state.step_small, delimits);
if (F_status_is_error(status)) break;
}
newline_last = range->start;
- line_start = range->start + 1;
- graph_first = 0x1;
-
- while (range->start <= range->stop && range->start < buffer.used) {
-
- if (state.interrupt) {
- status = state.interrupt((void *) &state, 0);
-
- if (F_status_set_fine(status) == F_interrupt) {
- status = F_status_set_error(F_interrupt);
-
- break;
- }
- }
-
- if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- newline_last = range->start;
- line_start = range->start + 1;
- graph_first = 0x1;
-
- break;
- }
-
- position_previous = range->start;
-
- status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(status)) break;
- } // while
-
- if (F_status_is_error(status)) break;
-
- if (depth) {
- private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop);
- }
- else {
- private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop);
- }
+ line_start = newline_last + 1;
+ is_state = 0x1;
}
}
- else if (buffer.string[range->start] == f_fss_embedded_list_close_s.string[0]) {
+ else if (buffer.string[range->start] == f_fss_embedded_list_close_s.string[0] && (is_state & 0x1)) {
while (range->start <= range->stop && range->start < buffer.used) {
if (state.interrupt) {
position_previous = range->start;
status = f_utf_buffer_increment(buffer, range, 1);
-
- if (F_status_is_error(status)) break;
- if (buffer.string[range->start] == f_fss_eol_s.string[0]) break;
+ if (F_status_is_error(status) || buffer.string[range->start] == f_fss_eol_s.string[0]) break;
if (buffer.string[range->start] != f_fss_delimit_placeholder_s.string[0]) {
status = f_fss_is_space(state, buffer, *range);
}
} // while
- if (F_status_is_error(status)) break;
-
- if (depth) {
- private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop);
- }
- else {
- private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop);
- }
+ if (F_status_is_error(status) || range->start >= buffer.used || range->start > range->stop) break;
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
if (depth >= found->used) {
status = f_fss_nest_resize(depth + 2, found);
- if (F_status_is_error(status)) break;
}
if (found->depth[depth].used >= found->depth[depth].size) {
- status = f_fss_items_increase(state.step_small, &found->depth[depth]);
- if (F_status_is_error(status)) break;
+ if (F_status_is_error_not(status)) {
+ status = f_fss_items_increase(state.step_small, &found->depth[depth]);
+ }
}
position = found->depth[depth].used;
if (found->depth[depth].array[position].content.size != 1) {
- status = f_string_ranges_resize(1, &found->depth[depth].array[position].content);
- if (F_status_is_error(status)) break;
+ if (F_status_is_error_not(status)) {
+ status = f_string_ranges_resize(1, &found->depth[depth].array[position].content);
+ }
}
+ if (F_status_is_error(status)) break;
+
if (depth) {
found->depth[depth].array[position].parent = found->depth[depth - 1].used;
found->used = depth + 1;
}
- if (graph_first == 0x2) {
+ if (is_state & 0x2) {
status = f_array_lengths_increase(state.step_small, delimits);
if (F_status_is_error(status)) break;
}
newline_last = range->start;
- line_start = range->start + 1;
- graph_first = 0x1;
+ line_start = newline_last + 1;
+ is_state = 0x1;
if (!depth) {
status = f_utf_buffer_increment(buffer, range, 1);
}
if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
- if (graph_first == 0x2) {
+ if (is_state & 0x2) {
status = f_array_lengths_increase(state.step_small, delimits);
if (F_status_is_error(status)) break;
}
newline_last = range->start;
- line_start = range->start + 1;
- graph_first = 0x1;
+ line_start = newline_last + 1;
+ is_state = 0x1;
break;
}
if (F_status_is_error(status)) break;
} // while
- if (F_status_is_error(status)) break;
-
- if (depth) {
- private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_end_not_nest_eos, F_end_not_nest_stop)
- }
- else {
- private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop)
- }
+ if (F_status_is_error(status) || range->start >= buffer.used || range->start > range->stop) break;
}
}
- else if (buffer.string[range->start] == f_fss_comment_s.string[0] && (graph_first == 0x1 || graph_first == 0x2)) {
+ else if (buffer.string[range->start] == f_fss_comment_s.string[0] && (is_state & 0x1)) {
// The newline_last is initialized to the range->start, which may not actually be a new line.
position = (buffer.string[newline_last] == f_string_eol_s.string[0]) ? newline_last + 1 : newline_last;
--range->start;
}
else {
- if (graph_first == 0x2) {
+ if (is_state & 0x2) {
status = f_array_lengths_increase(state.step_small, delimits);
if (F_status_is_error(status)) break;
}
newline_last = range->start;
- graph_first = 0x1;
+ line_start = newline_last + 1;
+ is_state = 0x1;
}
status = f_string_ranges_increase(state.step_small, comments);
comments->array[comments->used].start = position;
comments->array[comments->used++].stop = range->start++;
-
- continue;
}
else if (buffer.string[range->start] != f_fss_eol_s.string[0]) {
position_previous = range->start;
- if (graph_first == 0x1) {
+ if (is_state & 0x1) {
status = f_fss_is_space(state, buffer, *range);
- if (F_status_is_error(status)) break;
if (status == F_false) {
- graph_first = 0x0;
+ is_state &= ~0x1;
}
}
- status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(status)) break;
-
- if (range->start >= buffer.used || range->start > range->stop) break;
+ if (F_status_is_error_not(status)) {
+ status = f_utf_buffer_increment(buffer, range, 1);
+ }
- continue;
+ if (F_status_is_error(status)) break;
}
-
- position_previous = range->start;
-
- status = f_utf_buffer_increment(buffer, range, 1);
- if (F_status_is_error(status)) break;
} // while
f_array_lengths_resize(0, &positions_start);