Skip to content

Commit

Permalink
Merge SVN 4685
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Jun 22, 2024
1 parent d0c72fd commit 0ddd8a4
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 14 deletions.
10 changes: 9 additions & 1 deletion cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@
* field.c (has_std_needed_screen_clause), typeck.c (validate_alphabet),
codegen.c (output_initialize_one): minor refactorings

2022-08-20 Simon Sobisch <simonsobisch@gnu.org>

* pplex.l: match and ignore editor folding $REGION statement
* pplex.l: output actual directive for @OPTIONS and PROCESS
* pplex.l: *CONTROL from col7+
* pparse.y: don't warn on *CONTROL as this adjust listing only
and does not apply directly (possibly real handling later)

2022-07-29 Nicolas Berthier <nicolas.berthier@ocamlpro.com>

* flag.def, config.def: make format a dialect option instead of a flag
Expand Down Expand Up @@ -5627,7 +5635,7 @@
* tree.h: new field flag_unbounded for OCCURS ... TO UNBOUNDED
* cobc.h: added CB_CS_OCCURS
* reserved.c: added UNBOUNDED as context sensitive reserved word for OCCURS
* parser.y: added token UNBOUNDED and first attemt for adding
* parser.y: added token UNBOUNDED and first attemt to add
OCCURS ... TO UNBOUNDED in the parser

2016-08-13 Simon Sobisch <simonsobisch@gnu.org>
Expand Down
31 changes: 25 additions & 6 deletions cobc/pplex.l
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,12 @@ DEFNUM_LITERAL [+-]?[0-9]*[\.]*[0-9]+
BEGIN ENDIF_DIRECTIVE_STATE;
return ENDIF_DIRECTIVE;
}
^[ ]*"$REGION" |
^[ ]*"$END-$REGION" {
/* MF extension for logical marking of a block in the editor */
/* _possibly_ check: MF rule "$REGION and $IF statements must not overlap." */
skip_to_eol ();
}

^[ ]*"$"[_0-9A-Z-]+ {
/* unknown MF style directive */
Expand All @@ -404,7 +410,7 @@ DEFNUM_LITERAL [+-]?[0-9]*[\.]*[0-9]+
skip_to_eol ();
}

^......."@OPTIONS" {
^......."@OPTIONS"[ ][A-Z0-9() ,;'"=]* {
/* Fujitsu COBOL extension for specifying command line options */
/* TODO: check position of the @OPTIONS directive */
char *s = strchr (yytext, '@');
Expand All @@ -413,11 +419,24 @@ DEFNUM_LITERAL [+-]?[0-9]*[\.]*[0-9]+
skip_to_eol ();
}

^[ ]*("PROCESS"|"CBL")/[ ,;\n] {
^[ ]*("PROCESS"|"CBL")[ ,;]*[\n] {
/* IBM COBOL extension for specifying compiler options */
/* TODO: The CBL (PROCESS) statement must be placed before any comment lines or other compiler-directing statements. */
/* TODO: The CBL (PROCESS) statement must be placed before any
comment lines, IDENTIFICATIO DIVISION, or other
compiler-directing statements. */
/* empty - so ignored */
skip_to_eol ();
}

^[ ]*("PROCESS"|"CBL")[ ][A-Z0-9() ,;'"=]* {
/* IBM COBOL extension for specifying compiler options */
/* TODO: The CBL (PROCESS) statement must be placed before any
comment lines, IDENTIFICATIO DIVISION, or other
compiler-directing statements. */
char *s = yytext;
while (*s == ' ') s++;
cb_plex_warning (COBC_WARN_FILLER, newline_count - 1,
_("PROCESS statement ignored"));
_("ignoring unknown directive: '%s'"), s);
skip_to_eol ();
}

Expand Down Expand Up @@ -450,8 +469,8 @@ DEFNUM_LITERAL [+-]?[0-9]*[\.]*[0-9]+
return REPLACE;
}

