diff --git a/OnDemand-logic.md b/OnDemand-logic.md new file mode 100644 index 0000000..e28c549 --- /dev/null +++ b/OnDemand-logic.md @@ -0,0 +1,26 @@ +## object + +When searching for a key, if the key is found then we are left pointing at the colon, and we are one depth below the object itself. + +If the key is not found then we are left pointing at the either the start of the object or else a comma. + + +## depth + + +The depth is set in the following functions: +1. reenter_child +2. abandon (sets the depth to 0) + +The depth is incremented in these instances: +1. when encountering a colon in field_value() +2. in started_array() when it is not an empty array. Note that started_object does not similarly increment the depth. +3. in has_next_element() when encountering a comma. Note that a comma in an object does not change the depth (see has_next_field()) + +The depth is decremented in these instances: +1. When an object is closed by } (in started_object(), in has_next_field()) +2. When an array is closed by ] (in started_array(), in has_next_element()) +3. In advance_start(), in advance_root_scalar(), in advance_non_root_scalar() + + +Skip child will, as a first step, decrement the depth when encountering },] or an atom (anything that does not start with [,{,:, or the comma), and then scan the structural elements, incrementing on [,{ and decrementing on },].