|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?I=C3=B1aki=20Amatria=20Barral?= < [email protected]> |
| 3 | +Date: Wed, 25 Jun 2025 15:37:31 +0200 |
| 4 | +Subject: Allow `identifier`s in `data_value`'s `repeat`s |
| 5 | + |
| 6 | +As seen in |
| 7 | +https://github.com/llvm/llvm-project/blob/llvmorg-20.1.6/flang/lib/Parser/Fortran-parsers.cpp#L913-L915. |
| 8 | +--- |
| 9 | + grammar.js | 4 +++- |
| 10 | + test/corpus/statements.txt | 12 ++++++++++++ |
| 11 | + 2 files changed, 15 insertions(+), 1 deletion(-) |
| 12 | + |
| 13 | +diff --git a/grammar.js b/grammar.js |
| 14 | +index 80bc23a..6e79004 100644 |
| 15 | +--- a/grammar.js |
| 16 | ++++ b/grammar.js |
| 17 | +@@ -1273,7 +1273,9 @@ module.exports = grammar({ |
| 18 | + data_value: $ => seq( |
| 19 | + '/', |
| 20 | + commaSep1(seq( |
| 21 | +- optional(prec(1, seq(field('repeat', $.number_literal), '*'))), |
| 22 | ++ optional(prec(1, |
| 23 | ++ seq(field('repeat', choice($.number_literal, $.identifier)), '*') |
| 24 | ++ )), |
| 25 | + choice( |
| 26 | + $.number_literal, |
| 27 | + $.complex_literal, |
| 28 | +diff --git a/test/corpus/statements.txt b/test/corpus/statements.txt |
| 29 | +index 7948402..41a00f8 100644 |
| 30 | +--- a/test/corpus/statements.txt |
| 31 | ++++ b/test/corpus/statements.txt |
| 32 | +@@ -2842,6 +2842,7 @@ program test |
| 33 | + DATA array(:, N) / & |
| 34 | + 54.45_fp, 200.01_fp / |
| 35 | + DATA complex_array / ( 0, 1 ), ( 1, 0 ) / |
| 36 | ++ DATA foo / 3 * 0.0, 4 * bar, 1.0, 2.0 / |
| 37 | + data params/ param1, param2/ |
| 38 | + |
| 39 | + ! This is awful, but this makes sure the specification part has |
| 40 | +@@ -2949,6 +2950,17 @@ end program test |
| 41 | + (number_literal) |
| 42 | + (number_literal))))) |
| 43 | + (end_of_statement) |
| 44 | ++ (data_statement |
| 45 | ++ (data_set |
| 46 | ++ (identifier) |
| 47 | ++ (data_value |
| 48 | ++ (number_literal) |
| 49 | ++ (number_literal) |
| 50 | ++ (number_literal) |
| 51 | ++ (identifier) |
| 52 | ++ (number_literal) |
| 53 | ++ (number_literal)))) |
| 54 | ++ (end_of_statement) |
| 55 | + (data_statement |
| 56 | + (data_set |
| 57 | + (identifier) |
0 commit comments