aboutsummaryrefslogtreecommitdiff
path: root/spec/lexer_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lexer_test.go')
-rw-r--r--spec/lexer_test.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/spec/lexer_test.go b/spec/lexer_test.go
index 89553d0..569f278 100644
--- a/spec/lexer_test.go
+++ b/spec/lexer_test.go
@@ -32,18 +32,19 @@ func TestLexer_Run(t *testing.T) {
}{
{
caption: "the lexer can recognize all kinds of tokens",
- src: `id"terminal":|;#'()$1...`,
+ src: `id"terminal"'.*+?|()[\':|;#()$1...#`,
tokens: []*token{
idTok("id"),
termPatTok("terminal"),
+ termPatTok(`\.\*\+\?\|\(\)\[\\`),
symTok(tokenKindColon),
symTok(tokenKindOr),
symTok(tokenKindSemicolon),
- symTok(tokenKindDirectiveMarker),
symTok(tokenKindTreeNodeOpen),
symTok(tokenKindTreeNodeClose),
posTok(1),
symTok(tokenKindExpantion),
+ symTok(tokenKindDirectiveMarker),
newEOFToken(),
},
},
@@ -64,6 +65,16 @@ func TestLexer_Run(t *testing.T) {
},
},
{
+ caption: "a pattern must include at least one character",
+ src: `""`,
+ err: synErrEmptyPattern,
+ },
+ {
+ caption: "a literal pattern must include at least one character",
+ src: `''`,
+ err: synErrEmptyPattern,
+ },
+ {
caption: "the lexer can recognize newlines and combine consecutive newlines into one",
src: "\u000A | \u000D | \u000D\u000A | \u000A\u000A \u000D\u000D \u000D\u000A\u000D\u000A",
tokens: []*token{