Alejandro Mery
1 year ago
1 changed files with 15 additions and 0 deletions
@ -1,2 +1,17 @@ |
|||||||
// Package lexer provides basic helpers to implement parsers
|
// Package lexer provides basic helpers to implement parsers
|
||||||
package lexer |
package lexer |
||||||
|
|
||||||
|
// StateFn is a State Function of the parser
|
||||||
|
type StateFn func() (StateFn, error) |
||||||
|
|
||||||
|
// Run runs a state machine until the state function either
|
||||||
|
// returns nil or an error
|
||||||
|
func Run(fn StateFn) error { |
||||||
|
var err error |
||||||
|
|
||||||
|
for fn != nil && err == nil { |
||||||
|
fn, err = fn() |
||||||
|
} |
||||||
|
|
||||||
|
return err |
||||||
|
} |
||||||
|
Loading…
Reference in new issue