Versions in this module Expand all Collapse all v0 v0.6.0 Oct 23, 2018 v0.5.0 Aug 2, 2018 Changes in this version + func Stringify(tokens ...*Token) string type Emitter + func UsingByGroup(sublexerGetFunc func(string) Lexer, sublexerNameGroup, codeGroup int, ...) Emitter type Lexer + func DelegatingLexer(root Lexer, language Lexer) Lexer v0.4.0 Mar 2, 2018 Changes in this version type TokeniseOptions + Nested bool v0.3.0 Feb 15, 2018 Changes in this version type Rules + func (r Rules) Clone() Rules v0.2.1 Jan 2, 2018 Changes in this version type TokenType + func (t *TokenType) MarshalJSON() ([]byte, error) + func (t *TokenType) UnmarshalJSON(data []byte) error v0.2.0 Nov 24, 2017 Changes in this version type Config + EnsureNL bool + Priority float32 type Lexer + func RemappingLexer(lexer Lexer, mapper func(*Token) []*Token) Lexer + func TypeRemappingLexer(lexer Lexer, mapping TypeMapping) Lexer + type PrioritisedLexers []Lexer + func (l PrioritisedLexers) Len() int + func (l PrioritisedLexers) Less(i, j int) bool + func (l PrioritisedLexers) Swap(i, j int) type TokenType + const LineNumbersTable + const LineTable + const LineTableTD + type TypeMapping []struct v0.1.1 Sep 26, 2017 Changes in this version + var StandardTypes = map[TokenType]string type TokenType + func (t TokenType) Parent() TokenType v0.1.0 Sep 25, 2017 Changes in this version + const Date + const Number + const NumberBin + const NumberFloat + const NumberHex + const NumberInteger + const NumberIntegerLong + const NumberOct + const String + const StringAffix + const StringBacktick + const StringChar + const StringDelimiter + const StringDoc + const StringDouble + const StringEscape + const StringHeredoc + const StringInterpol + const StringOther + const StringRegex + const StringSingle + const StringSymbol + const Whitespace + var ANSI2RGB = map[string]string + func Words(prefix, suffix string, words ...string) string + type Analyser interface + AnalyseText func(text string) float32 + type Colour int32 + func MustParseColour(colour string) Colour + func NewColour(r, g, b uint8) Colour + func ParseColour(colour string) Colour + func (c Colour) Blue() uint8 + func (c Colour) Brighten(factor float64) Colour + func (c Colour) Brightness() float64 + func (c Colour) Distance(e2 Colour) float64 + func (c Colour) GoString() string + func (c Colour) Green() uint8 + func (c Colour) IsSet() bool + func (c Colour) Red() uint8 + func (c Colour) String() string + type Colours []Colour + func (c Colours) Len() int + func (c Colours) Less(i, j int) bool + func (c Colours) Swap(i, j int) + type CompiledRule struct + Regexp *regexp2.Regexp + type CompiledRules map[string][]*CompiledRule + type Config struct + AliasFilenames []string + Aliases []string + CaseInsensitive bool + DotAll bool + Filenames []string + MimeTypes []string + Name string + NotMultiline bool + type Emitter interface + Emit func(groups []string, lexer Lexer) Iterator + func ByGroups(emitters ...Emitter) Emitter + func Using(lexer Lexer, options *TokeniseOptions) Emitter + func UsingSelf(state string) Emitter + type EmitterFunc func(groups []string, lexer Lexer) Iterator + func (e EmitterFunc) Emit(groups []string, lexer Lexer) Iterator + type Formatter interface + Format func(w io.Writer, style *Style, iterator Iterator) error + func RecoveringFormatter(formatter Formatter) Formatter + type FormatterFunc func(w io.Writer, style *Style, iterator Iterator) error + func (f FormatterFunc) Format(w io.Writer, s *Style, it Iterator) (err error) + type Iterator func() *Token + func Concaterator(iterators ...Iterator) Iterator + func Literator(tokens ...*Token) Iterator + func (i Iterator) Tokens() []*Token + type Lexer interface + Config func() *Config + Tokenise func(options *TokeniseOptions, text string) (Iterator, error) + func Coalesce(lexer Lexer) Lexer + type LexerMutator interface + MutateLexer func(rules CompiledRules, state string, rule int) error + type LexerState struct + Groups []string + Lexer *RegexLexer + MutatorContext map[interface{}]interface{} + Pos int + Rule int + Rules CompiledRules + Stack []string + State string + Text []rune + func (l *LexerState) Get(key interface{}) interface{} + func (l *LexerState) Iterator() *Token + func (l *LexerState) Set(key interface{}, value interface{}) + type Lexers []Lexer + func (l Lexers) Len() int + func (l Lexers) Less(i, j int) bool + func (l Lexers) Pick(text string) Lexer + func (l Lexers) Swap(i, j int) + type Mutator interface + Mutate func(state *LexerState) error + func Combined(states ...string) Mutator + type MutatorFunc func(state *LexerState) error + func Mutators(modifiers ...Mutator) MutatorFunc + func Pop(n int) MutatorFunc + func Push(states ...string) MutatorFunc + func (m MutatorFunc) Mutate(state *LexerState) error + type RegexLexer struct + func MustNewLexer(config *Config, rules Rules) *RegexLexer + func NewLexer(config *Config, rules Rules) (*RegexLexer, error) + func (r *RegexLexer) AnalyseText(text string) float32 + func (r *RegexLexer) Config() *Config + func (r *RegexLexer) SetAnalyser(analyser func(text string) float32) *RegexLexer + func (r *RegexLexer) Tokenise(options *TokeniseOptions, text string) (Iterator, error) + func (r *RegexLexer) Trace(trace bool) *RegexLexer + type Rule struct + Mutator Mutator + Pattern string + Type Emitter + func Default(mutators ...Mutator) Rule + func Include(state string) Rule + type Rules map[string][]Rule + type Style struct + Name string + func MustNewStyle(name string, entries StyleEntries) *Style + func NewStyle(name string, entries StyleEntries) (*Style, error) + func (s *Style) Builder() *StyleBuilder + func (s *Style) Get(ttype TokenType) StyleEntry + func (s *Style) Has(ttype TokenType) bool + func (s *Style) Types() []TokenType + type StyleBuilder struct + func NewStyleBuilder(name string) *StyleBuilder + func (s *StyleBuilder) Add(ttype TokenType, entry string) *StyleBuilder + func (s *StyleBuilder) AddAll(entries StyleEntries) *StyleBuilder + func (s *StyleBuilder) AddEntry(ttype TokenType, entry StyleEntry) *StyleBuilder + func (s *StyleBuilder) Build() (*Style, error) + func (s *StyleBuilder) Get(ttype TokenType) StyleEntry + type StyleEntries map[TokenType]string + type StyleEntry struct + Background Colour + Bold Trilean + Border Colour + Colour Colour + Italic Trilean + NoInherit bool + Underline Trilean + func ParseStyleEntry(entry string) (StyleEntry, error) + func (s StyleEntry) Inherit(ancestors ...StyleEntry) StyleEntry + func (s StyleEntry) IsZero() bool + func (s StyleEntry) String() string + func (s StyleEntry) Sub(e StyleEntry) StyleEntry + type Token struct + Type TokenType + Value string + func Tokenise(lexer Lexer, options *TokeniseOptions, text string) ([]*Token, error) + func (t *Token) Clone() *Token + func (t *Token) GoString() string + func (t *Token) String() string + type TokenType int + const Background + const Comment + const CommentHashbang + const CommentMultiline + const CommentPreproc + const CommentPreprocFile + const CommentSingle + const CommentSpecial + const Error + const Generic + const GenericDeleted + const GenericEmph + const GenericError + const GenericHeading + const GenericInserted + const GenericOutput + const GenericPrompt + const GenericStrong + const GenericSubheading + const GenericTraceback + const GenericUnderline + const Keyword + const KeywordConstant + const KeywordDeclaration + const KeywordNamespace + const KeywordPseudo + const KeywordReserved + const KeywordType + const LineHighlight + const LineNumbers + const Literal + const LiteralDate + const LiteralNumber + const LiteralNumberBin + const LiteralNumberFloat + const LiteralNumberHex + const LiteralNumberInteger + const LiteralNumberIntegerLong + const LiteralNumberOct + const LiteralOther + const LiteralString + const LiteralStringAffix + const LiteralStringAtom + const LiteralStringBacktick + const LiteralStringBoolean + const LiteralStringChar + const LiteralStringDelimiter + const LiteralStringDoc + const LiteralStringDouble + const LiteralStringEscape + const LiteralStringHeredoc + const LiteralStringInterpol + const LiteralStringName + const LiteralStringOther + const LiteralStringRegex + const LiteralStringSingle + const LiteralStringSymbol + const Name + const NameAttribute + const NameBuiltin + const NameBuiltinPseudo + const NameClass + const NameConstant + const NameDecorator + const NameEntity + const NameException + const NameFunction + const NameFunctionMagic + const NameKeyword + const NameLabel + const NameNamespace + const NameOperator + const NameOther + const NameProperty + const NamePseudo + const NameTag + const NameVariable + const NameVariableAnonymous + const NameVariableClass + const NameVariableGlobal + const NameVariableInstance + const NameVariableMagic + const None + const Operator + const OperatorWord + const Other + const Punctuation + const Text + const TextPunctuation + const TextSymbol + const TextWhitespace + func (i TokenType) String() string + func (t TokenType) Category() TokenType + func (t TokenType) Emit(groups []string, lexer Lexer) Iterator + func (t TokenType) InCategory(other TokenType) bool + func (t TokenType) InSubCategory(other TokenType) bool + func (t TokenType) SubCategory() TokenType + type TokeniseOptions struct + State string + type Trilean uint8 + const No + const Pass + const Yes + func (t Trilean) Prefix(s string) string + func (t Trilean) String() string