Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcceptAct ¶ added in v0.1.20
AcceptAct is an accept action.
func NewAcceptAct ¶ added in v0.1.20
NewAcceptAct creates a new accept action.
Parameters:
- rule: The rule that is being accepted.
Returns:
- *AcceptAct: The new accept action.
- error: An error if rule is nil.
type Builder ¶ added in v0.1.20
Builder is a parser builder.
func NewBuilder ¶ added in v0.1.20
NewBuilder creates a new parser builder.
Returns:
- Builder: The new parser builder.
func (Builder[T]) Build ¶ added in v0.1.20
Build builds a parser.
Returns:
- *Parser: The new parser. Never returns nil.
type ErrAfter ¶ added in v0.1.20
type ErrAfter[T gr.Enumer] struct { // Type is the type before the one that caused the error. Type T // Err is the underlying error. Err error }
ErrAfter is an error that occurs after a certain type.
func NewErrAfter ¶ added in v0.1.20
NewErrAfter creates a new ErrAfter error.
Parameters:
- type_: The type before the one that caused the error.
- err: The underlying error.
Returns:
- *ErrAfter: The new error. Never returns nil.
type ErrBefore ¶ added in v0.1.20
type ErrBefore[T gr.Enumer] struct { // Type is the type after the one that caused the error. Type T // Err is the underlying error. Err error }
ErrBefore is an error that occurs before a certain type.
func NewErrBefore ¶ added in v0.1.20
NewErrBefore creates a new ErrBefore error.
Parameters:
- type_: The type after the one that caused the error.
- err: The underlying error.
Returns:
- *ErrBefore: The new error. Never returns nil.
type ErrUnexpectedToken ¶
type ErrUnexpectedToken[T gr.Enumer] struct { // Left is the expected type. Left T // Right is the unexpected type. Right T // Got is the token that was found. Got *T }
ErrUnexpectedToken is an error that occurs when an unexpected token is found.
func NewErrUnexpectedToken ¶
func NewErrUnexpectedToken[T gr.Enumer](left, right T, got *T) *ErrUnexpectedToken[T]
NewErrUnexpectedToken creates a new ErrUnexpectedToken error.
Parameters:
- left: The expected type.
- right: The unexpected type.
- got: The token that was found.
Returns:
- *ErrUnexpectedToken: The new error. Never returns nil.
func (ErrUnexpectedToken[T]) Error ¶
func (e ErrUnexpectedToken[T]) Error() string
Error implements the error interface.
Message: "expected either <left> or <right> but got <got> instead"
type ParseFunc ¶ added in v0.1.20
type ParseFunc[T gr.Enumer] func(parser *Parser[T], top1 *gr.Token[T], la *gr.Token[T]) (Actioner, error)
ParseFunc is a function that parses a token.
Parameters:
- parser: The parser. Assumed to be non-nil.
- top1: The first token. Assumed to be non-nil.
- la: The lookahead token.
Returns:
- Actioner: The action to perform.
- error: An error if the decision is invalid.
type Parser ¶
Parser is a parser.
type ReduceAct ¶ added in v0.1.20
ReduceAct is a reduce action.
func NewReduceAct ¶ added in v0.1.20
NewReduceAct creates a new reduce action.
Parameters:
- rule: The rule that is being reduced.
Returns:
- *ReduceAct: The new reduce action.
- error: An error if rule is nil.
type Rule ¶
Rule represents a rule in the grammar.
func NewRule ¶
NewRule creates a new rule.
Parameters:
- lhs: The left hand side of the rule.
- rhss: The right hand side of the rule.
Returns:
- *Rule: The new rule.
- error: An error if rhss is empty.
func (Rule[T]) BackwardRhs ¶ added in v0.1.20
BackwardRhs returns the right hand side of the rule in reverse order.
Returns:
- iter.Seq[T]: The right hand side of the rule in reverse order.
type ShiftAct ¶ added in v0.1.20
type ShiftAct struct { }
ShiftAct is a shift action.
func NewShiftAct ¶ added in v0.1.20
func NewShiftAct() *ShiftAct
NewShiftAct creates a new shift action.
Returns:
- *ShiftAct: The new shift action. Never returns nil.