scanner

package
v0.0.0-...-d40fe38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2016 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasChar

func HasChar(r rune, accept string) bool

func IsAlphaNumeric

func IsAlphaNumeric(r rune) bool

isAlphaNumeric reports whether r is an alphabetic, digit, or underscore.

func IsNumber

func IsNumber(r rune) bool

func IsQoute

func IsQoute(r rune) bool

func IsSpace

func IsSpace(r rune) bool

isSpace reports whether r is a space character.

Types

type Pos

type Pos int

Pos represents a byte position in the original input text from which this template was parsed.

func (Pos) Position

func (p Pos) Position() Pos

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner, Iterates through a string.

func NewScanner

func NewScanner(template string) *Scanner

NewScanner Creates a New Scanner pointer.

func (*Scanner) Accept

func (this *Scanner) Accept(valid string) bool

accept consumes the next rune if it's from the valid set.

func (*Scanner) AcceptNewLine

func (this *Scanner) AcceptNewLine() bool

accept consumes the next rune if it's from the valid set.

func (*Scanner) AcceptRun

func (this *Scanner) AcceptRun(valid string) (found int)

acceptRun consumes a run of runes from the valid set.

func (*Scanner) Backup

func (this *Scanner) Backup()

Backup steps back one rune. Can only be called once per call of next.

func (*Scanner) Commit

func (this *Scanner) Commit() string

Token return the current selected text and move the start position to the current position

func (*Scanner) Ignore

func (this *Scanner) Ignore()

Ignore skips over the pending input before this point.

func (*Scanner) IsEOF

func (this *Scanner) IsEOF() bool

IsEOF check if the end of the current string has been reached.

func (*Scanner) IsNewLine

func (this *Scanner) IsNewLine() bool

accept consumes the next rune if it's from the valid set.

func (*Scanner) LineNumber

func (this *Scanner) LineNumber() int

lineNumber reports which line we're on, based on the position of the previous item returned by nextItem. Doing it this way means we don't have to worry about peek double counting.

func (*Scanner) LoadState

func (this *Scanner) LoadState(state ScannerState)

func (*Scanner) MoveStart

func (this *Scanner) MoveStart(pos int)

func (*Scanner) Next

func (this *Scanner) Next() rune

Next returns the next rune in the input.

func (*Scanner) Peek

func (this *Scanner) Peek() rune

Peek returns but does not consume the next rune in the input.

func (*Scanner) Position

func (this *Scanner) Position() int

func (*Scanner) Prefix

func (this *Scanner) Prefix(pre string) bool

Prefix Check if content starts with same string. Does not Commit

func (*Scanner) Rollback

func (this *Scanner) Rollback()

Rollback move the curr pos back to the start pos.

func (*Scanner) RunTo

func (this *Scanner) RunTo(valid string) rune

runTo consumes a run of runes until an item in the valid set is found.

func (*Scanner) SaveState

func (this *Scanner) SaveState() ScannerState

func (*Scanner) Scan

func (this *Scanner) Scan(valid func(r rune) bool) bool

func (*Scanner) ScanHtmlWord

func (this *Scanner) ScanHtmlWord() bool

Scans a word with special characters like "col-3"

func (*Scanner) ScanNumber

func (this *Scanner) ScanNumber() bool

func (*Scanner) ScanWord

func (this *Scanner) ScanWord() bool

scan upto to the end of a word, returns true if a word was scanned. a word must start with a letter or '_' and can contain numbers after the first character.

func (*Scanner) SetPosition

func (this *Scanner) SetPosition(pos int)

func (*Scanner) SetStartPosition

func (this *Scanner) SetStartPosition(pos int)

func (*Scanner) Size

func (this *Scanner) Size() int

func (*Scanner) Skip

func (this *Scanner) Skip()

func (*Scanner) SkipSpaces

func (this *Scanner) SkipSpaces()

func (*Scanner) SkipToNewLine

func (this *Scanner) SkipToNewLine()

func (*Scanner) StartPosition

func (this *Scanner) StartPosition() int

type ScannerState

type ScannerState struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL