aboutsummaryrefslogtreecommitdiff
path: root/compiler/lexer.go
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/lexer.go')
-rw-r--r--compiler/lexer.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/lexer.go b/compiler/lexer.go
index 91cd209..acc9658 100644
--- a/compiler/lexer.go
+++ b/compiler/lexer.go
@@ -19,6 +19,7 @@ const (
tokenKindGroupClose = tokenKind(")")
tokenKindBExpOpen = tokenKind("[")
tokenKindBExpClose = tokenKind("]")
+ tokenKindCharRange = tokenKind("-")
tokenKindEOF = tokenKind("eof")
)
@@ -124,6 +125,8 @@ func (l *lexer) nextInDefault(c rune) (*token, error) {
func (l *lexer) nextInBExp(c rune) (*token, error) {
switch c {
+ case '-':
+ return newToken(tokenKindCharRange, nullChar), nil
case ']':
l.mode = lexerModeDefault
return newToken(tokenKindBExpClose, nullChar), nil
@@ -138,7 +141,7 @@ func (l *lexer) nextInBExp(c rune) (*token, error) {
}
}
switch {
- case c == '\\' || c == ']':
+ case c == '\\' || c == '-' || c == ']':
return newToken(tokenKindChar, c), nil
default:
return nil, &SyntaxError{