From: James K. Lowden Date: Thu, 30 Jul 2026 19:16:39 +0000 (-0400) Subject: cobol: Relax parsing restrictions for void sentences and MF $END-IF. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7a320f883fe3cbaa0ce0003d6a4eb3fc043d2e49;p=thirdparty%2Fgcc.git cobol: Relax parsing restrictions for void sentences and MF $END-IF. 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. --- diff --git a/gcc/cobol/gcobol.1 b/gcc/cobol/gcobol.1 index aff6c1c7431..36addddeb89 100644 --- a/gcc/cobol/gcobol.1 +++ b/gcc/cobol/gcobol.1 @@ -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 diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y index d6cd656085b..13a94ffc59e 100644 --- a/gcc/cobol/parse.y +++ b/gcc/cobol/parse.y @@ -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 sentence statements statement +%type statements statement %type star_cbl_opt close_how %type 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() ) { diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l index 67bdefa91dc..278cad8b154 100644 --- a/gcc/cobol/scan.l +++ b/gcc/cobol/scan.l @@ -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)? {