aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell.go28
1 files changed, 10 insertions, 18 deletions
diff --git a/shell.go b/shell.go
index b5a457d..e4f8650 100644
--- a/shell.go
+++ b/shell.go
@@ -52,12 +52,12 @@ const (
type class int
const (
- clBreak class = iota
+ clOther class = iota
+ clBreak
clNewline
clQuote
clSingle
clDouble
- clOther
)
type action int
@@ -140,21 +140,13 @@ var update = [...][]struct {
},
}
-func classOf(b byte) class {
- switch b {
- case ' ', '\t':
- return clBreak
- case '\n':
- return clNewline
- case '\\':
- return clQuote
- case '\'':
- return clSingle
- case '"':
- return clDouble
- default:
- return clOther
- }
+var classOf = [256]class{
+ ' ': clBreak,
+ '\t': clBreak,
+ '\n': clNewline,
+ '\\': clQuote,
+ '\'': clSingle,
+ '"': clDouble,
}
// A Scanner partitions input from a reader into tokens divided on space, tab,
@@ -190,7 +182,7 @@ func (s *Scanner) Next() bool {
} else if err != nil {
return false
}
- next := update[s.st][classOf(c)]
+ next := update[s.st][classOf[c]]
s.st = next.state
switch next.action {
case push: