asciigoat's core library
https://asciigoat.org/core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
403 B
22 lines
403 B
// Package lexer provides basic helpers to implement parsers |
|
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 { |
|
for fn != nil { |
|
var err error |
|
|
|
fn, err = fn() |
|
if err != nil { |
|
// failed |
|
return err |
|
} |
|
} |
|
|
|
// ended |
|
return nil |
|
}
|
|
|