1 #ifndef _C4_YML_PARSER_STATE_HPP_
2 #define _C4_YML_PARSER_STATE_HPP_
4 #ifndef _C4_YML_COMMON_HPP_
42 csubstr _parser_flags_to_str(substr buf,
ParserFlag_t flags);
60 RYML_ASSERT(offset <= buf.len);
63 while(e < buf.len && (buf.str[e] !=
'\n' && buf.str[e] !=
'\r'))
65 RYML_ASSERT(e >= offset);
66 const substr stripped_ = buf.range(offset, e);
68 if(e < buf.len && buf.str[e] ==
'\r')
70 if(e < buf.len && buf.str[e] ==
'\n')
72 const substr full_ = buf.range(offset, e);
73 reset(full_, stripped_);
76 void reset(substr full_, substr stripped_)
96 RYML_ASSERT(
rem.str >=
full.str);
97 size_t col =
static_cast<size_t>(
rem.str -
full.str);
116 RYML_ASSERT(s.str >=
full.str);
117 RYML_ASSERT(
full.is_super(s));
118 size_t col =
static_cast<size_t>(s.str -
full.str);
122 static_assert(std::is_standard_layout<LineContents>::value,
"LineContents not standard");
199 static_assert(std::is_standard_layout<ParserState>::value,
"ParserState not standard");
Common utilities and infrastructure used by ryml.
#define RYML_NOEXCEPT
Conditionally expands to noexcept when RYML_USE_ASSERT is 0 and is empty otherwise.
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
@ BLCK
reading in block mode
@ RSET
the (implicit) map being read is a !!set.
@ RNXT
read next val or keyval
@ FLOW
reading is inside explicit flow chars: [] or {}
@ 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
@ 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
int ParserFlag_t
data type for ParserState_e
Helper to control the line contents while parsing a buffer.
substr rem
the stripped line remainder; initially starts at the first non-space character
substr full
the full line, including newlines on the right
void reset(substr full_, substr stripped_)
size_t current_col(csubstr s) const RYML_NOEXCEPT
void reset_with_next_line(substr buf, size_t offset)
substr stripped
the stripped line, excluding newlines on the right
size_t indentation
the number of spaces on the beginning of the line
size_t current_col() const RYML_NOEXCEPT
size_t offset
number of bytes from the beginning of the source buffer
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)