From f4bbd20fb97d6b91c9a53492fd945a4ac7ff4e5f Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Mon, 28 Jun 2021 01:25:54 +0900 Subject: Add ast action --- spec/lexer_test.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'spec/lexer_test.go') 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(), }, }, @@ -67,6 +71,11 @@ bar // This is the fourth comment. src: `"\`, 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`, @@ -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) } } -- cgit v1.2.3