^[ ]*"*CONTROL" |
^[ ]*"*CBL" {
^......[ ]*"*CONTROL" |
^......[ ]*"*CBL" {
BEGIN CONTROL_STATEMENT_STATE;
return CONTROL_STATEMENT;
}
Expand Down
3 changes: 0 additions & 3 deletions cobc/ppparse.y
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,6 @@ statement_no_replace:
| directive TERMINATOR
| listing_statement
| CONTROL_STATEMENT control_options _dot TERMINATOR
{
CB_PENDING (_("*CONTROL statement"));
}
;

directive:
Expand Down
108 changes: 104 additions & 4 deletions tests/testsuite.src/syn_misc.at
Original file line number Diff line number Diff line change
Expand Up @@ -6993,18 +6993,20 @@ AT_CLEANUP


AT_SETUP([@OPTIONS parsing])
AT_KEYWORDS([misc OPTIONS])
AT_KEYWORDS([misc OPTIONS fujitsu])

# GnuCOBOL currently only skips these, see FR 305

AT_DATA([valid.cob], [
000100 @OPTIONS NOMAIN,APOST
000200 IDENTIFICATION DIVISION.
000300 PROGRAM-ID. VALID.
000200 @OPTIONS APOST
000300 IDENTIFICATION DIVISION.
000400 PROGRAM-ID. VALID.
])

AT_CHECK([$COMPILE_ONLY valid.cob], [0], [],
[valid.cob:2: warning: ignoring unknown directive: '@OPTIONS'
[valid.cob:2: warning: ignoring unknown directive: '@OPTIONS NOMAIN,APOST'
valid.cob:3: warning: ignoring unknown directive: '@OPTIONS APOST'
])

#AT_DATA([invalid.cob], [
Expand Down Expand Up @@ -7034,6 +7036,104 @@ AT_CHECK([$COMPILE_ONLY valid.cob], [0], [],
AT_CLEANUP


AT_SETUP([PROCESS / CBL parsing])
AT_KEYWORDS([misc ibm])

# GnuCOBOL currently only skips these, see FR 305

#AT_DATA([valid.cob], [
#Process codepage(1047)
#CBL CODEPAGE(1047)
#Process
# Process codepage(1208)
# CBL CODEPAGE(1208)
#000100 Process codepage(1047)
#000200 CBL CODEPAGE(1047)
#000300 CBL
#000400 IDENTIFICATION DIVISION.
#000500 PROGRAM-ID. VALID.
#])
#
#AT_CHECK([$COMPILE_ONLY valid.cob], [0], [],
#[valid.cob:2: warning: ignoring unknown directive: 'Process codepage(1047)'
#valid.cob:3: warning: ignoring unknown directive: 'CBL CODEPAGE(1047)'
#valid.cob:5: warning: ignoring unknown directive: 'Process codepage(1208)'
#valid.cob:6: warning: ignoring unknown directive: 'CBL CODEPAGE(1208)'
#valid.cob:7: warning: ignoring unknown directive: 'Process codepage(1047)'
#valid.cob:8: warning: ignoring unknown directive: 'CBL CODEPAGE(1047)'
#])

# FIXME: the part above does not work

#AT_DATA([valid.cob], [
#Process codepage(1047)
# Process
# CBL
#000100 Process codepage(1208)
#000200 CBL CODEPAGE(1208)
#000300 CBL
#000400 IDENTIFICATION DIVISION.
#000500 PROGRAM-ID. VALID.
#])

#AT_CHECK([$COMPILE_ONLY valid.cob], [0], [],
#[valid.cob:2: warning: ignoring unknown directive: 'Process codepage(1047)'
#valid.cob:5: warning: ignoring unknown directive: 'Process codepage(1208)'
#valid.cob:6: warning: ignoring unknown directive: 'CBL CODEPAGE(1208)'
#])

# simple one, to consider later how to make the necessary changes for
# process/cbl before col 7

AT_DATA([valid.cob], [
000100 Process codepage(1047)
000200 CBL CODEPAGE(1208)
000300 CBL
000400 IDENTIFICATION DIVISION.
000500 PROGRAM-ID. VALID.
])

AT_CHECK([$COMPILE_ONLY valid.cob], [0], [],
[valid.cob:2: warning: ignoring unknown directive: 'Process codepage(1047)'
valid.cob:3: warning: ignoring unknown directive: 'CBL CODEPAGE(1208)'
])

AT_CLEANUP


AT_SETUP([*CONTROL / *CBL parsing])
AT_KEYWORDS([misc ibm])

#AT_DATA([valid.cob], [
# *CONTROL LIST
# *CONTROL SOURCE
# *CBL MAP LIST
#000100 *CBL NOMAP NOSOURCE NOLIST
#000200 IDENTIFICATION DIVISION.
#000300 PROGRAM-ID. VALID.
#])

#AT_CHECK([$COMPILE_ONLY valid.cob], [0], [],
#[valid.cob:2: warning: LIST is not applicable, consider -g / -s
#valid.cob:4: warning: LIST is not applicable, consider -g / -s
#])

# for now only simple one -> ignored

AT_DATA([valid.cob], [
*CONTROL LIST
*CONTROL SOURCE
*CBL MAP LIST
000100 *CBL NOMAP NOSOURCE NOLIST
000200 IDENTIFICATION DIVISION.
000300 PROGRAM-ID. VALID.
])

AT_CHECK([$COMPILE_ONLY valid.cob], [0], [], [])

AT_CLEANUP


AT_SETUP([system routines with wrong number of parameters])
AT_KEYWORDS([misc CALL 91 C$TOUPPER CBL_GC_FORK])

Expand Down

0 comments on commit 0ddd8a4

Please sign in to comment.