scanner

package
v0.0.0-...-ec9fd1c Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2012 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

The scanner package is responsible for parsing a YAML document and transforming it into a sequence of events. This corresponds to the parsing stage in the YAML 1.2 specification.

Index

Constants

View Source
const (
	AnyScalarStyle = iota
	PlainScalarStyle
	SingleQuotedScalarStyle
	DoubleQuotedScalarStyle
	LiteralScalarStyle
	FoldedScalarStyle
)

Scalar styles

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicToken

type BasicToken struct {
	Kind       token.Token
	Start, End token.Position
}

BasicToken holds the essential information for a Token.

func (BasicToken) GetEnd

func (t BasicToken) GetEnd() token.Position

func (BasicToken) GetKind

func (t BasicToken) GetKind() token.Token

func (BasicToken) GetStart

func (t BasicToken) GetStart() token.Position

func (BasicToken) String

func (t BasicToken) String() string

type Error

type Error struct {
	Err error
	Pos token.Position
}

Error is the error type returned by a Scanner. It provides the position of the error.

func (Error) Error

func (err Error) Error() string

type ScalarToken

type ScalarToken struct {
	ValueToken
	Style int
}

A ScalarToken holds a value and the style as it appeared in the YAML document.

type Scanner

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

A Scanner generates a sequence of lexical tokens from a reader containing YAML data.

func New

func New(r io.Reader) (s *Scanner)

New creates a new Scanner from a reader.

func (*Scanner) GetPosition

func (s *Scanner) GetPosition() token.Position

GetPosition returns the position of the first unread byte from the underlying reader.

This does not necessarily correspond to the starting position of the token that will be returned next by Scan, nor does it even correspond to the position in the reader (more bytes may have actually been read). The Scanner has to do some look-ahead to do its job.

func (*Scanner) Scan

func (s *Scanner) Scan() (result Token, err error)

Scan returns the next token in the stream. If the stream has already ended, then this method will return nil, nil.

type TagDirective

type TagDirective struct {
	BasicToken
	Handle string
	Prefix string
}

TagDirective stores a %TAG directive.

func (TagDirective) String

func (td TagDirective) String() string

type TagToken

type TagToken struct {
	BasicToken
	Handle string
	Suffix string
}

TagToken holds information for a token of TAG type (i.e. a tag property).

func (TagToken) String

func (t TagToken) String() string

type Token

type Token interface {
	GetKind() token.Token
	GetStart() token.Position
	GetEnd() token.Position
	String() string
}

Token holds data for a single lexical unit in a YAML document.

type ValueToken

type ValueToken struct {
	BasicToken
	Value string
}

ValueToken defines a token that holds a string value. It is used for anchors, aliases, and scalars.

func (ValueToken) String

func (t ValueToken) String() string

type VersionDirective

type VersionDirective struct {
	BasicToken
	Major, Minor int
}

VersionDirective stores a %YAML directive.

func (VersionDirective) String

func (vd VersionDirective) String() string

Jump to

Keyboard shortcuts

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