Skip to content

Commit 8696854

Browse files
committed
Allow identifiers in data_value's repeats
1 parent 0e1ea74 commit 8696854

File tree

5 files changed

+44
-9
lines changed

5 files changed

+44
-9
lines changed

grammar.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,9 @@ module.exports = grammar({
12401240
data_value: $ => seq(
12411241
'/',
12421242
commaSep1(seq(
1243-
optional(prec(1, seq(field('repeat', $.number_literal), '*'))),
1243+
optional(prec(1,
1244+
seq(field('repeat', choice($.number_literal, $.identifier)), '*')
1245+
)),
12441246
choice(
12451247
$.number_literal,
12461248
$.complex_literal,

src/grammar.json

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13933,8 +13933,17 @@
1393313933
"type": "FIELD",
1393413934
"name": "repeat",
1393513935
"content": {
13936-
"type": "SYMBOL",
13937-
"name": "number_literal"
13936+
"type": "CHOICE",
13937+
"members": [
13938+
{
13939+
"type": "SYMBOL",
13940+
"name": "number_literal"
13941+
},
13942+
{
13943+
"type": "SYMBOL",
13944+
"name": "identifier"
13945+
}
13946+
]
1393813947
}
1393913948
},
1394013949
{
@@ -14018,8 +14027,17 @@
1401814027
"type": "FIELD",
1401914028
"name": "repeat",
1402014029
"content": {
14021-
"type": "SYMBOL",
14022-
"name": "number_literal"
14030+
"type": "CHOICE",
14031+
"members": [
14032+
{
14033+
"type": "SYMBOL",
14034+
"name": "number_literal"
14035+
},
14036+
{
14037+
"type": "SYMBOL",
14038+
"name": "identifier"
14039+
}
14040+
]
1402314041
}
1402414042
},
1402514043
{

src/node-types.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,10 @@
18261826
"multiple": true,
18271827
"required": false,
18281828
"types": [
1829+
{
1830+
"type": "identifier",
1831+
"named": true
1832+
},
18291833
{
18301834
"type": "number_literal",
18311835
"named": true

src/parser.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546329,7 +546329,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
546329546329
[sym_string_literal] = STATE(5676),
546330546330
[sym_coarray_expression] = STATE(4543),
546331546331
[sym_conditional_expression] = STATE(4543),
546332-
[sym_identifier] = STATE(5676),
546332+
[sym_identifier] = STATE(5679),
546333546333
[anon_sym_LPAREN2] = ACTIONS(17),
546334546334
[anon_sym_PLUS] = ACTIONS(5865),
546335546335
[anon_sym_DASH] = ACTIONS(5865),
@@ -547185,7 +547185,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
547185547185
[sym_string_literal] = STATE(5386),
547186547186
[sym_coarray_expression] = STATE(4543),
547187547187
[sym_conditional_expression] = STATE(4543),
547188-
[sym_identifier] = STATE(5386),
547188+
[sym_identifier] = STATE(5387),
547189547189
[anon_sym_LPAREN2] = ACTIONS(17),
547190547190
[anon_sym_PLUS] = ACTIONS(5865),
547191547191
[anon_sym_DASH] = ACTIONS(5865),
@@ -547506,7 +547506,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
547506547506
[sym_string_literal] = STATE(5428),
547507547507
[sym_coarray_expression] = STATE(4543),
547508547508
[sym_conditional_expression] = STATE(4543),
547509-
[sym_identifier] = STATE(5428),
547509+
[sym_identifier] = STATE(5429),
547510547510
[anon_sym_LPAREN2] = ACTIONS(17),
547511547511
[anon_sym_PLUS] = ACTIONS(5865),
547512547512
[anon_sym_DASH] = ACTIONS(5865),
@@ -547613,7 +547613,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
547613547613
[sym_string_literal] = STATE(5484),
547614547614
[sym_coarray_expression] = STATE(4543),
547615547615
[sym_conditional_expression] = STATE(4543),
547616-
[sym_identifier] = STATE(5484),
547616+
[sym_identifier] = STATE(5485),
547617547617
[anon_sym_LPAREN2] = ACTIONS(17),
547618547618
[anon_sym_PLUS] = ACTIONS(5865),
547619547619
[anon_sym_DASH] = ACTIONS(5865),

test/corpus/statements.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,6 +2471,7 @@ program test
24712471
DATA array(:, N) / &
24722472
54.45_fp, 200.01_fp /
24732473
DATA complex_array / ( 0, 1 ), ( 1, 0 ) /
2474+
DATA foo / 3 * 0.0, 4 * bar, 1.0, 2.0 /
24742475
data params/ param1, param2/
24752476

24762477
! This is awful, but this makes sure the specification part has
@@ -2569,6 +2570,16 @@ end program test
25692570
(complex_literal
25702571
(number_literal)
25712572
(number_literal)))))
2573+
(data_statement
2574+
(data_set
2575+
(identifier)
2576+
(data_value
2577+
(number_literal)
2578+
(number_literal)
2579+
(number_literal)
2580+
(identifier)
2581+
(number_literal)
2582+
(number_literal))))
25722583
(data_statement
25732584
(data_set
25742585
(identifier)

0 commit comments

Comments
 (0)