Skip to content

Commit 92952ed

Browse files
committed
Allow fmt argument without keyword argument
It turns out that Fortran allows the `fmt` argument to IO routines as the second argument without `fmt=`, even if the first argument _does_ have `unit=` Closes stadelmanma#40
1 parent 1333cf5 commit 92952ed

File tree

5 files changed

+489867
-484497
lines changed

5 files changed

+489867
-484497
lines changed

grammar.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ module.exports = grammar({
101101
[$._inline_if_statement, $.arithmetic_if_statement, $._block_if_statement, $.identifier],
102102
[$.file_position_statement, $.identifier],
103103
[$.cray_pointer_declaration, $.identifier],
104+
[$.unit_identifier, $.identifier],
104105
],
105106

106107
supertypes: $ => [
@@ -1759,14 +1760,20 @@ module.exports = grammar({
17591760
),
17601761

17611762
// precedence is used to override a conflict with the complex literal
1762-
unit_identifier: $ => prec(1, choice(
1763-
$.number_literal,
1764-
$._io_expressions
1765-
)),
1763+
unit_identifier: $ => seq(
1764+
optional(seq(caseInsensitive('unit'), '=')),
1765+
prec(1, choice(
1766+
$.number_literal,
1767+
$._io_expressions
1768+
))
1769+
),
17661770

1767-
format_identifier: $ => choice(
1768-
$.statement_label_reference,
1769-
$._io_expressions
1771+
format_identifier: $ => seq(
1772+
optional(seq(caseInsensitive('fmt'), '=')),
1773+
choice(
1774+
$.statement_label_reference,
1775+
$._io_expressions
1776+
)
17701777
),
17711778

17721779
_file_position_spec: $ => choice(
@@ -2326,6 +2333,7 @@ module.exports = grammar({
23262333
caseInsensitive('target'),
23272334
caseInsensitive('texture'),
23282335
prec(-1, caseInsensitive('type')),
2336+
caseInsensitive('unit'),
23292337
caseInsensitive('unlock'),
23302338
caseInsensitive('value'),
23312339
caseInsensitive('wait'),

0 commit comments

Comments
 (0)