Documentation
¶
Overview ¶
Package grammar imlements the grammar parser for the BadWolf query language. The parser is impemented as a reusable recursive decent parser for a left LL(k) left factorized grammar. BQL is an LL(1) grammar however the parser is designed to be reusable and help separate the grammar from the parsing mechanics to improve maintainablity and flexibility of grammar changes by keeping those the code separation clearly delineated.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clause ¶
type Clause struct { Elements []Element ProcessStart semantic.ClauseHook ProcessEnd semantic.ClauseHook ProcessedElement semantic.ElementHook }
Clause contains on clause of the derivation rule.
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
Element are the main components that define a derivation rule.
func NewTokenType ¶
NewTokenType creates a new element from a token.
type Grammar ¶
Grammar contains the left factory LLk grammar to be parsed. All provided grammars *must* have the "START" symbol to initialte the parsing of input text.
func SemanticBQL ¶
func SemanticBQL() *Grammar
SemanticBQL contains the BQL grammar with hooks injected.
type LLk ¶
type LLk struct {
// contains filtered or unexported fields
}
LLk provide the basic lookahead mechanisms required to implement a recursive descent LLk parser.
func NewLLk ¶
NewLLk creates a LLk structure for the given string to parse and the indicated k lookahead.
func (*LLk) CanAccept ¶
CanAccept returns true if the provided token matches the current on being processed, false otherwise.
func (*LLk) Consume ¶
Consume will consue the current token and move to the next one if it matches the provided token, false otherwise.