Documentation
¶
Index ¶
- Constants
- func IsLineTerminator(c rune) bool
- type Pos
- type Range
- type Runes
- type Source
- func (s *Source) AdvanceIf(c rune) bool
- func (s *Source) Ahead2nd() rune
- func (s *Source) AheadIsCh(c rune) bool
- func (s *Source) AheadIsChOr(c1 rune, c2 rune) bool
- func (s *Source) AheadIsChs2(c1 rune, c2 rune) bool
- func (s *Source) AheadIsEOF() bool
- func (s *Source) DiscardState()
- func (s *Source) Len() int
- func (s *Source) LineCol(rng Range) (from, to Pos)
- func (s *Source) MetLineTerm() bool
- func (s *Source) NewOpenRange() Range
- func (s *Source) Ofst() uint32
- func (s *Source) OfstLineCol(ofst uint32) (pos Pos)
- func (s *Source) OpenRange(rng *Range)
- func (s *Source) Peek() rune
- func (s *Source) PopState()
- func (s *Source) Pos() uint32
- func (s *Source) PushState()
- func (s *Source) Read() rune
- func (s *Source) RngText(rng Range) string
- func (s *Source) SkipSpace() *Source
- func (s *Source) Text(start, end uint32) string
- type SourceState
Constants ¶
View Source
const ( // used to unify `\r`, `\r\n` to `\n`, despite other line-terminators in unicode EOL = rune('\n') EOF = rune(-1) )
Variables ¶
This section is empty.
Functions ¶
func IsLineTerminator ¶
Types ¶
type Source ¶
type Source struct { Path string // contains filtered or unexported fields }
process the utf8 encoded source file
the return value of below methods which return rune will be `utf8.RuneError` if the given position is not well encoded in utf8
`\r`, `\r\n` will be unified to `\n` which has an alias `span.EOL`
func (*Source) AheadIsEOF ¶
func (*Source) DiscardState ¶
func (s *Source) DiscardState()
pop the state-stack and discard the popped state
func (*Source) LineCol ¶ added in v0.0.10
line-column is useful for developer can figure out where the errors occur, however it will pressure memory footprint if we directly store them in Node, this method is inspired by `acorn` to defer restore the line-column by the given source range
func (*Source) MetLineTerm ¶
func (*Source) NewOpenRange ¶
func (*Source) OfstLineCol ¶ added in v0.0.10
func (*Source) PopState ¶
func (s *Source) PopState()
pop the state-stack and apply the popped state
type SourceState ¶
type SourceState struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.