lexer

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const COLOR_BG = '_'
View Source
const COLOR_FG = '^'
View Source
const COMMENT = '!'
View Source
const CONTROL = '/'
View Source
const EOF rune = 0
View Source
const MEDIA = '@'
View Source
const TITLE = '#'

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

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

Lexer with an input, tokens and a state. Internally it tracks also a start pointer, a position pointer and the width of the current lexed item.

func BeginLexing

func BeginLexing(input string) *Lexer

BeginLexing returns a new Lexer with a given input, a start state and a buffered Token channel.

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

NextToken returns the next lexed Token in our channel. If there is none, it loops over doing nothing until we lexed a new Token.

type Token

type Token struct {
	Typ TokenType
	Val string
}

Token represents a TokenType and a Value.

func (Token) String

func (t Token) String() string

type TokenType

type TokenType int

TokenType describes all possible Tokens.

const (
	TOKEN_ERROR TokenType = iota
	TOKEN_EOF

	TOKEN_NEWSLIDE

	TOKEN_TEXT
	TOKEN_TITLE // #
	TOKEN_MEDIA // @

	TOKEN_COLOR_BG // _
	TOKEN_COLOR_FG // ^

	TOKEN_COMMENT // !
)

Jump to

Keyboard shortcuts

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