parsers

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The unknown
	ErrCodeUnknown = "UNKNOWN"

	// The internal error
	ErrCodeInternal = "INTERNAL"

	// The unexpected end.
	ErrCodeUnexpectedEnd = "UNEXPECTED_END"

	// The error near
	ErrCodeErrorNear = "ERROR_NEAR"

	// The error at
	ErrCodeErrorAt = "ERROR_AT"

	// The unexpected symbol
	ErrCodeUnexpectedSymbol = "UNEXPECTED_SYMBOL"

	// The mismatched brackets
	ErrCodeMismatchedBrackets = "MISTMATCHED_BRACKETS"

	// The missing variable
	ErrCodeMissingVariable = "MISSING_VARIABLE"

	// Not closed section
	ErrCodeNotClosedSection = "NOT_CLOSED_SECTION"

	// Unexpected section end
	ErrCodeUnexpectedSectionEnd = "UNEXPECTED_SECTION_END"
)

General syntax errors

View Source
const (
	TokenUnknown = iota
	TokenValue
	TokenVariable
	TokenEscapedVariable
	TokenSection
	TokenInvertedSection
	TokenSectionEnd
	TokenPartial
	TokenComment
)

Define types of mustache tokens

View Source
const (
	StateValue = iota
	StateOperator1
	StateOperator2
	StateVariable
	StateComment
	StateClosure
)

Define states in mustache lexical analysis

Variables

This section is empty.

Functions

This section is empty.

Types

type MustacheParser

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

Implements an mustache parser class.

func NewMustacheParser

func NewMustacheParser() *MustacheParser

func (*MustacheParser) Clear

func (c *MustacheParser) Clear()

Clears parsing results.

func (*MustacheParser) InitialTokens

func (c *MustacheParser) InitialTokens() []*MustacheToken

Gets the list of original mustache tokens.

func (*MustacheParser) OriginalTokens

func (c *MustacheParser) OriginalTokens() []*tokenizers.Token

Gets the list of original tokens

func (*MustacheParser) ParseString

func (c *MustacheParser) ParseString(mustache string) error

Sets a new mustache string and parses it into internal byte code. Parameters:

mustache: A new mustache string.

func (*MustacheParser) ParseTokens

func (c *MustacheParser) ParseTokens(tokens []*tokenizers.Token) error

func (*MustacheParser) ResultTokens

func (c *MustacheParser) ResultTokens() []*MustacheToken

Sets the list of parsed mustache tokens.

func (*MustacheParser) SetOriginalTokens

func (c *MustacheParser) SetOriginalTokens(value []*tokenizers.Token) error

Sets the list of original tokens

func (*MustacheParser) SetTemplate

func (c *MustacheParser) SetTemplate(value string) error

Sets the mustache template.

func (*MustacheParser) Template

func (c *MustacheParser) Template() string

Gets the mustache template.

func (*MustacheParser) VariableNames

func (c *MustacheParser) VariableNames() []string

Gets the list of found variable names.

type MustacheToken

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

Defines an mustache token holder.

func NewMustacheToken

func NewMustacheToken(typ int, value string, line int, column int) *MustacheToken

Creates an instance of a mustache token

Parameters:

  • typ: The type of this token.
  • value: The value of this token.
  • line: The line number where the token is.
  • column: The column number where the token is.

func (*MustacheToken) Column

func (c *MustacheToken) Column() int

The column number where the token is.

func (*MustacheToken) Line

func (c *MustacheToken) Line() int

The line number where the token is.

func (*MustacheToken) SetTokens

func (c *MustacheToken) SetTokens(tokens []*MustacheToken)

Sets a list of subtokens is this token a section.

func (*MustacheToken) Tokens

func (c *MustacheToken) Tokens() []*MustacheToken

Gets a list of subtokens is this token a section.

func (*MustacheToken) Type

func (c *MustacheToken) Type() int

The type of this token.

func (*MustacheToken) Value

func (c *MustacheToken) Value() string

The value of this token.

Jump to

Keyboard shortcuts

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