From 1d831059fa02fdd21280819d9c0934f1b8b0470e Mon Sep 17 00:00:00 2001 From: David Declerck Date: Wed, 19 Jun 2024 13:20:31 +0200 Subject: [PATCH] Merge SVN 4645 --- cobc/ChangeLog | 5 ++ cobc/parser.y | 46 +++++++++++ cobc/pplex.l | 42 +++++++--- config/bs2000-strict.conf | 2 +- config/rm-strict.conf | 2 +- tests/testsuite.src/syn_misc.at | 139 ++++++++++++++++++++++++++++++++ 6 files changed, 222 insertions(+), 14 deletions(-) diff --git a/cobc/ChangeLog b/cobc/ChangeLog index 63716636c..eb4b4f1e6 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -246,6 +246,11 @@ * cobc.c: drop source format-related macros * cobc.c (cobc_print_info): silence a warning with string indexing +2022-07-05 Nicolas Berthier + + * pplex.l, parser.y: parse DISPLAY and ACCEPT statements in DEFAULT + SECTION (GCOS 7 extension) + 2022-07-04 Nicolas Berthier FR #29 support for ACUCOBOL-GT Terminal format diff --git a/cobc/parser.y b/cobc/parser.y index 38ffc563f..3eaf950e5 100644 --- a/cobc/parser.y +++ b/cobc/parser.y @@ -3372,6 +3372,7 @@ nested_list: depth = 0; setup_from_identification = 0; } + _control_division /* GCOS extension */ source_element_list ; @@ -3559,6 +3560,51 @@ _prototype_procedure_division_header: } ; +/* CONTROL DIVISION (GCOS extension) */ + +_control_division: + /* empty */ +| CONTROL DIVISION TOK_DOT + { + cb_verify (cb_control_division, "CONTROL DIVISION"); + } + _default_section +; + +_default_section: + /* empty */ +| DEFAULT SECTION TOK_DOT + _default_clauses + { + cobc_cs_check = 0; + } +; + +_default_clauses: + /*empty*/ +| _default_accept_clause + _default_display_clause + TOK_DOT +; + +_default_accept_clause: + /* empty */ +| ACCEPT _is word_or_terminal + { + CB_PENDING ("ACCEPT statement in DEFAULT SECTION"); + /* TODO: setup_default_accept ($3); */ + } +; + +_default_display_clause: + /* empty */ +| DISPLAY _is word_or_terminal + { + CB_PENDING ("DISPLAY statement in DEFAULT SECTION"); + /* TODO: setup_default_display ($3); */ + } +; + /* PROGRAM body */ _program_body: diff --git a/cobc/pplex.l b/cobc/pplex.l index 97a79f755..dd42e73a4 100644 --- a/cobc/pplex.l +++ b/cobc/pplex.l @@ -459,34 +459,52 @@ DEFNUM_LITERAL [+-]?[0-9]*[\.]*[0-9]+ "CONTROL"[ ,;\n]+"DIVISION" { /* Syntax extension for GCOS: such a division may include a SUBSTITUTION SECTION that records source text replacement statements, along with a - DEFAULT SECTION where compile-time implicits are defined. */ - /* cf `ppparse.y`, grammar entry `program_with_control_division`. */ - cb_verify (cb_control_division, "CONTROL DIVISION"); + DEFAULT SECTION where compile-time defaults are specified. */ + /* cf `ppparse.y`, grammar entry `program_with_control_division`, along + with `parser.y`, entry `_control_division`. */ + ppecho (yytext, 0, (int)yyleng); yy_push_state (CONTROL_DIVISION_STATE); return CONTROL_DIVISION; } -"SUBSTITUTION"[ ,;\n]+"SECTION" { - yy_push_state (SUBSTITUTION_SECTION_STATE); - return SUBSTITUTION_SECTION; +{ + "SUBSTITUTION"[ ,;\n]+"SECTION" { + yy_push_state (SUBSTITUTION_SECTION_STATE); + return SUBSTITUTION_SECTION; + } + \. { + /* Pass dots to the parser to handle DEFAULT SECTION. */ + ppecho (yytext, 0, (int)yyleng); + return DOT; + } } -"REPLACE" { - yy_push_state (COPY_STATE); - return REPLACE; +{ + "REPLACE" { + yy_push_state (COPY_STATE); + return REPLACE; + } + \. { + /* Intercept dots within the SUBSTITUTION SECTION */ + return DOT; + } } { + "DEFAULT"[ ,;\n]+"SECTION" { + /* Pop any control division-related start condition state. */ + while (YY_START == CONTROL_DIVISION_STATE || + YY_START == SUBSTITUTION_SECTION_STATE) + yy_pop_state (); + ppecho (yytext, 0, (int)yyleng); + } [,;]?\n { ECHO; check_listing (yytext, 0); cb_source_line++; } [,;]?[ ]+ { /* ignore */ } - \. { - return DOT; - } }