diff options
Diffstat (limited to 'compiler/lexer_test.go')
-rw-r--r-- | compiler/lexer_test.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/lexer_test.go b/compiler/lexer_test.go index 11cf043..e2e7d7a 100644 --- a/compiler/lexer_test.go +++ b/compiler/lexer_test.go @@ -31,10 +31,12 @@ func TestLexer(t *testing.T) { }, { caption: "lexer can recognize the special characters", - src: ".*|()[]", + src: ".*+?|()[]", tokens: []*token{ newToken(tokenKindAnyChar, nullChar), newToken(tokenKindRepeat, nullChar), + newToken(tokenKindRepeatOneOrMore, nullChar), + newToken(tokenKindOption, nullChar), newToken(tokenKindAlt, nullChar), newToken(tokenKindGroupOpen, nullChar), newToken(tokenKindGroupClose, nullChar), @@ -45,11 +47,13 @@ func TestLexer(t *testing.T) { }, { caption: "lexer can recognize the escape sequences", - src: "\\\\\\.\\*\\|\\(\\)\\[\\]", + src: "\\\\\\.\\*\\+\\?\\|\\(\\)\\[\\]", tokens: []*token{ newToken(tokenKindChar, '\\'), newToken(tokenKindChar, '.'), newToken(tokenKindChar, '*'), + newToken(tokenKindChar, '+'), + newToken(tokenKindChar, '?'), newToken(tokenKindChar, '|'), newToken(tokenKindChar, '('), newToken(tokenKindChar, ')'), @@ -60,12 +64,14 @@ func TestLexer(t *testing.T) { }, { caption: "in a bracket expression, the special characters are also handled as normal characters", - src: "[\\\\.*|()[\\]].*|()][", + src: "[\\\\.*+?|()[\\]].*|()][", tokens: []*token{ newToken(tokenKindBExpOpen, nullChar), newToken(tokenKindChar, '\\'), newToken(tokenKindChar, '.'), newToken(tokenKindChar, '*'), + newToken(tokenKindChar, '+'), + newToken(tokenKindChar, '?'), newToken(tokenKindChar, '|'), newToken(tokenKindChar, '('), newToken(tokenKindChar, ')'), |