Documentation ¶
Index ¶
- func PNodeBytes(node PNode, src []byte) []byte
- func PNodePosStr(node PNode) string
- func PNodeString(node PNode, src []byte) string
- func SprintNodeTree(src []byte, node PNode, maxDepth int) string
- type Action
- type ActionAccept
- type ActionReduce
- type ActionShift
- type AndRule
- type BasicPNode
- type BoolRule
- type BuildNodeData
- func (d *BuildNodeData) Child(i int) *BuildNodeData
- func (d *BuildNodeData) ChildInt(i int) (int, error)
- func (d *BuildNodeData) ChildLoop(i int, fn BuildNodeFn) error
- func (d *BuildNodeData) ChildLoop2(i int, loopi int, pre, post BuildNodeFn) error
- func (d *BuildNodeData) ChildOptional(i int) (*BuildNodeData, bool)
- func (d *BuildNodeData) ChildStr(i int) string
- func (d *BuildNodeData) ChildsLen() int
- func (d *BuildNodeData) Data() any
- func (d *BuildNodeData) End() int
- func (d *BuildNodeData) ExternalData() any
- func (d *BuildNodeData) FullSrc() []byte
- func (d *BuildNodeData) IsEmpty() bool
- func (d *BuildNodeData) IsOr(i int) bool
- func (d *BuildNodeData) NodeSrc() string
- func (d *BuildNodeData) Pos() int
- func (d *BuildNodeData) PrintRuleTree(maxDepth int)
- func (d *BuildNodeData) SetData(v any)
- func (d *BuildNodeData) SprintRuleTree(maxDepth int) string
- type BuildNodeFn
- type CPNode
- type CmnRule
- type ContentParser
- type CpOpt
- type DefRule
- type FileSet
- type FuncRule
- type IfRule
- type Lrparser
- func (lrp *Lrparser) ContentParser(opt *CpOpt) (*ContentParser, error)
- func (lrp *Lrparser) GetStringRule(name string) (string, error)
- func (lrp *Lrparser) MustGetStringRule(name string) string
- func (lrp *Lrparser) SetBoolRule(name string, v bool) error
- func (lrp *Lrparser) SetFuncRule(name string, parseOrder int, fn PStateParseFn) error
- func (lrp *Lrparser) SetStringRule(name string, s string) error
- type OrRule
- type PNode
- type PState
- type PStateParseFn
- type ParenRule
- type PosError
- type ProcRule
- type ProcRuleArg
- type ProcRuleArgs
- type ProcRuleFn
- type RefRule
- type Rule
- type RuleDot
- type RuleDots
- type RuleDotsLaSet
- type RuleFirstT
- type RuleIndex
- type RuleSet
- type RuneRange
- type SingletonRule
- type State
- type StatesData
- type StringRule
- type Vertex
- type VertexId
- type VerticesData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PNodeBytes ¶
func PNodePosStr ¶
func PNodeString ¶
Types ¶
type ActionAccept ¶
type ActionAccept struct { }
func (*ActionAccept) String ¶
func (a *ActionAccept) String() string
type ActionReduce ¶
type ActionReduce struct {
// contains filtered or unexported fields
}
func (*ActionReduce) String ¶
func (a *ActionReduce) String() string
type ActionShift ¶
type ActionShift struct {
// contains filtered or unexported fields
}
func (*ActionShift) String ¶
func (a *ActionShift) String() string
type BasicPNode ¶
type BasicPNode struct {
// contains filtered or unexported fields
}
basic parse node implementation
func (*BasicPNode) End ¶
func (n *BasicPNode) End() int
func (*BasicPNode) Pos ¶
func (n *BasicPNode) Pos() int
func (*BasicPNode) PosEmpty ¶
func (n *BasicPNode) PosEmpty() bool
func (*BasicPNode) SetPos ¶
func (n *BasicPNode) SetPos(pos, end int)
func (*BasicPNode) SrcString ¶
func (n *BasicPNode) SrcString(src []byte) string
type BoolRule ¶
type BoolRule struct { CmnRule // contains filtered or unexported fields }
To be used in src code and then found by IfRule; the value is observed when building the contentparser, not at parse time (0 childs)
type BuildNodeData ¶
type BuildNodeData struct {
// contains filtered or unexported fields
}
func (*BuildNodeData) Child ¶
func (d *BuildNodeData) Child(i int) *BuildNodeData
func (*BuildNodeData) ChildLoop ¶
func (d *BuildNodeData) ChildLoop(i int, fn BuildNodeFn) error
func (*BuildNodeData) ChildLoop2 ¶
func (d *BuildNodeData) ChildLoop2(i int, loopi int, pre, post BuildNodeFn) error
func (*BuildNodeData) ChildOptional ¶
func (d *BuildNodeData) ChildOptional(i int) (*BuildNodeData, bool)
func (*BuildNodeData) ChildStr ¶
func (d *BuildNodeData) ChildStr(i int) string
func (*BuildNodeData) ChildsLen ¶
func (d *BuildNodeData) ChildsLen() int
func (*BuildNodeData) Data ¶
func (d *BuildNodeData) Data() any
func (*BuildNodeData) End ¶
func (d *BuildNodeData) End() int
func (*BuildNodeData) ExternalData ¶
func (d *BuildNodeData) ExternalData() any
func (*BuildNodeData) FullSrc ¶
func (d *BuildNodeData) FullSrc() []byte
func (*BuildNodeData) IsEmpty ¶
func (d *BuildNodeData) IsEmpty() bool
func (*BuildNodeData) IsOr ¶
func (d *BuildNodeData) IsOr(i int) bool
func (*BuildNodeData) NodeSrc ¶
func (d *BuildNodeData) NodeSrc() string
func (*BuildNodeData) Pos ¶
func (d *BuildNodeData) Pos() int
func (*BuildNodeData) PrintRuleTree ¶
func (d *BuildNodeData) PrintRuleTree(maxDepth int)
func (*BuildNodeData) SetData ¶
func (d *BuildNodeData) SetData(v any)
func (*BuildNodeData) SprintRuleTree ¶
func (d *BuildNodeData) SprintRuleTree(maxDepth int) string
type BuildNodeFn ¶
type BuildNodeFn func(*BuildNodeData) error
type CPNode ¶
type CPNode struct { BasicPNode // contains filtered or unexported fields }
content parser node
type ContentParser ¶
type ContentParser struct { Opt *CpOpt // contains filtered or unexported fields }
func (*ContentParser) Parse ¶
func (cp *ContentParser) Parse(src []byte, index int) (*BuildNodeData, *cpRun, error)
func (*ContentParser) ParseFileSet ¶
func (cp *ContentParser) ParseFileSet(fset *FileSet, index int, extData any) (*BuildNodeData, *cpRun, error)
func (*ContentParser) SetBuildNodeFn ¶
func (cp *ContentParser) SetBuildNodeFn(name string, buildFn BuildNodeFn) error
type CpOpt ¶
type CpOpt struct { StartRule string // can be empty, will try to get it from grammar VerboseError bool EarlyStop bool // artificially parses an endrule when nextparsedrule fails. Allows parsing to stop successfully when no more input is recognized (although there is still input), while the rules are still able to reduce correctly. ShiftOnSRConflict bool Reverse bool // runs input/rules in reverse (useful to backtrack in the middle of big inputs to then parse normally) }
content parser options
type DefRule ¶
type DefRule struct { BasicPNode CmnRule // contains filtered or unexported fields }
definition rule (1 child)
type FileSet ¶
type FileSet struct { Src []byte // currently, just a single src Filename string // for errors only }
TODO: multiple files (working for single file only)
func NewFileSetFromBytes ¶
func (*FileSet) NodeString ¶
type FuncRule ¶
type FuncRule struct { CmnRule // contains filtered or unexported fields }
(0 childs)
type IfRule ¶
type IfRule struct { BasicPNode CmnRule }
replaced in dereference phase (3 childs: [conditional,then,else])
type Lrparser ¶
type Lrparser struct {
// contains filtered or unexported fields
}
func NewLrparser ¶
func NewLrparserFromBytes ¶
func NewLrparserFromString ¶
func (*Lrparser) ContentParser ¶
func (lrp *Lrparser) ContentParser(opt *CpOpt) (*ContentParser, error)
func (*Lrparser) MustGetStringRule ¶
func (*Lrparser) SetFuncRule ¶
func (lrp *Lrparser) SetFuncRule(name string, parseOrder int, fn PStateParseFn) error
type ParenRule ¶
type ParenRule struct { BasicPNode CmnRule // contains filtered or unexported fields }
parenthesis, ex: (aaa (bbb|ccc)) replaced by defrules at ruleindex (1 childs)
type ProcRule ¶
type ProcRule struct { BasicPNode CmnRule // contains filtered or unexported fields }
processor function call rule: allows processing rules at compile time. Ex: string operations. (0 childs)
type ProcRuleArg ¶
type ProcRuleArg any
type ProcRuleArgs ¶
type ProcRuleArgs []ProcRuleArg
func (ProcRuleArgs) MergedStringRule ¶
func (args ProcRuleArgs) MergedStringRule(i int) (*StringRule, error)
type ProcRuleFn ¶
type ProcRuleFn func(args ProcRuleArgs) (Rule, error)
type RefRule ¶
type RefRule struct { BasicPNode CmnRule // contains filtered or unexported fields }
reference to a rule // replaced in dereference phase (0 childs)
type RuleDotsLaSet ¶
aka "set of items"
func (RuleDotsLaSet) String ¶
func (rdslas RuleDotsLaSet) String() string
type RuleFirstT ¶
type RuleFirstT struct {
// contains filtered or unexported fields
}
rules first terminals
func (*RuleFirstT) String ¶
func (rf *RuleFirstT) String() string
type RuleIndex ¶
type RuleIndex struct {
// contains filtered or unexported fields
}
unique rule index
type SingletonRule ¶
type SingletonRule struct { BasicPNode CmnRule // contains filtered or unexported fields }
(0 childs)
func (*SingletonRule) String ¶
func (r *SingletonRule) String() string
type StatesData ¶
type StatesData struct {
// contains filtered or unexported fields
}
func (*StatesData) String ¶
func (sd *StatesData) String() string
type StringRule ¶
type StringRule struct { BasicPNode CmnRule // contains filtered or unexported fields }
(0 childs)
func (*StringRule) String ¶
func (r *StringRule) String() string
type VerticesData ¶
type VerticesData struct {
// contains filtered or unexported fields
}
passes rules (ruleindex) to vertices data
func (*VerticesData) String ¶
func (vd *VerticesData) String() string