rule

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CharacterToken = "character"
	ParameterToken = "parameter"
	EOFToken       = "eof"
)

Variables

View Source
var Options = []rulebot.Option{
	rulebot.RegisterRuleset(New(rules)),
}

Functions

func New

func New(rules []Rule) *regexRuleset

func SyntaxCheck

func SyntaxCheck(define string, actual []*Token) (bool, error)

Types

type Command

type Command struct {
	Main string
	Sub  string
	Args []string
}

type Lexer

type Lexer struct {
	Text        []rune
	Pos         int
	CurrentChar rune
	LineNo      int
	Column      int
}

func NewLexer

func NewLexer(text []rune) *Lexer

func (*Lexer) Advance

func (l *Lexer) Advance()

func (*Lexer) Character

func (l *Lexer) Character() (*Token, error)

func (*Lexer) GetNextToken

func (l *Lexer) GetNextToken() (*Token, error)

func (*Lexer) Peek

func (l *Lexer) Peek() rune

func (*Lexer) SkipWhitespace

func (l *Lexer) SkipWhitespace()

type Rule

type Rule struct {
	Define string
	Help   string
	Parse  func(context.Context, rulebot.IComponent, []*Token) []string
}

type Syntax

type Syntax struct {
	Text        []rune
	Pos         int
	CurrentChar rune
	LineNo      int
	Column      int
}

func NewSyntax

func NewSyntax(text []rune) *Syntax

func (*Syntax) Advance

func (l *Syntax) Advance()

func (*Syntax) Character

func (l *Syntax) Character() (*Token, error)

func (*Syntax) GetNextToken

func (l *Syntax) GetNextToken() (*Token, error)

func (*Syntax) Parameter

func (l *Syntax) Parameter() (*Token, error)

func (*Syntax) Peek

func (l *Syntax) Peek() rune

func (*Syntax) SkipWhitespace

func (l *Syntax) SkipWhitespace()

type Token

type Token struct {
	Type   string
	Value  string
	LineNo int
	Column int
}

func ParseCommand

func ParseCommand(in string) ([]*Token, error)

Jump to

Keyboard shortcuts

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