aboutsummaryrefslogtreecommitdiff
path: root/spec/parser_test.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2021-07-28 21:55:43 +0900
committerRyo Nihei <nihei.dev@gmail.com>2021-07-28 21:55:43 +0900
commitc7ae8cd1d33d6b82d022628112ceb6c64d37194a (patch)
tree6c72a83e64e27a88200e7651956061fcf8d0a74e /spec/parser_test.go
parentDetect duplicate production errors (diff)
downloadcotia-c7ae8cd1d33d6b82d022628112ceb6c64d37194a.tar.gz
cotia-c7ae8cd1d33d6b82d022628112ceb6c64d37194a.tar.xz
Count the number of each line in consecutive lines
Diffstat (limited to 'spec/parser_test.go')
-rw-r--r--spec/parser_test.go52
1 files changed, 52 insertions, 0 deletions
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
@@ -220,6 +220,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: `
mode_tran_seq