Documentation ¶
Index ¶
- func ByteToInt(b byte) int
- func ByteToLower(b byte) byte
- func IsAStringChar(tokenType TokenType) bool
- func IsAtomChar(tokenType TokenType) bool
- func IsCTL(tokenType TokenType) bool
- func IsError(err error) bool
- func IsQuotedChar(tokenType TokenType) bool
- func IsQuotedSpecial(tokenType TokenType) bool
- func IsRespSpecial(tokenType TokenType) bool
- type Bytes
- type Error
- type Parser
- func (p *Parser) Advance() error
- func (p *Parser) Check(tokenType TokenType) bool
- func (p *Parser) CheckWith(f func(tokenType TokenType) bool) bool
- func (p *Parser) CollectBytesWhileMatches(tokenType TokenType) (Bytes, error)
- func (p *Parser) CollectBytesWhileMatchesWith(f func(tokenType TokenType) bool) (Bytes, error)
- func (p *Parser) CollectBytesWhileMatchesWithPrev(tokenType TokenType) (Bytes, error)
- func (p *Parser) CollectBytesWhileMatchesWithPrevWith(f func(tokenType TokenType) bool) (Bytes, error)
- func (p *Parser) Consume(tokenType TokenType, message string) error
- func (p *Parser) ConsumeBytes(chars ...byte) error
- func (p *Parser) ConsumeBytesFold(chars ...byte) error
- func (p *Parser) ConsumeNewLine() error
- func (p *Parser) ConsumeWith(f func(token TokenType) bool, message string) error
- func (p *Parser) CurrentToken() Token
- func (p *Parser) MakeError(err string) error
- func (p *Parser) MakeErrorAtOffset(err string, offset int) error
- func (p *Parser) Matches(tokenType TokenType) (bool, error)
- func (p *Parser) MatchesWith(f func(tokenType TokenType) bool) (bool, error)
- func (p *Parser) ParseAString() (String, error)
- func (p *Parser) ParseAtom() (string, error)
- func (p *Parser) ParseLiteral() ([]byte, error)
- func (p *Parser) ParseNumber() (int, error)
- func (p *Parser) ParseNumberN(n int) (int, error)
- func (p *Parser) ParseQuoted() (String, error)
- func (p *Parser) ParseString() (String, error)
- func (p *Parser) PreviousToken() Token
- func (p *Parser) ResetOffsetCounter()
- func (p *Parser) RestoreState(state ParserState)
- func (p *Parser) SaveState() ParserState
- func (p *Parser) TryParseString() (String, bool, error)
- type ParserState
- type Reader
- type Scanner
- type String
- type Token
- type TokenType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteToLower ¶
func IsAStringChar ¶
func IsAtomChar ¶
func IsQuotedChar ¶
func IsQuotedSpecial ¶
func IsRespSpecial ¶
Types ¶
type Bytes ¶
func (Bytes) IntoString ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser provide facilities to consumes tokens from a given scanner. Advance should be called at least once before any checks in order to initialize the previousToken.
func (*Parser) CollectBytesWhileMatches ¶
CollectBytesWhileMatches collects bytes from the token scanner while tokens match the given token type. This function DOES NOT INCLUDE the previous token consumed before this call.
func (*Parser) CollectBytesWhileMatchesWith ¶
CollectBytesWhileMatchesWith collects bytes from the token scanner while tokens match the given condition. This function DOES NOT INCLUDE the previous token consumed before this call.
func (*Parser) CollectBytesWhileMatchesWithPrev ¶
CollectBytesWhileMatchesWithPrev collects bytes from the token scanner while tokens match the given token type. This function INCLUDES the previous token consumed before this call.
func (*Parser) CollectBytesWhileMatchesWithPrevWith ¶
func (p *Parser) CollectBytesWhileMatchesWithPrevWith(f func(tokenType TokenType) bool) (Bytes, error)
CollectBytesWhileMatchesWithPrevWith collects bytes from the token scanner while tokens match the given condition. This function INCLUDES the previous token consumed before this call.
func (*Parser) Consume ¶
Consume will advance the scanner to the next token if the current token matches the given token. If current token does not match, an error with given message will be returned.
func (*Parser) ConsumeBytes ¶
ConsumeBytes will advance if the next token value matches the given sequence.
func (*Parser) ConsumeBytesFold ¶
ConsumeBytesFold behaves the same as ConsumeBytes, but case insensitive for characters.
func (*Parser) ConsumeNewLine ¶
ConsumeNewLine issues two Consume calls for the `CRLF` token sequence.
func (*Parser) ConsumeWith ¶
ConsumeWith will advance the scanner to the next token if the current token matches the given condition. If current token does not match, an error with given message will be returned.
func (*Parser) CurrentToken ¶
func (*Parser) Matches ¶
Matches will advance the scanner to the next token and return true if the current token matches the given tokenType.
func (*Parser) MatchesWith ¶
MatchesWith will advance the scanner to the next token and return true if the current token matches the given condition.
func (*Parser) ParseAString ¶
ParseAString parses an astring according to RFC3501.
func (*Parser) ParseLiteral ¶
ParseLiteral parses a literal as defined in RFC3501.
func (*Parser) ParseNumber ¶
ParseNumber parses a non decimal number without any signs.
func (*Parser) ParseNumberN ¶
ParseNumberN parses a non decimal with N digits.
func (*Parser) ParseQuoted ¶
ParseQuoted parses a quoted string.
func (*Parser) ParseString ¶
ParseString parses a string according to RFC3501.
func (*Parser) PreviousToken ¶
func (*Parser) ResetOffsetCounter ¶
func (p *Parser) ResetOffsetCounter()
ResetOffsetCounter resets the token offset back to 0.
func (*Parser) RestoreState ¶
func (p *Parser) RestoreState(state ParserState)
RestoreState restores the previous and current tokens from the given state. NOTE: If this is called without adjusting the scanner input to the location where these were recorded you can break your parsing.
func (*Parser) SaveState ¶
func (p *Parser) SaveState() ParserState
SaveState saves the current and previous token state so it can potentially be restored later with RestoreState.
type ParserState ¶
type ParserState struct {
// contains filtered or unexported fields
}
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
func NewScanner ¶
func NewScannerWithReader ¶
func (*Scanner) ConsumeBytes ¶
func (*Scanner) ConsumeUntilNewLine ¶
func (*Scanner) ResetOffsetCounter ¶
func (s *Scanner) ResetOffsetCounter()
type TokenType ¶
type TokenType int
const ( TokenTypeEOF TokenType = iota TokenTypeError TokenTypeSP TokenTypeExclamation TokenTypeDQuote TokenTypeHash TokenTypeDollar TokenTypePercent TokenTypeAmpersand TokenTypeSQuote TokenTypeLParen TokenTypeRParen TokenTypeAsterisk TokenTypePlus TokenTypeComma TokenTypeMinus TokenTypePeriod TokenTypeSlash TokenTypeSemicolon TokenTypeColon TokenTypeLess TokenTypeEqual TokenTypeGreater TokenTypeQuestion TokenTypeAt TokenTypeLBracket TokenTypeRBracket TokenTypeCaret TokenTypeUnderscore TokenTyeBacktick TokenTypeLCurly TokenTypePipe TokenTypeRCurly TokenTypeTilde TokenTypeBackslash TokenTypeDigit TokenTypeChar TokenTypeExtendedChar TokenTypeCR TokenTypeLF TokenTypeCTL TokenTypeTab TokenTypeDelete TokenTypeZero )