lexer

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ESCAPE     = rune('\\')
	DELIM      = rune('$')
	NEWLINE    = rune('\n')
	SEMICOLON  = rune(';')
	EQUALS     = rune('=')
	QUOT       = rune('"')
	COMMA      = rune(',')
	SPACE      = rune(' ')
	HTAB       = rune('\t')
	LPAREN     = rune('(')
	RPAREN     = rune(')')
	DOT        = rune('.')
	UNDERSCORE = rune('_')
	DASH       = rune('-')
	TRUTHY     = "truthy"
	PRESENT    = "present"
)
View Source
const DEBUG = false

Variables

This section is empty.

Functions

This section is empty.

Types

type AST

type AST []Node

func Tokenize

func Tokenize(data string) (ast AST, err error)

Tokenize takes all runes from the provided string, feeds an internal Tokenizer instance, and returns the result by calling Finish

func (AST) IsPureLiteral

func (a AST) IsPureLiteral() bool

IsPureLiteral determines whether the AST only contains literals, meaning it contains no templating to be processed

type Conditional

type Conditional struct {
	Property string
	Helper   string
	Then     AST
	ElseIf   []*Conditional
	Else     AST
	// contains filtered or unexported fields
}

func (Conditional) Kind

func (c Conditional) Kind() Kind

func (Conditional) Parent

func (c Conditional) Parent() Node

type InvalidConditionalExpressionErr

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

func (InvalidConditionalExpressionErr) Error

type Kind

type Kind int
const (
	KindInvalid Kind = iota
	KindLiteral
	KindTemplate
	KindConditional
)

type Literal

type Literal struct {
	String string
	// contains filtered or unexported fields
}

func (Literal) Kind

func (l Literal) Kind() Kind

func (Literal) Parent

func (l Literal) Parent() Node

type Node

type Node interface {
	Kind() Kind
	Parent() Node
}

type Template

type Template struct {
	Name    string
	Options map[string]string
	// contains filtered or unexported fields
}

func (Template) Kind

func (t Template) Kind() Kind

func (Template) Parent

func (t Template) Parent() Node

type Tokenizer

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

func NewTokenizer

func NewTokenizer() *Tokenizer

NewTokenizer prepares a new Tokenizer

func (*Tokenizer) Feed

func (t *Tokenizer) Feed(chr rune) error

Feed feeds a given rune to the parser

func (*Tokenizer) Finish

func (t *Tokenizer) Finish() (AST, error)

Finish completes the parsing process and returns the generated AST, or an error

type UnexpectedEOFErr

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

func (UnexpectedEOFErr) Error

func (u UnexpectedEOFErr) Error() string

type UnexpectedLinebreakErr

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

func (UnexpectedLinebreakErr) Error

func (u UnexpectedLinebreakErr) Error() string

type UnexpectedTokenErr

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

func (UnexpectedTokenErr) Error

func (u UnexpectedTokenErr) Error() string

type UnsupportedConditionalHelperErr

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

func (UnsupportedConditionalHelperErr) Error

Jump to

Keyboard shortcuts

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