Documentation ¶
Overview ¶
Package bsr implements a Binary Subtree Representation set as defined in
Scott et al Derivation representation using binary subtree sets, Science of Computer Programming 175 (2019)
Index ¶
- type BSR
- func (b BSR) Alternate() int
- func (b BSR) GetAllNTChildren() [][]BSR
- func (b BSR) GetNTChild(nt symbols.NT, i int) BSR
- func (b BSR) GetNTChildI(i int) BSR
- func (b BSR) GetNTChildren(nt symbols.NT, i int) []BSR
- func (b BSR) GetNTChildrenI(i int) []BSR
- func (b BSR) GetTChildI(i int) *token.Token
- func (b BSR) LeftExtent() int
- func (b BSR) Pivot() int
- func (b BSR) RightExtent() int
- func (b BSR) String() string
- type BSRs
- type Set
- func (s *Set) Add(l slot.Label, i, k, j int)
- func (s *Set) AddEmpty(l slot.Label, i int)
- func (s *Set) Contain(nt symbols.NT, left, right int) bool
- func (s *Set) Dump()
- func (s *Set) GetAll() (bsrs []BSR)
- func (s *Set) GetAllStrings(str symbols.Symbols, lext, rext int) (strs []*stringBSR)
- func (s *Set) GetRightExtent() int
- func (s *Set) GetRoot() BSR
- func (s *Set) GetRoots() (roots []BSR)
- func (s *Set) IsAmbiguous() bool
- func (s *Set) ReportAmbiguous()
- func (pf *Set) ToSPPF() *sppf.SymbolNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BSR ¶
BSR is the binary subtree representation of a parsed nonterminal
func (BSR) GetAllNTChildren ¶
GetAllNTChildren returns all the NT Children of b. If an NT child of b has ambiguous parses then all parses of that child are returned.
func (BSR) GetNTChild ¶
GetNTChild returns the BSR of occurrence i of nt in s. GetNTChild fails if s has ambiguous subtrees of occurrence i of nt.
func (BSR) GetNTChildI ¶
GetNTChildI returns the BSR of NT symbol[i] in the BSR set. GetNTChildI fails if the BSR set has ambiguous subtrees of NT i.
func (BSR) GetNTChildren ¶
GetNTChildren returns all the BSRs of occurrence i of nt in s
func (BSR) GetNTChildrenI ¶
GetNTChildrenI returns all the BSRs of NT symbol[i] in s
func (BSR) GetTChildI ¶
GetTChildI returns the terminal symbol at position i in b. GetTChildI panics if symbol i is not a valid terminal
func (BSR) LeftExtent ¶
LeftExtent returns the left extent of the BSR in the stream of tokens
func (BSR) RightExtent ¶
RightExtent returns the right extent of the BSR in the stream of tokens
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set contains the set of Binary Subtree Representations (BSR).
func (*Set) Contain ¶
Contain returns true iff the BSR Set contains the NT symbol with left and right extent.
func (*Set) GetAllStrings ¶
GetAllStrings returns all string elements with symbols = str, left extent = lext and right extent = rext
func (*Set) GetRightExtent ¶
GetRightExtent returns the right extent of the BSR set
func (*Set) GetRoot ¶
GetRoot returns the root of the parse tree of an unambiguous parse. GetRoot fails if the parse was ambiguous. Use GetRoots() for ambiguous parses.
func (*Set) GetRoots ¶
GetRoots returns all the roots of parse trees of the start symbol of the grammar.
func (*Set) IsAmbiguous ¶
IsAmbiguous returns true if the BSR set does not have exactly one root, or if any BSR in the set has an NT symbol, which does not have exactly one sub-tree.
func (*Set) ReportAmbiguous ¶
func (s *Set) ReportAmbiguous()
ReportAmbiguous lists the ambiguous subtrees of the parse forest
func (*Set) ToSPPF ¶
func (pf *Set) ToSPPF() *sppf.SymbolNode