summaryrefslogtreecommitdiff
path: root/combinator.go
diff options
context:
space:
mode:
Diffstat (limited to 'combinator.go')
-rw-r--r--combinator.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/combinator.go b/combinator.go
index f072913..e83a0c1 100644
--- a/combinator.go
+++ b/combinator.go
@@ -123,6 +123,19 @@ func Maybe(parser Parserish) Parser {
})
}
+func Bind(parser Parserish, val interface{}) Parser {
+ p := Parsify(parser)
+
+ return func(ps *State) Node {
+ node := p(ps)
+ if ps.Errored() {
+ return node
+ }
+ node.Result = val
+ return node
+ }
+}
+
func Map(parser Parserish, f func(n Node) Node) Parser {
p := Parsify(parser)