Skip to content

Commit 50792fa

Browse files
committed
wip
1 parent 45c6ae7 commit 50792fa

1 file changed

Lines changed: 40 additions & 41 deletions

File tree

src_extra/c4/yml/extra/event_handler_ints.hpp

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#ifndef _C4_YML_TAG_HPP_
2323
#include <c4/yml/tag.hpp>
2424
#endif
25-
#ifndef _C4_YML_DETAIL_PARSER_DBG_HPP_
26-
#include <c4/yml/detail/parser_dbg.hpp>
25+
#ifndef _C4_YML_DETAIL_DBGPRINT_HPP_
26+
#include <c4/yml/detail/dbgprint.hpp>
2727
#endif
2828
#endif
2929

@@ -62,11 +62,11 @@ typedef enum : DataType {
6262
SCLR = (1 << 8), ///< =VAL scalar
6363
ALIA = (1 << 9), ///< =ALI alias (reference)
6464
// Style flags
65-
PLAI = (1 << 10), ///< : (plain scalar)
66-
SQUO = (1 << 11), ///< ' (single-quoted scalar)
67-
DQUO = (1 << 12), ///< " (double-quoted scalar)
68-
LITL = (1 << 13), ///< | (block literal scalar)
69-
FOLD = (1 << 14), ///< > (block folded scalar)
65+
PLAI = (1 << 10), ///< plain scalar
66+
SQUO = (1 << 11), ///< single-quoted scalar (')
67+
DQUO = (1 << 12), ///< double-quoted scalar ("")
68+
LITL = (1 << 13), ///< block literal scalar (|)
69+
FOLD = (1 << 14), ///< block folded scalar (>)
7070
FLOW = (1 << 15), ///< flow container: [] for seqs or {} for maps
7171
BLCK = (1 << 16), ///< block container
7272
// Modifiers
@@ -75,21 +75,19 @@ typedef enum : DataType {
7575
// Structure flags
7676
KEY_ = (1 << 19), ///< as key
7777
VAL_ = (1 << 20), ///< as value
78-
EXPL = (1 << 21), ///< --- (with BDOC) or
79-
///< ... (with EDOC)
80-
/// special flag to enable look back in the event array. it
81-
/// signifies that the previous event has a string, meaning that
82-
/// the jump back to it event is 3 positions. without this flag it
83-
/// would be impossible to jump to the previous event
84-
PSTR = (1 << 22),
85-
// Utility flags
86-
LAST = PSTR,
87-
MASK = (LAST << 1) - 1, // mask
88-
/// with string: mask of all the events that encode a string
89-
/// following the event. in the event has a string. the next two
90-
/// integers will provide respectively the string's offset and
91-
/// length
92-
WSTR = SCLR|ALIA|ANCH|TAG_,
78+
EXPL = (1 << 21), ///< `---` (with BDOC) or
79+
///< `...` (with EDOC)
80+
PSTR = (1 << 22), ///< special flag to enable look back in the event array. it
81+
///< signifies that the previous event has a string, meaning that
82+
///< the jump back to it event is 3 positions. without this flag it
83+
///< would be impossible to jump to the previous event
84+
// Utility flags/masks
85+
LAST = PSTR, ///< the last flag defined above
86+
MASK = (LAST << 1) - 1, ///< a mask of all bits in this enumeration
87+
WSTR = SCLR|ALIA|ANCH|TAG_, ///< with string: mask of all the events that encode a string
88+
///< following the event. in the event has a string. the next two
89+
///< integers will provide respectively the string's offset and
90+
///< length. See also @ref PSTR.
9391
} EventFlags;
9492

9593
} // namespace ievt
@@ -175,23 +173,23 @@ struct EventHandlerIntsState : public c4::yml::ParserState
175173
* };
176174
* ```
177175
* Here is some further explanation of the buffer structure:
178-
* ```
179-
* source : [a, bb, ccc]
180-
* string offset "a" string offset "bb" string offset "ccc"
181-
* | string length "a" | string length "bb" | string length "ccc"
182-
* | | | | | |
183-
* event event event [ event "a" ... | | event "bb" ... | | event "ccc" ... | | event ] event event
184-
* | | | | | | | | | | | | | | |
185-
* +--------+-------+------------------+---------------+---+------+---------------------+---+------+---------------------+---+------+-------------+--------+-----|
186-
* value : BSTR BDOC VAL_|BSEQ|FLOW VAL_|SCLR|PLAI 1 1 VAL_|SCLR|PLAI|PSTR 4 2 VAL_|SCLR|PLAI|PSTR 8 3 ESEQ|PSTR EDOC ESTR (array)
187-
* event # : 0 1 2 3 . . 4 | . . 5 | . . 6 7 8 (event #)
188-
* index/pos: 0 1 2 3 4 5 6 | 7 8 9 | 10 11 12 13 14 (index/pos)
189-
* \ | | \ | | | \ | | |
190-
* has a string--+---+ has a string-+------+---+ has a string-+------+---+
191-
* | |
192-
* prev event has string prev event has string
193-
* (jump back 3 to get to it) (jump back 3 to get to it)
194-
* ```
176+
@verbatim
177+
source : [a, bb, ccc]
178+
string offset "a" string offset "bb" string offset "ccc"
179+
| string length "a" | string length "bb" | string length "ccc"
180+
| | | | | |
181+
event event event [ event "a" ... | | event "bb" ... | | event "ccc" ... | | event ] event event
182+
| | | | | | | | | | | | | | |
183+
+--------+-------+------------------+---------------+---+------+---------------------+---+------+---------------------+---+------+-------------+--------+-----|
184+
value : BSTR BDOC VAL_|BSEQ|FLOW VAL_|SCLR|PLAI 1 1 VAL_|SCLR|PLAI|PSTR 4 2 VAL_|SCLR|PLAI|PSTR 8 3 ESEQ|PSTR EDOC ESTR (array)
185+
event # : 0 1 2 3 . . 4 | . . 5 | . . 6 7 8 (event #)
186+
index/pos: 0 1 2 3 4 5 6 | 7 8 9 | 10 11 12 13 14 (index/pos)
187+
\ | | \ | | | \ | | |
188+
has a string--+---+ has a string-+------+---+ has a string-+------+---+
189+
| |
190+
prev event has string prev event has string
191+
(jump back 3 to get to it) (jump back 3 to get to it)
192+
@endverbatim
195193
*
196194
* Note that the buffer contains both events and strings encoded as
197195
* integer pairs. That is, events that have an associated string are
@@ -299,8 +297,9 @@ struct EventHandlerIntsState : public c4::yml::ParserState
299297
* The result of @ref estimate_events_ints_size() (click to see more
300298
* info) is generally an overprediction: it overpredicts for every
301299
* single case among the many hundreds of cases covered in the unit
302-
* tests. But conceivably it may underpredict in some instances not
303-
* found in the test suite. What to do then?
300+
* tests. This is deliberate, and aims at minimizing the chance for a
301+
* retry parse. But conceivably it may underpredict in some instances
302+
* not found in the test suite. What to do then?
304303
*
305304
* First, [open an issue](https://github.com/biojppm/rapidyaml/issues)
306305
* to allow the estimation to be improved! Second, there are two ways

0 commit comments

Comments
 (0)