parser

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: MIT Imports: 6 Imported by: 0

README

chat-parser

to start fuzzing the lexer

$ go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
$ go-fuzz-build
$ go-fuzz

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLexer

func NewLexer(input string) lexer

func RunesFromStrings

func RunesFromStrings(s []string) (r [][]rune)

Types

type Emote

type Emote struct {
	Name      string
	Modifiers []string
	TokPos    int
	TokEnd    int
}

func (*Emote) End

func (e *Emote) End() int

func (*Emote) InsertModifier

func (e *Emote) InsertModifier(m string)

func (*Emote) Pos

func (e *Emote) Pos() int
type Link struct {
	URL    string
	TokPos int
	TokEnd int
}

func (*Link) End

func (l *Link) End() int

func (*Link) Pos

func (l *Link) Pos() int

type Nick

type Nick struct {
	Nick   string
	TokPos int
	TokEnd int
	Meta   interface{}
}

func (*Nick) End

func (n *Nick) End() int

func (*Nick) Pos

func (n *Nick) Pos() int

type NickIndex added in v1.0.3

type NickIndex struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewNickIndex added in v1.0.3

func NewNickIndex(values [][]rune) *NickIndex

func (*NickIndex) Contains added in v1.0.3

func (n *NickIndex) Contains(v []rune) bool

func (*NickIndex) Get added in v1.0.5

func (n *NickIndex) Get(v []rune) *nickIndexItem

func (*NickIndex) Insert added in v1.0.3

func (n *NickIndex) Insert(v []rune)

func (*NickIndex) InsertWithMeta added in v1.0.5

func (n *NickIndex) InsertWithMeta(v []rune, m interface{})

func (*NickIndex) Remove added in v1.0.3

func (n *NickIndex) Remove(v []rune)

type Node

type Node interface {
	Pos() int
	End() int
}

type Parser

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

func NewParser

func NewParser(ctx *ParserContext, l lexer) *Parser

func (*Parser) ParseMessage

func (p *Parser) ParseMessage() (s *Span)

type ParserContext

type ParserContext struct {
	Emotes         *RuneIndex
	EmoteModifiers *RuneIndex
	Nicks          *NickIndex
	Tags           *RuneIndex
}

func NewParserContext

func NewParserContext(opt ParserContextValues) *ParserContext

type ParserContextValues

type ParserContextValues struct {
	Emotes         []string
	EmoteModifiers []string
	Nicks          []string
	Tags           []string
}

type RuneIndex

type RuneIndex struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewRuneIndex

func NewRuneIndex(values [][]rune) *RuneIndex

func (*RuneIndex) Contains

func (r *RuneIndex) Contains(v []rune) bool

func (*RuneIndex) Insert

func (r *RuneIndex) Insert(v []rune)

func (*RuneIndex) Remove

func (r *RuneIndex) Remove(v []rune)

func (*RuneIndex) Replace

func (r *RuneIndex) Replace(values [][]rune)

type Span

type Span struct {
	Type   SpanType
	Nodes  []Node
	TokPos int
	TokEnd int
}

func (*Span) End

func (s *Span) End() int

func (*Span) Insert

func (s *Span) Insert(n Node)

func (*Span) Pos

func (s *Span) Pos() int

type SpanType

type SpanType int
const (
	SpanMessage SpanType = iota
	SpanText
	SpanCode
	SpanGreentext
	SpanSpoiler
	SpanMe
)

func (SpanType) String

func (t SpanType) String() string

type Tag

type Tag struct {
	Name   string
	TokPos int
	TokEnd int
}

func (*Tag) End

func (t *Tag) End() int

func (*Tag) Pos

func (t *Tag) Pos() int

Jump to

Keyboard shortcuts

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