gnom

package module
v0.0.0-...-b2231bd Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2020 License: MPL-2.0 Imports: 3 Imported by: 4

README

gnom

A simple lexer and parser for go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParse         = errors.New("parser error")
	ErrParseInternal = errors.New("internal parser error")
)
View Source
var (
	ErrGrammar = errors.New("grammar error")
)
View Source
var (
	ErrLex = errors.New("lexer error")
)

Functions

This section is empty.

Types

type Dfa

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

func NewDfa

func NewDfa(kind int) *Dfa

func (*Dfa) AddDfa

func (d *Dfa) AddDfa(s []rune, dfa *Dfa)

func (*Dfa) AddPath

func (d *Dfa) AddPath(path []rune, kind int, def int) *Dfa

func (*Dfa) Kind

func (d *Dfa) Kind() int

func (*Dfa) Match

func (d *Dfa) Match(c rune) (*Dfa, bool)

type DfaLexer

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

func NewDfaLexer

func NewDfaLexer(dfa *Dfa, def, eof int, ignored map[int]struct{}) *DfaLexer

func (*DfaLexer) Next

func (l *DfaLexer) Next(chars []rune) (*Token, []rune, error)

func (*DfaLexer) Tokenize

func (l *DfaLexer) Tokenize(chars []rune) ([]Token, error)

type GrammarRule

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

func NewGrammarRule

func NewGrammarRule(from GrammarSym, to ...GrammarSym) GrammarRule

type GrammarSym

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

func NewGrammarNonTerm

func NewGrammarNonTerm(kind int) GrammarSym

func NewGrammarTerm

func NewGrammarTerm(kind int) GrammarSym

func (*GrammarSym) Kind

func (s *GrammarSym) Kind() int

func (*GrammarSym) Term

func (s *GrammarSym) Term() bool

type GrammarSymGenerator

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

func NewGrammarSymGenerator

func NewGrammarSymGenerator() *GrammarSymGenerator

func (*GrammarSymGenerator) NonTerm

func (g *GrammarSymGenerator) NonTerm() GrammarSym

func (*GrammarSymGenerator) Term

func (g *GrammarSymGenerator) Term() GrammarSym

type LL1Parser

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

func NewLL1Parser

func NewLL1Parser(rules []GrammarRule, start, eof GrammarSym) (*LL1Parser, error)

func (*LL1Parser) Parse

func (p *LL1Parser) Parse(tokens []Token) (*ParseTree, error)

type PEGParser

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

func NewPEGParser

func NewPEGParser(rules []GrammarRule, start, eof GrammarSym) *PEGParser

func (*PEGParser) Parse

func (p *PEGParser) Parse(tokens []Token) (*ParseTree, error)

type ParseTree

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

func (*ParseTree) Children

func (t *ParseTree) Children() []*ParseTree

func (*ParseTree) Kind

func (t *ParseTree) Kind() int

func (*ParseTree) Sym

func (t *ParseTree) Sym() GrammarSym

func (*ParseTree) Term

func (t *ParseTree) Term() bool

func (*ParseTree) Token

func (t *ParseTree) Token() Token

func (*ParseTree) Val

func (t *ParseTree) Val() string

type Token

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

func (*Token) Kind

func (t *Token) Kind() int

func (*Token) Val

func (t *Token) Val() string

Jump to

Keyboard shortcuts

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