69 bool AtEnd()
const {
return pos_ >= text_.size(); }
72 std::size_t
Offset()
const {
return pos_; }
102 [[noreturn]]
void Fail(std::string
const& what)
const;
105 std::string
const& text_;
A read position over one canonical-encoding text, with the small lexical helpers the grammar needs (l...
Definition canonical_decoding.hpp:63
DecodingCursor(std::string const &text)
Start reading text from its first byte.
Definition canonical_decoding.hpp:66
std::string ReadNetstring()
Read a netstring name: <byte-length>:<bytes>.
bool TryConsume(char c)
Consume c if it is next; report whether it was.
void Expect(std::string_view lit)
Consume exactly the literal lit, or throw.
void SkipWhitespace()
Skip any run of spaces and newlines.
bool AtEnd() const
Whether every byte has been consumed.
Definition canonical_decoding.hpp:69
void Fail(std::string const &what) const
Throw std::runtime_error describing what at the current position.
void Expect(char c)
Consume exactly the character c, or throw.
std::size_t Offset() const
The byte offset of the next unread character.
Definition canonical_decoding.hpp:72
char Peek() const
The next unread character (throws at end of text).
unsigned long long ReadUnsigned()
Read a non-negative decimal integer.
long long ReadInt()
Read a decimal integer with an optional sign.
std::string ReadWord()
Read a maximal run of characters that are not whitespace or a parenthesis.
Definition canonical.hpp:56
std::shared_ptr< Node > DecodeCanonical(DecodingCursor &cursor, DecodingContext &ctx)
Decode one node (and everything under it) from the cursor's position.
std::shared_ptr< Node > DecodeCanonicalTree(std::string const &text)
Decode a whole tree from its canonical encoding text (fresh context).
Definition algorithm_builder.hpp:36
Defines the abstract Node base class.
The back-reference table of one decoding pass: the nodes in first-encounter order,...
Definition canonical_decoding.hpp:118
std::vector< std::shared_ptr< Node > > by_index
The node numbered by each index, in encounter order.
Definition canonical_decoding.hpp:120