lexers

package
v0.0.0-...-e95280a Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	ToLexer(script string) (Lexer, error)
}

Adapter represents the lexer adapter

type AdapterBuilder

type AdapterBuilder interface {
	Create() AdapterBuilder
	WithName(name string) AdapterBuilder
	WithRoot(root string) AdapterBuilder
	WithFileFetcher(fileFetcher grammar.FileFetcher) AdapterBuilder
	WithGrammarFilePath(grammarFilePath string) AdapterBuilder
	WithGrammarRetrieverCriteria(grammarRetrieverCriteria grammar.RetrieverCriteria) AdapterBuilder
	WithGrammar(grammar grammar.Grammar) AdapterBuilder
	WithEvents(events []Event) AdapterBuilder
	Now() (Adapter, error)
}

AdapterBuilder represents an adapter builder

func NewAdapterBuilder

func NewAdapterBuilder() AdapterBuilder

NewAdapterBuilder creates a new lexer adapter builder

type Builder

type Builder interface {
	Create() Builder
	WithGrammar(grammar grammar.Grammar) Builder
	WithNodeTree(tree NodeTree) Builder
	WithScript(script string) Builder
	WithEvents(evts []Event) Builder
	Now() (Lexer, error)
}

Builder represents a lexer builder

func NewBuilder

func NewBuilder() Builder

NewBuilder creates a new lexer builder

type Element

type Element interface {
	Rule() grammar.Rule
	Code() string
}

Element represents an element

type ElementBuilder

type ElementBuilder interface {
	Create() ElementBuilder
	WithRule(rule grammar.Rule) ElementBuilder
	WithCode(code string) ElementBuilder
	Now() (Element, error)
}

ElementBuilder represents an element builder

type Event

type Event interface {
	Token() string
	Fn() EventFn
}

Event represents a lexer event

type EventBuilder

type EventBuilder interface {
	Create() EventBuilder
	WithToken(token string) EventBuilder
	WithFn(fn EventFn) EventBuilder
	Now() (Event, error)
}

EventBuilder represents an event builder

func NewEventBuilder

func NewEventBuilder() EventBuilder

NewEventBuilder creates a new EventBuilder instance

type EventFn

type EventFn func(from int, to int, script []rune, rule grammar.Rule) []rune

EventFn represents the event func

type Lexer

type Lexer interface {
	Grammar() grammar.Grammar
	Tree() NodeTree
}

Lexer represents a lexer

type Node

type Node interface {
	HasRecursiveName() bool
	RecursiveName() string
	HasTrees() bool
	Trees() []NodeTree
	HasElements() bool
	Elements() []Element
	Code() string
	CodeFromName(name string) string
	CodesFromName(name string) []string
}

Node represents a node

type NodeBuilder

type NodeBuilder interface {
	Create() NodeBuilder
	WithTrees(trees []NodeTree) NodeBuilder
	WithElements(elements []Element) NodeBuilder
	WithRecursiveName(recursiveName string) NodeBuilder
	Now() (Node, error)
}

NodeBuilder represents a node builder

type NodeTree

type NodeTree interface {
	Grammar() grammar.Grammar
	Token() grammar.Token
	Nodes() []Node
	HasSubNodeTrees() bool
	Code() string
	CodeFromName(name string) string
	CodesFromName(name string) []string
	BestMatchFromNames(names []string) (string, string)
	NextNodeTree() NodeTree
	NextNodeTrees() []NodeTree
	SubTreeFromName(name string) NodeTree
}

NodeTree represents a nodeTree

type NodeTreeAdapter

type NodeTreeAdapter interface {
	ToNodeTree(script string) (NodeTree, error)
}

NodeTreeAdapter represents a nodeTree adapter

type NodeTreeAdapterBuilder

type NodeTreeAdapterBuilder interface {
	Create() NodeTreeAdapterBuilder
	WithGrammar(grammar grammar.Grammar) NodeTreeAdapterBuilder
	Now() (NodeTreeAdapter, error)
}

NodeTreeAdapterBuilder represents a nodeTreeAdapter builder

type NodeTreeBuilder

type NodeTreeBuilder interface {
	Create() NodeTreeBuilder
	WithRuleTree(tree grammar.RuleTree) NodeTreeBuilder
	WithScript(script string) NodeTreeBuilder
	Now() (NodeTree, error)
}

NodeTreeBuilder represents a nodeTree builder

type ScriptApplication

type ScriptApplication interface {
	Execute(script string) (string, error)
}

ScriptApplication represents a script application

type ScriptApplicationBuilder

type ScriptApplicationBuilder interface {
	Create() ScriptApplicationBuilder
	WithGrammar(grammar grammar.Grammar) ScriptApplicationBuilder
	WithEvents(evts []Event) ScriptApplicationBuilder
	Now() (ScriptApplication, error)
}

ScriptApplicationBuilder represents a script application builder

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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