From fd66f635888abdba5b8c89609be7f7af522df55c Mon Sep 17 00:00:00 2001 From: Maurice Makaay Date: Tue, 18 Jun 2019 23:26:15 +0000 Subject: [PATCH] And stil... it can be cleaner and simpler. --- value_boolean.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/value_boolean.go b/value_boolean.go index f42a0df..7996347 100644 --- a/value_boolean.go +++ b/value_boolean.go @@ -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")) -) - +// Booleans are just the tokens you're used to. Always lowercase. 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") }