Documentation
¶
Overview ¶
Package input provides an abstraction for data to be read.
Index ¶
- Constants
- func IsEOLEOS(ch rune) bool
- func IsSpace(ch rune) bool
- type Input
- func (inp *Input) Accept(s string) bool
- func (inp *Input) EatEOL()
- func (inp *Input) IsSpace() bool
- func (inp *Input) Next() rune
- func (inp *Input) Peek() rune
- func (inp *Input) PeekN(n int) rune
- func (inp *Input) ScanEntity() (res string, success bool)
- func (inp *Input) ScanLineContent() []byte
- func (inp *Input) SetPos(pos int)
- func (inp *Input) SkipSpace()
- func (inp *Input) SkipToEOL()
Constants ¶
const EOS = rune(-1)
EOS = End of source
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Input ¶
type Input struct { // Read-only, will never change Src []byte // The source string // Read-only, will change Ch rune // current character Pos int // character position in src // contains filtered or unexported fields }
Input is an abstract input source
func (*Input) Accept ¶
Accept checks if the given string is a prefix of the text to be parsed. If successful, advance position and current character. String must only contain bytes < 128. If not successful, everything remains as it is.
func (*Input) IsSpace ¶
IsSpace returns true if current character is a whitespace.
func (*Input) Next ¶
Next reads the next rune into inp.Ch and returns it too.
func (*Input) Peek ¶
Peek returns the rune following the most recently read rune without advancing. If end-of-source was already found peek returns EOS.
func (*Input) PeekN ¶
PeekN returns the n-th rune after the most recently read rune without advancing. If end-of-source was already found peek returns EOS.
func (*Input) ScanEntity ¶
ScanEntity scans either a named or a numbered entity and returns it as a string.
For numbered entities (like { or ģ) html.UnescapeString returns sometimes other values as expected, if the number is not well-formed. This may happen because of some strange HTML parsing rules. But these do not apply to Zettelmarkup. Therefore, I parse the number here in the code.
func (*Input) ScanLineContent ¶
ScanLineContent reads the reaining input stream and interprets it as lines of text.