lexer

package
v0.0.0-...-3d8df2e Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

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

Lexer generates a stream of Tokens from raw HAML text

func NewLexer

func NewLexer(data string) *Lexer

NewLexer creates a new Lexer for the specified string

func (*Lexer) Lex

func (l *Lexer) Lex()

Lex the raw HAML until EOF or an error

func (*Lexer) LexAll

func (l *Lexer) LexAll() (tokens []Token, err error)

LexAll characters until EOF or an error

func (*Lexer) Next

func (l *Lexer) Next() (t *Token, err error)

Next reads the next available Token

type Token

type Token struct {
	Kind    TokenKind
	Content string
	Line    int
	Col     int
	Error   error
}

Token is a lexer Token

func (Token) Type

func (t Token) Type() string

Type returns the name of the Kind of this Token

type TokenKind

type TokenKind int

TokenKind specifies the type of a Token

const (
	// NewLine are found at the end of each textual line
	NewLine TokenKind = iota
	// Indent contain all of the leading whitespace of a line
	Indent
	// Text contains all of the trailing text on a line
	Text
	// ID specifies the HTML tag ID for the current Div tag
	ID
	// Class specifies an HTML class for the current tag
	Class
	// Element specifies kind of tag for this line
	Element
	// AttrsStart specifies the beginning of an attribute list
	AttrsStart
	// AttrName is the name of an attribute
	AttrName
	// AttrAssign is the assignment operator for Name:Value pairs of attributes
	AttrAssign
	// AttrValue is the value assigned to an attribute, as a quoted string
	AttrValue
	// AttrSep is the list separator for attributes
	AttrSep
	// AttrsEnd marks the end of an attribute list
	AttrsEnd
	// Error is a special Token used to communicate errors to the Parser
	Error
)

Jump to

Keyboard shortcuts

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