diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2021-06-28 01:25:54 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2021-06-28 02:59:34 +0900 |
commit | f4bbd20fb97d6b91c9a53492fd945a4ac7ff4e5f (patch) | |
tree | d7c34a9521e130c6181e96d904fc02ef922e5991 /spec/lexer_test.go | |
parent | Add syntax of fragment (diff) | |
download | cotia-f4bbd20fb97d6b91c9a53492fd945a4ac7ff4e5f.tar.gz cotia-f4bbd20fb97d6b91c9a53492fd945a4ac7ff4e5f.tar.xz |
Add ast action
Diffstat (limited to 'spec/lexer_test.go')
-rw-r--r-- | spec/lexer_test.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/spec/lexer_test.go b/spec/lexer_test.go index 7701ce7..bd7fbf0 100644 --- a/spec/lexer_test.go +++ b/spec/lexer_test.go @@ -14,7 +14,7 @@ func TestLexer_Run(t *testing.T) { }{ { caption: "the lexer can recognize all kinds of tokens", - src: `id"terminal":|;@#`, + src: `id"terminal":|;@#'()$1...`, tokens: []*token{ newIDToken("id"), newTerminalPatternToken("terminal"), @@ -23,6 +23,10 @@ func TestLexer_Run(t *testing.T) { newSymbolToken(tokenKindSemicolon), newSymbolToken(tokenKindModifierMarker), newSymbolToken(tokenKindActionLeader), + newSymbolToken(tokenKindTreeNodeOpen), + newSymbolToken(tokenKindTreeNodeClose), + newPositionToken(1), + newSymbolToken(tokenKindExpantion), newEOFToken(), }, }, @@ -68,6 +72,11 @@ bar // This is the fourth comment. err: synErrIncompletedEscSeq, }, { + caption: "a position must be greater than or equal to 1", + src: `$0`, + err: synErrZeroPos, + }, + { caption: "the lexer can recognize valid tokens following an invalid token", src: `abc!!!def`, tokens: []*token{ @@ -123,7 +132,7 @@ bar // This is the fourth comment. func testToken(t *testing.T, tok, expected *token) { t.Helper() - if tok.kind != expected.kind || tok.text != expected.text { + if tok.kind != expected.kind || tok.text != expected.text || tok.num != expected.num { t.Fatalf("unexpected token; want: %+v, got: %+v", expected, tok) } } |