]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cobol: Relax parsing restrictions for void sentences and MF $END-IF.
authorJames K. Lowden <jklowden@cobolworx.com>
Thu, 30 Jul 2026 19:16:39 +0000 (15:16 -0400)
committerJames K. Lowden <jklowden@cobolworx.com>
Thu, 30 Jul 2026 19:17:07 +0000 (15:17 -0400)
Accept multiple consecutive periods as empty statements.  Accept
undocumented $END-IF under -dialect mf without comment.

gcc/cobol/ChangeLog:

PR cobol/126495
PR cobol/126496
* gcobol.1: Update manual to reflect new syntax.
* parse.y: Allow void sentence and increment s/r expected count to 7.
* scan.l: Lex $END-IF, optionally, as $END.

gcc/cobol/gcobol.1
gcc/cobol/parse.y
gcc/cobol/scan.l

index aff6c1c7431e34e13750a3818fcb07a549af9c87..36addddeb89fb0a6dc19f8aa6f2b6a615db6c58b 100644 (file)
@@ -491,6 +491,9 @@ to indicate GnuCOBOL syntax, generally compatible with MicroFocus.
 to indicate MicroFocus syntax:
 .Bl -bullet -compact
 .It
+CDF
+.Sy $IF , $ELSE , $END , Sy $END-IF , Li and Sy $SET
+.It
 .Sy BINARY-LONG-LONG
 .It
 .Sy CALL ... GIVING
index d6cd656085bb98f5b4ba7a371ab8cb49291692f8..13a94ffc59ef2c8e9c1479a7c986aefa6acf43e4 100644 (file)
@@ -730,7 +730,7 @@ class locale_tgt_t {
     // https://savannah.gnu.org/forum/forum.php?forum_id=9735
 %token  YYEOF 0 "end of file"
 
-%type   <number>        sentence statements statement
+%type   <number>        statements statement
 %type   <number>        star_cbl_opt close_how
 
 %type   <number>        test_before usage_clause1 might_be alphanational
@@ -1566,7 +1566,7 @@ class locale_tgt_t {
 %locations
 %token-table
 %define parse.error verbose // custom
-%expect 6
+%expect 7
 %require "3.5.1"  //    3.8.2 also works, but not 3.8.0
 %%
 
@@ -5691,7 +5691,8 @@ paragraph_name: NAME
         |       NUMSTR { $$ = $1.string; }
                ;
 
-sentence:       statements  '.'
+sentence:       '.'
+        |       statements  '.'
         |       statements  YYEOF
                 {
                   if( ! goodnight_gracie() ) {
index 67bdefa91dc86f698edec1c401e211efd46ae243..278cad8b1545f8d4ca3aecf94f2c50b0f8d9edb5 100644 (file)
@@ -2439,7 +2439,7 @@ BASIS             { yy_push_state(basis); return BASIS; }
                                  yy_push_state(cdf_state); return CDF_IF; }
   ^[ ]*[$]{OBLANK}ELSE         { dialect_ok(yylloc, MfCdfDollar, yytext); 
                                  return CDF_ELSE; }
-  ^[ ]*[$]{OBLANK}END          { dialect_ok(yylloc, MfCdfDollar, yytext); 
+  ^[ ]*[$]{OBLANK}END(-IF)?    { dialect_ok(yylloc, MfCdfDollar, yytext); 
                                  return CDF_END_IF; }
 
   ^[ ]*[$]{OBLANK}SET({SPC}CONSTANT)? {