From c7ae8cd1d33d6b82d022628112ceb6c64d37194a Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Wed, 28 Jul 2021 21:55:43 +0900 Subject: Count the number of each line in consecutive lines --- spec/parser_test.go | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'spec/parser_test.go') diff --git a/spec/parser_test.go b/spec/parser_test.go index 1c99716..29d9051 100644 --- a/spec/parser_test.go +++ b/spec/parser_test.go @@ -219,6 +219,58 @@ fragment words: "[A-Za-z\u{0020}]+"; }, }, }, + { + caption: "the lexer treats consecutive lines as a single token but can count lines correctly", + src: `// This line precedes line comments and blank lines. +// This is a line comment. + + +s + : foo + ; + + +// This line is sandwiched between blank lines. + + +foo: 'foo'; +`, + checkPosition: true, + ast: &RootNode{ + Productions: []*ProductionNode{ + withProdPos( + prod("s", + withAltPos( + alt( + withElemPos( + id("foo"), + newPosition(6), + ), + ), + newPosition(6), + ), + ), + newPosition(5), + ), + }, + LexProductions: []*ProductionNode{ + withProdPos( + prod("foo", + withAltPos( + alt( + withElemPos( + pat(`foo`), + newPosition(13), + ), + ), + newPosition(13), + ), + ), + newPosition(13), + ), + }, + }, + }, { caption: "a grammar can contain production directives and alternative directives", src: ` -- cgit v1.2.3