parser

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LEFT  = true
	RIGHT = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element interface {
	Parse(lex *lexer.Lexer, res *base.List[ast.ASTree]) error
	Match(lex *lexer.Lexer) bool
}

type Expr

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

func NewExpr

func NewExpr(typ string, exp *Parser, m *Operators) *Expr

func (*Expr) Match

func (e *Expr) Match(lex *lexer.Lexer) bool

func (*Expr) Parse

func (e *Expr) Parse(lex *lexer.Lexer, res *base.List[ast.ASTree]) error

type IdToken

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

func NewIdToken

func NewIdToken(typ string, r *base.HashSet[string]) *IdToken

func (*IdToken) Match

func (i *IdToken) Match(lex *lexer.Lexer) bool

func (*IdToken) Parse

func (i *IdToken) Parse(lex *lexer.Lexer, res *base.List[ast.ASTree]) error

type Leaf

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

func NewLeaf

func NewLeaf(t []string) *Leaf

func (*Leaf) Find

func (l *Leaf) Find(res *base.List[ast.ASTree], t token.Token)

func (*Leaf) Match

func (l *Leaf) Match(lex *lexer.Lexer) bool

func (*Leaf) Parse

func (l *Leaf) Parse(lex *lexer.Lexer, res *base.List[ast.ASTree]) error

type NumToken

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

func NewNumToken

func NewNumToken(typ string) *NumToken

func (*NumToken) Match

func (n *NumToken) Match(lex *lexer.Lexer) bool

func (*NumToken) Parse

func (n *NumToken) Parse(lex *lexer.Lexer, res *base.List[ast.ASTree]) error

type Operators

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

func NewOperators

func NewOperators() *Operators

func (*Operators) Add

func (o *Operators) Add(name string, pre int, leftAssoc bool)

func (*Operators) Get

func (o *Operators) Get(s string) (*Precedence, bool)

type OrTree

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

func NewOrTree

func NewOrTree(p []*Parser) *OrTree

func (*OrTree) Choose

func (o *OrTree) Choose(l *lexer.Lexer) *Parser

func (*OrTree) Insert

func (o *OrTree) Insert(p *Parser)

func (*OrTree) Match

func (o *OrTree) Match(lex *lexer.Lexer) bool

func (*OrTree) Parse

func (o *OrTree) Parse(lex *lexer.Lexer, res *base.List[ast.ASTree]) error

type Parser

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

func NewParser

func NewParser(typ string) *Parser

func NewParserWithParser

func NewParserWithParser(p *Parser) *Parser

func RuleNoType

func RuleNoType() *Parser

func RuleWithType

func RuleWithType(typ string) *Parser

func (*Parser) Ast

func (p *Parser) Ast(pa *Parser) *Parser

func (*Parser) ExpressionNoType

func (p *Parser) ExpressionNoType(sub *Parser, operators *Operators) *Parser

func (*Parser) ExpressionWithType

func (p *Parser) ExpressionWithType(typ string, sub *Parser, operators *Operators) *Parser

func (*Parser) IdentifierNoType

func (p *Parser) IdentifierNoType(reserved *base.HashSet[string]) *Parser

func (*Parser) IdentifierWithType

func (p *Parser) IdentifierWithType(typ string, reserved *base.HashSet[string]) *Parser

func (*Parser) InsertChoice

func (p *Parser) InsertChoice(pa *Parser) *Parser

func (*Parser) Match

func (p *Parser) Match(l *lexer.Lexer) bool

func (*Parser) Maybe

func (p *Parser) Maybe(pa *Parser) *Parser

func (*Parser) NumberNoType

func (p *Parser) NumberNoType() *Parser

func (*Parser) NumberWithType

func (p *Parser) NumberWithType(typ string) *Parser

func (*Parser) Option

func (p *Parser) Option(pa *Parser) *Parser

func (*Parser) Or

func (p *Parser) Or(pa ...*Parser) *Parser

func (*Parser) Parse

func (p *Parser) Parse(l *lexer.Lexer) ast.ASTree

func (*Parser) Repeat

func (p *Parser) Repeat(pa *Parser) *Parser

func (*Parser) ResetNoType

func (p *Parser) ResetNoType() *Parser

func (*Parser) ResetWithType

func (p *Parser) ResetWithType(typ string) *Parser

func (*Parser) Sep

func (p *Parser) Sep(pat ...string) *Parser

func (*Parser) StringNoType

func (p *Parser) StringNoType() *Parser

func (*Parser) StringWithType

func (p *Parser) StringWithType(typ string) *Parser

func (*Parser) Token

func (p *Parser) Token(pat ...string) *Parser

type Precedence

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

func NewPrecedence

func NewPrecedence(v int, a bool) *Precedence

type Repeat

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

func NewRepeat

func NewRepeat(p *Parser, once bool) *Repeat

func (*Repeat) Match

func (r *Repeat) Match(lex *lexer.Lexer) bool

func (*Repeat) Parse

func (r *Repeat) Parse(lex *lexer.Lexer, res *base.List[ast.ASTree]) error

type Skip

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

func NewSkip

func NewSkip(t []string) *Skip

func (*Skip) Find

func (s *Skip) Find(res *base.List[ast.ASTree], t token.Token)

func (*Skip) Match

func (s *Skip) Match(lex *lexer.Lexer) bool

func (*Skip) Parse

func (s *Skip) Parse(lex *lexer.Lexer, res *base.List[ast.ASTree]) error

type StrToken

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

func NewStrToken

func NewStrToken(typ string) *StrToken

func (*StrToken) Match

func (n *StrToken) Match(lex *lexer.Lexer) bool

func (*StrToken) Parse

func (n *StrToken) Parse(lex *lexer.Lexer, res *base.List[ast.ASTree]) error

type Tree

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

func NewTree

func NewTree(p *Parser) *Tree

func (*Tree) Match

func (t *Tree) Match(lex *lexer.Lexer) bool

func (*Tree) Parse

func (t *Tree) Parse(lex *lexer.Lexer, res *base.List[ast.ASTree]) error

Jump to

Keyboard shortcuts

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