Safe Haskell | None |
---|---|
Language | Haskell2010 |
Parser defintions
Defines parsers used by the I2P SAM protocol
Warning: This function is used internally by I2P
and using these functions directly is unsupported. The
interface of these functions might change at any time without
prior notice.
- doubleQuote :: Word8
- singleQuote :: Word8
- backslash :: Word8
- equals :: Word8
- quotedValue :: Parser ByteString
- unquotedValue :: Parser ByteString
- value :: Parser ByteString
- keyValue :: Parser Token
- key :: Parser Token
- token :: Parser Token
- tokens :: Parser [Token]
- line :: Parser Line
Documentation
Ascii offset representation of a double quote.
Ascii offset representation of a single quote.
quotedValue :: Parser ByteString Source
Parses a single- or double-quoted value, and returns all bytes within the value; the unescaping is beyond the scope of this function (since different unescaping mechanisms might be desired).
Looking at the SAMv3 code on github, it appears as if the protocol is kind hacked together at the moment: no character escaping is performed at all, and no formal tokens / AST is used.
So this function already goes way beyond what is required, but it cannot hurt to do so.
unquotedValue :: Parser ByteString Source
An unquoted value is "everything until a whitespace or newline is reached". This is pretty broad, but the SAM implementation in I2P just uses a strtok, and is quite hackish.
value :: Parser ByteString Source
Parses either a quoted value or an unquoted value
Parses a key, which, after studying the SAMv3 code, is anything until either a space has been reached, or an '=' is reached.