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"
|
||||
)
|
||||
|
||||
var (
|
||||
// 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) {
|
||||
switch {
|
||||
case p.Accept(tok.Boolean(nil, trueOrFalse)):
|
||||
t.emitCommand(csetBoolVal, p.Result().Value(0).(bool))
|
||||
case p.Accept(a.Str("true")):
|
||||
t.emitCommand(csetBoolVal, true)
|
||||
case p.Accept(a.Str("false")):
|
||||
t.emitCommand(csetBoolVal, false)
|
||||
default:
|
||||
p.Expected("true or false")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue