diff options
author | Adam Scarr <adam@vektah.net> | 2017-08-15 18:57:00 +1000 |
---|---|---|
committer | Adam Scarr <adam@vektah.net> | 2017-08-15 18:57:00 +1000 |
commit | 0f854720ca2bad30246020bb01cdb903a5f9406d (patch) | |
tree | f4acedaa6928300fecd7791a68cc493c37938e5e /combinator.go | |
parent | ddb61bdfc034a683f755dec6ddc80627d2d43522 (diff) |
Make until only work on string terminators
Diffstat (limited to 'combinator.go')
-rw-r--r-- | combinator.go | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/combinator.go b/combinator.go index 4e7e4a5..38145ee 100644 --- a/combinator.go +++ b/combinator.go @@ -145,36 +145,6 @@ func Maybe(parser Parserish) Parser { }) } -// Until will consume all input until one of the given parsers match. This is running every parser over every byte, -// so its probably going to be slow. -func Until(parsers ...Parserish) Parser { - parserfied := ParsifyAll(parsers...) - return NewParser("Until()", func(ps *State, node *Result) { - ws := ps.WS - ps.WS = NoWhitespace - defer func() { - ps.WS = ws - }() - startPos := ps.Pos - for ps.Pos < len(ps.Input) { - endPos := ps.Pos - for _, p := range parserfied { - ps.Pos = endPos - - p(ps, node) - - if !ps.Errored() { - node.Token = ps.Input[startPos:endPos] - return - } - ps.Recover() - } - ps.Pos++ - } - node.Token = ps.Input[startPos:ps.Pos] - }) -} - // Bind will set the node .Result when the given parser matches // This is useful for giving a value to keywords and constant literals // like true and false. See the json parser for an example. |