1 #ifndef _C4_YML_PARSER_STATE_HPP_
2 #define _C4_YML_PARSER_STATE_HPP_
4 #ifndef _C4_YML_ERROR_HPP_
45 csubstr _parser_flags_to_str(substr buf,
ParserFlag_t flags);
71 _RYML_ASSERT_BASIC(start <= buf.len);
74 while((end < buf.len) && (buf.str[end] !=
'\n'))
78 _RYML_ASSERT_BASIC(buf[end] ==
'\n');
79 full = buf.range(start, end + 1);
80 rem = buf.range(start, end);
87 size_t pos =
rem.last_not_of(
'\r');
88 rem.len = (pos !=
npos) ? pos + 1 : 0;
90 _RYML_ASSERT_BASIC(
rem.find(
'\r') ==
npos);
97 _RYML_ASSERT_BASIC(
rem.str >=
full.str);
98 return static_cast<size_t>(
rem.str -
full.str);
103 _RYML_ASSERT_BASIC(s.str >=
full.str);
104 _RYML_ASSERT_BASIC(s.str <=
rem.end());
105 return static_cast<size_t>(s.str -
full.str);
108 static_assert(std::is_standard_layout<LineContents>::value,
"LineContents not standard");
185 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.
@ RNXT
read next val or keyval
@ RUNK
reading unknown state (when starting): must determine whether scalar, map or seq
@ RKEY
reading a scalar as key
@ 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
@ RVAL
reading a scalar as val
@ 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. TODO this should not be a member of this object....
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 at_line_beginning() const noexcept
void start_parse(const char *file, id_type node_id_)
bool indentation_lt() 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)