package parse

import (
	"git.makaay.nl/mauricem/go-parsekit/parse"
	"git.makaay.nl/mauricem/go-toml/ast"
)

var falseValue = ast.NewValue(ast.TypeBool, false)
var trueValue = ast.NewValue(ast.TypeBool, 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
	}
}
