23 lines
536 B
Go
23 lines
536 B
Go
package parse
|
|
|
|
import (
|
|
"git.makaay.nl/mauricem/go-parsekit/parse"
|
|
"git.makaay.nl/mauricem/go-toml/ast"
|
|
)
|
|
|
|
var falseValue = ast.NewValue(ast.TypeBoolean, false)
|
|
var trueValue = ast.NewValue(ast.TypeBoolean, true)
|
|
|
|
// Booleans are just the tokens you're used to. Always lowercase.
|
|
func (t *parser) parseBoolean(p *parse.API) (*ast.Value, bool) {
|
|
switch {
|
|
case p.Accept(a.Str("true")):
|
|
return trueValue, true
|
|
case p.Accept(a.Str("false")):
|
|
return falseValue, true
|
|
default:
|
|
p.Expected("true or false")
|
|
return nil, false
|
|
}
|
|
}
|