Documentation ¶
Overview ¶
A Parser library and framework. Left-recursive rules are not supported without special care.
A Parser library and framework. Left-recursive rules are not supported without special care.
Index ¶
- Constants
- func FastMatch(t *scanlist.Element, rs ...rune) (bool, *scanlist.Element)
- func Match(f func(rune) string, t *scanlist.Element, rs ...rune) (error, *scanlist.Element)
- func Textify(r rune) string
- type ArrayPlus
- type ArraySeq
- type ArrayStar
- type Delegate
- type LPlus
- type LSeq
- type LStar
- type OR
- type ParseRule
- type Parser
- func (p *Parser) Construct() *Parser
- func (p *Parser) Define(n string, left bool, r ParseRule)
- func (p *Parser) DefineBefore(n string, left bool, r ParseRule)
- func (p *Parser) Match(n string, tokens *scanlist.Element) ParserResult
- func (p *Parser) MatchNoLeftRecursion(n string, tokens *scanlist.Element) ParserResult
- func (p *Parser) String() string
- func (p *Parser) TouchRule(n string)
- type ParserResult
- type Pfunc
- type RequireText
- type Required
- type TokenFinishedOptional
Constants ¶
View Source
const ( RESULT_OK = uint(iota) RESULT_FAILED RESULT_FAILED_CUT )
View Source
const (
LEFT_RECURSIVE = uint(1 << iota)
)
View Source
const NONE = uint(0)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ParseRule ¶
type ParseRule interface { // left = the Left-Recursive element, if any, else nil Parse(p *Parser, tokens *scanlist.Element, left interface{}) ParserResult }
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) DefineBefore ¶
Like .Define(), but does prepend rather than append!
func (*Parser) MatchNoLeftRecursion ¶
func (p *Parser) MatchNoLeftRecursion(n string, tokens *scanlist.Element) ParserResult
type ParserResult ¶
type ParserResult struct { Result uint Next *scanlist.Element // next token on success; undefined on failure. Data interface{} // The syntax-tree on success; the error message on failure. Pos scanner.Position }
func ResultFail ¶
func ResultFail(reason string, pos scanner.Position) ParserResult
func ResultFailCut ¶
func ResultFailCut(reason string, pos scanner.Position) ParserResult
func ResultOk ¶
func ResultOk(next *scanlist.Element, tree interface{}) ParserResult
type RequireText ¶
type RequireText struct {
Text string
}
func (RequireText) Parse ¶
func (r RequireText) Parse(p *Parser, tokens *scanlist.Element, left interface{}) ParserResult
type TokenFinishedOptional ¶
(Token|Inner Token) => Inner or nil
func (TokenFinishedOptional) Parse ¶
func (s TokenFinishedOptional) Parse(p *Parser, tokens *scanlist.Element, left interface{}) ParserResult
Click to show internal directories.
Click to hide internal directories.