Skip to content

Commit b4c3566

Browse files
committed
Add _specification_parts as supertype
1 parent 614162a commit b4c3566

File tree

4 files changed

+692163
-593434
lines changed

4 files changed

+692163
-593434
lines changed

grammar.js

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ module.exports = grammar({
104104
],
105105

106106
supertypes: $ => [
107+
$._specification_parts,
107108
$._expression,
108109
$._statements,
109110
$._argument_item,
@@ -534,27 +535,13 @@ module.exports = grammar({
534535
// Variable Declarations
535536

536537
_specification_part: $ => prec(1, choice(
537-
$.include_statement,
538-
seq($.use_statement, $._end_of_statement),
539-
seq($.implicit_statement, $._end_of_statement),
540-
seq($.save_statement, $._end_of_statement),
541-
seq($.import_statement, $._end_of_statement),
542-
$.public_statement,
543-
$.private_statement,
544-
$.enum,
545-
$.enumeration_type,
546-
$.interface,
547-
$.derived_type_definition,
548-
seq($.namelist_statement, $._end_of_statement),
549-
seq($.common_statement, $._end_of_statement),
550-
seq($.variable_declaration, $._end_of_statement),
551-
seq($.variable_modification, $._end_of_statement),
552-
seq($.parameter_statement, $._end_of_statement),
553-
seq($.equivalence_statement, $._end_of_statement),
554-
seq($.data_statement, $._end_of_statement),
538+
// Split out so it can be used as a supertype
539+
$._specification_parts,
540+
// This catches statement functions, which are completely ambiguous
555541
seq($.assignment_statement, $._end_of_statement),
542+
// This allows format statements in the specification part,
543+
// without making the statements rule particularly awkward
556544
prec(1, seq($.statement_label, $.format_statement, $._end_of_statement)),
557-
$.cray_pointer_declaration,
558545
$.preproc_include,
559546
$.preproc_def,
560547
$.preproc_function_def,
@@ -564,6 +551,28 @@ module.exports = grammar({
564551
';',
565552
)),
566553

554+
_specification_parts: $ => prec(1, choice(
555+
$.include_statement,
556+
$.use_statement,
557+
$.implicit_statement,
558+
$.save_statement,
559+
$.import_statement,
560+
$.public_statement,
561+
$.private_statement,
562+
$.enum,
563+
$.enumeration_type,
564+
$.interface,
565+
$.derived_type_definition,
566+
$.namelist_statement,
567+
$.common_statement,
568+
$.variable_declaration,
569+
$.variable_modification,
570+
$.parameter_statement,
571+
$.equivalence_statement,
572+
$.data_statement,
573+
$.cray_pointer_declaration,
574+
)),
575+
567576
use_statement: $ => seq(
568577
caseInsensitive('use'),
569578
choice(
@@ -578,7 +587,8 @@ module.exports = grammar({
578587
seq(',', commaSep1($.use_alias)),
579588
$.included_items
580589
)
581-
)
590+
),
591+
$._end_of_statement,
582592
),
583593

584594
included_items: $ => seq(
@@ -619,7 +629,8 @@ module.exports = grammar({
619629
')'
620630
))
621631
)
622-
)
632+
),
633+
$._end_of_statement
623634
),
624635

625636
save_statement: $ => prec(1, seq(
@@ -630,7 +641,8 @@ module.exports = grammar({
630641
$.identifier,
631642
seq('/', $.identifier, '/'),
632643
)),
633-
))
644+
)),
645+
$._end_of_statement,
634646
)),
635647

636648
private_statement: $ => prec.right(1, seq(
@@ -653,15 +665,17 @@ module.exports = grammar({
653665

654666
namelist_statement: $ => seq(
655667
caseInsensitive('namelist'),
656-
repeat1($.variable_group)
668+
repeat1($.variable_group),
669+
$._end_of_statement
657670
),
658671

659672
common_statement: $ => seq(
660673
caseInsensitive('common'),
661674
repeat1(choice(
662675
$.variable_group,
663676
commaSep1($._variable_declarator)
664-
))
677+
)),
678+
$._end_of_statement
665679
),
666680

667681
variable_group: $ => seq(
@@ -678,7 +692,8 @@ module.exports = grammar({
678692

679693
import_statement: $ => prec.left(seq(
680694
caseInsensitive('import'),
681-
optional($._import_names)
695+
optional($._import_names),
696+
$._end_of_statement
682697
)),
683698
_import_names: $ => choice(
684699
seq(optional('::'), commaSep1($.identifier)),
@@ -701,7 +716,7 @@ module.exports = grammar({
701716
$._end_of_statement
702717
),
703718
$.include_statement,
704-
seq($.variable_declaration, $._end_of_statement),
719+
$.variable_declaration,
705720
$.preproc_include,
706721
$.preproc_def,
707722
$.preproc_function_def,
@@ -825,7 +840,8 @@ module.exports = grammar({
825840
)
826841
)),
827842
optional('::'),
828-
$._declaration_targets
843+
$._declaration_targets,
844+
$._end_of_statement
829845
),
830846

831847
procedure_declaration: $ => seq(
@@ -844,6 +860,7 @@ module.exports = grammar({
844860
)),
845861
optional('::'),
846862
commaSep1(field('declarator', $._variable_declarator)),
863+
$._end_of_statement,
847864
),
848865

849866
variable_attributes: $ => seq(
@@ -1024,14 +1041,16 @@ module.exports = grammar({
10241041
caseInsensitive('parameter'),
10251042
'(',
10261043
commaSep1($.parameter_assignment),
1027-
')'
1044+
')',
1045+
$._end_of_statement
10281046
)),
10291047

10301048
parameter_assignment: $ => seq($.identifier, '=', $._expression),
10311049

10321050
equivalence_statement: $ => seq(
10331051
caseInsensitive('equivalence'),
1034-
commaSep1($.equivalence_set)
1052+
commaSep1($.equivalence_set),
1053+
$._end_of_statement,
10351054
),
10361055

10371056
equivalence_set: $ => seq(
@@ -1189,7 +1208,8 @@ module.exports = grammar({
11891208

11901209
data_statement: $ => seq(
11911210
caseInsensitive('data'),
1192-
sep1($.data_set, optional(','))
1211+
sep1($.data_set, optional(',')),
1212+
$._end_of_statement,
11931213
),
11941214
data_set: $ => prec(1, seq(
11951215
commaSep1(

0 commit comments

Comments
 (0)