Skip to content

Commit

Permalink
docs: simple lexer rules are tried in order (#404)
Browse files Browse the repository at this point in the history
This addition to `MustSimple` and `NewSimple` docs would help me when writing my lexer. I had to find the answer in #287 (reply in thread)
  • Loading branch information
viktomas committed May 8, 2024
1 parent a8adfde commit 088bb72
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lexer/simple.go
Expand Up @@ -7,6 +7,7 @@ type SimpleRule struct {
}

// MustSimple creates a new Stateful lexer with only a single root state.
// The rules are tried in order.
//
// It panics if there is an error.
func MustSimple(rules []SimpleRule) *StatefulDefinition {
Expand All @@ -18,6 +19,7 @@ func MustSimple(rules []SimpleRule) *StatefulDefinition {
}

// NewSimple creates a new Stateful lexer with only a single root state.
// The rules are tried in order.
func NewSimple(rules []SimpleRule) (*StatefulDefinition, error) {
fullRules := make([]Rule, len(rules))
for i, rule := range rules {
Expand Down

0 comments on commit 088bb72

Please sign in to comment.