1 #ifndef _C4_YML_PARSER_STATE_HPP_
2 #define _C4_YML_PARSER_STATE_HPP_
4 #ifndef _C4_YML_ERROR_HPP_
68 _RYML_ASSERT_BASIC(start <= buf.len);
71 while((end < buf.len) && (buf.str[end] !=
'\n'))
75 _RYML_ASSERT_BASIC(buf[end] ==
'\n');
76 full = buf.range(start, end + 1);
77 rem = buf.range(start, end);
84 size_t pos =
rem.last_not_of(
'\r');
85 rem.len = (pos !=
npos) ? pos + 1 : 0;
87 _RYML_ASSERT_BASIC(
rem.find(
'\r') ==
npos);
94 _RYML_ASSERT_BASIC(
rem.str >=
full.str);
95 return static_cast<size_t>(
rem.str -
full.str);
100 _RYML_ASSERT_BASIC(s.str >=
full.str);
101 _RYML_ASSERT_BASIC(s.str <=
rem.end());
102 return static_cast<size_t>(s.str -
full.str);
105 static_assert(std::is_standard_layout<LineContents>::value,
"LineContents not standard");
214 static_assert(std::is_standard_layout<ParserState>::value,
"ParserState not standard");
#define RYML_NOEXCEPT
Conditionally expands to noexcept when RYML_USE_ASSERT is 0 and is empty otherwise.
Error utilities used by ryml.
csubstr to_csubstr(substr s) noexcept
neutral version for use in generic code
RYML_ID_TYPE id_type
The type of a node id in the YAML tree; to override the default type, define the macro RYML_ID_TYPE t...
@ npos
a null string position
ParserState_e
Enumeration of the state flags for the parser.
@ RTOP
reading at top level
@ RSET
the (implicit) map being read is a !!set.
@ RUNK
reading unknown state (when starting): must determine whether scalar, map or seq
@ RKCL
reading the key colon (ie the : after the key in the map)
@ NDOC
no document mode. a document has ended and another has not started yet.
@ QSCL
stored scalar was quoted
@ RBLCK
reading in block mode
@ USTY
reading in unknown style mode - must determine FLOW or BLCK reading an implicit map nested in an expl...
@ QMRK
reading an explicit key (? key)
@ SSCL
there's a stored scalar
@ RFLOW
reading is inside explicit flow chars: [] or {}
int ParserFlag_t
data type for ParserState_e
(Undefined by default) Use shorter error message from checks/asserts: do not show the check condition...
Helper to control the line contents while parsing a buffer.
substr rem
current line remainder, without newline characters
substr full
full line, including newline characters \n and \r
void reset_with_next_line(substr buf, size_t start) RYML_NOEXCEPT
size_t num_cols
number of columns in the line, excluding newline characters (ie the initial size of rem)
LineContents() RYML_NOEXCEPT=default
size_t current_col(csubstr s) const RYML_NOEXCEPT
size_t indentation
number of spaces on the beginning of the line.
size_t current_col() const RYML_NOEXCEPT
holds a source or yaml file position, for example when an error is detected; See also location_format...
size_t offset
number of bytes from the beginning of the source buffer
csubstr name
name of the file
bool indentation_eq_extra() const noexcept
bool at_line_beginning() const noexcept
void start_parse(const char *file, id_type node_id_)
bool indentation_lt() const noexcept
bool indentation_gt_extra() const noexcept
bool indentation_ge_extra() const noexcept
bool indentation_lt_extra() const noexcept
bool at_first_token() const noexcept
LineContents line_contents
bool indentation_eq() const noexcept
size_t indref
the reference indentation in the current block scope
id_type node_id
don't hold a pointer to the node as it will be relocated during tree resizes
bool indentation_ge() const noexcept
bool indentation_gt() const noexcept
void reset_before_pop(ParserState const &to_pop)