And stil... it can be cleaner and simpler.
This commit is contained in:
parent
1c8f5ffe7e
commit
fd66f63588
|
@ -4,15 +4,13 @@ import (
|
||||||
"git.makaay.nl/mauricem/go-parsekit/parse"
|
"git.makaay.nl/mauricem/go-parsekit/parse"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// Booleans are just the tokens you're used to. Always lowercase.
|
// Booleans are just the tokens you're used to. Always lowercase.
|
||||||
trueOrFalse = a.Str("true").Or(a.Str("false"))
|
|
||||||
)
|
|
||||||
|
|
||||||
func (t *parser) startBoolean(p *parse.API) {
|
func (t *parser) startBoolean(p *parse.API) {
|
||||||
switch {
|
switch {
|
||||||
case p.Accept(tok.Boolean(nil, trueOrFalse)):
|
case p.Accept(a.Str("true")):
|
||||||
t.emitCommand(csetBoolVal, p.Result().Value(0).(bool))
|
t.emitCommand(csetBoolVal, true)
|
||||||
|
case p.Accept(a.Str("false")):
|
||||||
|
t.emitCommand(csetBoolVal, false)
|
||||||
default:
|
default:
|
||||||
p.Expected("true or false")
|
p.Expected("true or false")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue