diff options
author | Adam Scarr <adam@vektah.net> | 2017-08-10 21:04:14 +1000 |
---|---|---|
committer | Adam Scarr <adam@vektah.net> | 2017-08-10 21:08:18 +1000 |
commit | af542eff9e1e51561a9efa37685ee07b1d01b53e (patch) | |
tree | c700bdca58b4f9bbeb89ba1b102b2a779c88f7f3 /parser.go | |
parent | b64fcfaa6115eb4a5f65c12d37f95d842136ae35 (diff) |
Add parse logging
Diffstat (limited to 'parser.go')
-rw-r--r-- | parser.go | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -52,7 +52,7 @@ type Parserish interface{} func Parsify(p Parserish) Parser { switch p := p.(type) { case func(*State) Result: - return NewParser("anonymous func", p) + return p case Parser: return p case *Parser: @@ -84,6 +84,13 @@ func WS() Parser { }) } +// Cut prevents backtracking beyond this point. Usually used after keywords when you +// are sure this is the correct path. Improves performance and error reporting. +func Cut(ps *State) Result { + ps.Cut = ps.Pos + return Result{} +} + // Run applies some input to a parser and returns the result, failing if the input isnt fully consumed. // It is a convenience method for the most common way to invoke a parser. func Run(parser Parserish, input string) (result interface{}, err error) { |