Documentation
¶
Overview ¶
Package strparse provides facilities for parsing strings, intended for use in tests and debug input.
Index ¶
- type Parser
- func (p *Parser) BlobFileID() base.BlobFileID
- func (p *Parser) DiskFileNum() base.DiskFileNum
- func (p *Parser) Done() bool
- func (p *Parser) Errf(format string, args ...any)
- func (p *Parser) Expect(tokens ...string)
- func (p *Parser) FileNum() base.FileNum
- func (p *Parser) Int() int
- func (p *Parser) InternalKey() base.InternalKey
- func (p *Parser) Level() int
- func (p *Parser) Next() string
- func (p *Parser) Peek() string
- func (p *Parser) Remaining() string
- func (p *Parser) SeqNum() base.SeqNum
- func (p *Parser) TryLevel() (level int, ok bool)
- func (p *Parser) Uint32() uint32
- func (p *Parser) Uint64() uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is a helper used to implement parsing of strings, like manifest.ParseFileMetadataDebug.
It takes a string and splits it into tokens. Tokens are separated by whitespace; in addition user-specified separators are also always separate tokens. For example, when passed the separators `:-[]();` the string `000001:[a - b]` results in tokens `000001`, `:`, `[`, `a`, `-`, `b`, `]`, .
All Parser methods throw panics instead of returning errors. The code that uses a Parser can recover them and convert them to errors.
func MakeParser ¶
MakeParser constructs a new Parser that converts any instance of the runes contained in [separators] into separate tokens, and consumes the provided input string.
func (*Parser) BlobFileID ¶
func (p *Parser) BlobFileID() base.BlobFileID
BlobFileID parses the next token as a BlobFileID.
func (*Parser) DiskFileNum ¶
func (p *Parser) DiskFileNum() base.DiskFileNum
DiskFileNum parses the next token as a DiskFileNum.
func (*Parser) Errf ¶
Errf panics with an error which includes the original string and the last token.
func (*Parser) Expect ¶
Expect consumes the next tokens, verifying that they exactly match the arguments.
func (*Parser) InternalKey ¶
func (p *Parser) InternalKey() base.InternalKey
InternalKey parses the next token as an internal key.
func (*Parser) Peek ¶
Peek returns the next token, without consuming the token. Returns "" if there are no more tokens.