summaryrefslogtreecommitdiff
path: root/parser.go
diff options
context:
space:
mode:
Diffstat (limited to 'parser.go')
-rw-r--r--parser.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/parser.go b/parser.go
index c6d7f9b..2477bb4 100644
--- a/parser.go
+++ b/parser.go
@@ -81,6 +81,21 @@ func ParseString(parser Parserish, input string) (result interface{}, remaining
}
func Exact(match string) Parser {
+ if len(match) == 1 {
+ matchByte := match[0]
+ return NewParser(match, func(ps *State) Node {
+ ps.AutoWS()
+ if ps.Input[ps.Pos] != matchByte {
+ ps.ErrorHere(match)
+ return Node{}
+ }
+
+ ps.Advance(1)
+
+ return Node{Token: match}
+ })
+ }
+
return NewParser(match, func(ps *State) Node {
ps.AutoWS()
if !strings.HasPrefix(ps.Get(), match) {