Skip to content

Commit f1cd64d

Browse files
author
rasmussn
committed
Modified handling of free-form comments to remove ambiguity with statements.
1 parent 60f5df2 commit f1cd64d

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

fortran/syntax/FixedForm.sdf

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ exports
55
sorts
66

77
EOL WS DIGIT LETTER CHARS
8-
LABEL LABELTAB START TABSTART
8+
LABEL LABELTAB START TABSTART BANGSTART
99
STARTCHAR CONTCHAR COMMENTCHAR BANGCHAR PRECHAR
1010
StartChar ContChar CommentChar BangChar PreChar NoChar Eol OptWS
1111
BlankLine CommentLine Continuation FollowLine PreprocessLine Stmt
12-
InitialComment StmtBlock File Text
12+
InitialComment CommentText StmtBlock File Text
1313

1414
context-free start-symbols
1515

@@ -35,6 +35,14 @@ exports
3535

3636
[cC\*\!] -> COMMENTCHAR
3737

38+
%% free-form commentary
39+
40+
%% [\!] -> BANGSTART %% ambiguous with fixed-form commentary
41+
[\ ][\!] -> BANGSTART
42+
[\ ][\ ][\!] -> BANGSTART
43+
[\ ][\ ][\ ][\!] -> BANGSTART
44+
[\ ][\ ][\ ][\ ][\!] -> BANGSTART
45+
3846
%% start of a non-labeled statement
3947

4048
[\ 0\t] -> STARTCHAR
@@ -48,7 +56,7 @@ exports
4856
[\ ][\ ][\ ][\ ][\ ] -> START
4957

5058
%% labels: max 5 digits with space in 6th pos
51-
%%
59+
5260
[0-9][\ ][\ ][\ ][\ ] -> LABEL
5361
[\ ][0-9][\ ][\ ][\ ] -> LABEL
5462
[\ ][\ ][0-9][\ ][\ ] -> LABEL
@@ -101,8 +109,6 @@ exports
101109

102110
PreChar CHARS Eol -> PreprocessLine {cons("Preprocess")}
103111
OptWS Eol -> BlankLine {cons("BlankLine")}
104-
CommentChar CHARS Eol -> CommentLine {cons("Comment")}
105-
WS BangChar CHARS Eol -> CommentLine {cons("FreeFormComment")}
106112

107113
START ContChar CHARS Eol -> Continuation {cons("Continuation")}
108114

@@ -114,8 +120,17 @@ exports
114120

115121
Stmt FollowLine* -> StmtBlock {cons("StmtBlock")}
116122

123+
% Commentary %
124+
125+
OptWS BANGCHAR CHARS -> CommentText {cons("Comment")}
126+
127+
CommentChar CHARS Eol -> CommentLine {cons("Comment")}
128+
BANGSTART CHARS Eol -> CommentLine {cons("StartFFComment")}
129+
START StartChar CommentText Eol -> CommentLine {cons("FreeFormComment")}
130+
117131

118132
CHARS -> Text
133+
OptWS BANGCHAR CHARS -> Text {reject}
119134
WS -> Text {reject}
120135
% empty % -> Text {reject}
121136

0 commit comments

Comments
 (0)