Skip to content

Commit

Permalink
follow-up to CONTROL check-in and minor general adjustments
Browse files Browse the repository at this point in the history
cobc:
* parser.y (display_erase, display_pos_specifier): pass display attributes to codegen
* parser.y (control_source): allow both an alphanumeric identifier or literal for use with CONTROL phrase
* cobc.c (set_category, set_category_from_usage): changed argument types from int to their matching enum
* tree.c (cb_build_prototype), parser.y (setup_prototype), tree.h (struct cb_prototype): use matching enum
* parser.y: adjust a bunch of terminals to match the internal name with leading underscore as optional

libcob:
* common.h: added COB_SCREEN_GRAPHICS attribute
* screenio.c (control_attrs): added currently not active attributes CONVERT and GRAPHICS
  • Loading branch information
sf-mensch committed May 23, 2023
1 parent 35e9533 commit 412c46a
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 64 deletions.
16 changes: 16 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@

2023-05-23 Simon Sobisch <[email protected]>

* parser.y (control_source): allow both an alphanumeric identifier or
literal for use with CONTROL phrase
* parser.y: adjust a bunch of terminals to match the internal name with
leading underscore as optional

2023-05-15 Simon Sobisch <[email protected]>

* cobc.c (set_category, set_category_from_usage): changed argument types
from int to their matching enum
* tree.c (cb_build_prototype), parser.y (setup_prototype),
tree.h (struct cb_prototype): use matching enum

2023-05-11 Simon Sobisch <[email protected]>

* cobc.c (cobc_check_valid_name): allow leading underscore,
Expand Down Expand Up @@ -254,6 +268,8 @@
* parser.y (usage_clause_screen_report), typeck.c (validate_usage): have
REPORT and SCREEN section only expecting the possibly USAGEs instead all
removing the need to check for bad USAGE later
* parser.y (display_erase, display_pos_specifier): pass display attributes
to codegen

2023-01-28 Simon Sobisch <[email protected]>

Expand Down
9 changes: 6 additions & 3 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4373,7 +4373,7 @@ process_filename (const char *filename)
#endif
}

cob_incr_temp_iteration();
cob_incr_temp_iteration ();
return fn;
}

Expand Down Expand Up @@ -5425,7 +5425,7 @@ set_picture (struct cb_field *field, char *picture, size_t picture_len)
}

static void
set_category_from_usage (int usage, char *type)
set_category_from_usage (const enum cb_usage usage, char *type)
{
switch (usage) {
case CB_USAGE_INDEX:
Expand All @@ -5451,7 +5451,8 @@ set_category_from_usage (int usage, char *type)
}

static void
set_category (int category, int usage, char *type)
set_category (const enum cb_category category, const enum cb_usage usage,
char *type)
{
switch (category) {
case CB_CATEGORY_UNKNOWN:
Expand Down Expand Up @@ -5556,8 +5557,10 @@ print_fields (struct cb_field *top, int *found)
if (top->children) {
strcpy (type, "GROUP");
if (!top->external_definition) {
/* group never has a PICTURE ... */
got_picture = 0;
} else {
/* ...stilll output definitions for TYPEDEF / SAME AS */
got_picture = set_picture (top, picture, picture_len);
}
} else {
Expand Down
114 changes: 65 additions & 49 deletions cobc/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ check_for_duplicate_prototype (const cb_tree prototype_name,

static void
setup_prototype (cb_tree prototype_name, cb_tree ext_name,
const int type, const int is_current_element)
const enum cob_module_type type, const int is_current_element)
{
cb_tree prototype;
int name_redefinition_allowed;
Expand Down Expand Up @@ -2265,15 +2265,13 @@ error_if_different_display_type (struct cb_list *l, cb_tree local_upon_value,
static void
error_if_not_usage_display_or_nonnumeric_lit (cb_tree x)
{
const int is_numeric_literal = CB_NUMERIC_LITERAL_P (x);
const int is_field_with_usage_not_display =
CB_REFERENCE_P (x) && CB_FIELD (cb_ref (x))
&& CB_FIELD (cb_ref (x))->usage != CB_USAGE_DISPLAY;

if (is_numeric_literal) {
if (CB_NUMERIC_LITERAL_P (x)) {
cb_error_x (x, _("%s is not an alphanumeric literal"), CB_LITERAL (x)->data);
} else if (is_field_with_usage_not_display) {
cb_error_x (x, _("'%s' is not USAGE DISPLAY"), cb_name (x));
} else if (CB_REFERENCE_P (x) && CB_FIELD_P (cb_ref (x))) {
const struct cb_field *f = CB_FIELD (cb_ref (x));
if (f->usage != CB_USAGE_DISPLAY) {
cb_error_x (x, _ ("'%s' is not USAGE DISPLAY"), cb_name (x));
}
}
}

Expand Down Expand Up @@ -5333,8 +5331,8 @@ file_control_entry:
;

_select_clauses_or_error:
_select_clause_sequence _dot_or_else_end_of_file_control
| error _dot_or_else_end_of_file_control
_select_clause_sequence dot_or_else_end_of_file_control
| error dot_or_else_end_of_file_control
{
yyerrok;
}
Expand Down Expand Up @@ -6180,8 +6178,8 @@ i_o_control_header:
;

_i_o_control_entries:
| i_o_control_list _dot_or_else_end_of_file_control
| i_o_control_list error _dot_or_else_end_of_file_control
| i_o_control_list dot_or_else_end_of_file_control
| i_o_control_list error dot_or_else_end_of_file_control
{
yyerrok;
}
Expand Down Expand Up @@ -6441,8 +6439,8 @@ file_description_entry:
}
}
}
_file_description_clause_sequence _dot_or_else_end_of_file_description
| file_type error _dot_or_else_end_of_file_description
_file_description_clause_sequence dot_or_else_end_of_file_description
| file_type error dot_or_else_end_of_file_description
{
yyerrok;
}
Expand Down Expand Up @@ -6870,7 +6868,7 @@ communication_description_entry:
check_duplicate = 0;
}
_communication_description_clause_sequence
_dot_or_else_end_of_communication_description
dot_or_else_end_of_communication_description
;

_communication_description_clause_sequence:
Expand Down Expand Up @@ -6962,7 +6960,7 @@ unnamed_i_o_cd_clauses:
working_storage: WORKING_STORAGE { check_area_a_of ("WORKING-STORAGE SECTION"); };
_working_storage_section:
| working_storage SECTION
_dot_or_else_end_of_record_description
dot_or_else_end_of_record_description
{
check_headers_present (COBC_HD_DATA_DIVISION, 0, 0, 0);
header_check |= COBC_HD_WORKING_STORAGE_SECTION;
Expand Down Expand Up @@ -6995,8 +6993,8 @@ _record_description_list:
;

record_description_list:
data_description _dot_or_else_end_of_record_description
| record_description_list data_description _dot_or_else_end_of_record_description
data_description dot_or_else_end_of_record_description
| record_description_list data_description dot_or_else_end_of_record_description
;

data_description:
Expand Down Expand Up @@ -8443,7 +8441,7 @@ occurs_key_field:
for (l = $4; l; l = CB_CHAIN (l)) {
CB_PURPOSE (l) = $1;
ref = CB_VALUE (l);
if (CB_VALID_TREE(ref)) {
if (CB_VALID_TREE (ref)) {
CB_REFERENCE (ref)->chain = rchain;
}
}
Expand Down Expand Up @@ -9045,7 +9043,7 @@ report_description:
check_duplicate = 0;
}
_report_description_options
_dot_or_else_end_of_report_description
dot_or_else_end_of_report_description
_report_group_description_list
{
$$ = get_finalized_description_tree ();
Expand All @@ -9061,7 +9059,7 @@ report_description:

_report_description_options:
| _report_description_options report_description_option
| error _dot_or_else_end_of_report_description
| error dot_or_else_end_of_report_description
{
yyerrok;
}
Expand Down Expand Up @@ -9310,11 +9308,11 @@ report_group_description_entry:
description_field = current_field;
}
}
_report_group_options _dot_or_else_end_of_report_group_description
_report_group_options dot_or_else_end_of_report_group_description
{
build_sum_counter (current_report, current_field);
}
| level_number error _dot_or_else_end_of_report_group_description
| level_number error dot_or_else_end_of_report_group_description
{
yyerrok;
check_pic_duplicate = 0;
Expand Down Expand Up @@ -10039,7 +10037,7 @@ screen_option:
current_field->screen_color = $3;
CB_PENDING ("COLOR clause (SCREEN)"); /* no place in cob_screen */
}
| CONTROL _is display_identifier
| CONTROL _is control_source
{
check_repeated ("CONTROL", SYN_CLAUSE_24, &check_duplicate);
current_field->screen_control = $3;
Expand Down Expand Up @@ -11951,7 +11949,7 @@ accp_attr:
check_repeated ("COLOR", SYN_CLAUSE_30, &check_duplicate);
set_attribs (0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $3, NULL);
}
| CONTROL _is display_identifier
| CONTROL _is control_source
{
check_repeated ("CONTROL", SYN_CLAUSE_31, &check_duplicate);
set_attribs (0, NULL, NULL, NULL, NULL, NULL, NULL, $3, NULL, NULL);
Expand Down Expand Up @@ -13263,7 +13261,8 @@ display_erase:
}
_with_display_attr
{
cb_emit_display (CB_LIST_INIT (cb_space), cb_null, cb_int1, line_column, NULL, 1, FIELD_ON_SCREEN_DISPLAY);
cb_emit_display (CB_LIST_INIT (cb_space), cb_null, cb_int1, line_column,
current_statement->attr_ptr, 1, FIELD_ON_SCREEN_DISPLAY);
}
;

Expand All @@ -13272,7 +13271,8 @@ display_pos_specifier:
would allow combination of multiple formats ...*/
field_or_literal_or_erase_with_pos_specifier _with_display_attr
{
cb_emit_display ($1, cb_null, cb_int1, line_column, NULL, 1, FIELD_ON_SCREEN_DISPLAY);
cb_emit_display ($1, cb_null, cb_int1, line_column,
current_statement->attr_ptr, 1, FIELD_ON_SCREEN_DISPLAY);
}
;

Expand Down Expand Up @@ -13584,7 +13584,7 @@ disp_attr:
check_repeated ("COLOR", SYN_CLAUSE_21, &check_duplicate);
set_attribs (0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $3, NULL);
}
| CONTROL _is display_identifier
| CONTROL _is control_source
{
check_repeated ("CONTROL", SYN_CLAUSE_22, &check_duplicate);
set_attribs (0, NULL, NULL, NULL, NULL, NULL, NULL, $3, NULL, NULL);
Expand Down Expand Up @@ -13689,6 +13689,11 @@ disp_attr:
}
;

control_source:
display_identifier { $$ = $1; }
| alphanumeric_literal { $$ = $1; }
;

_end_display:
/* empty */ %prec SHIFT_PREFER
{
Expand Down Expand Up @@ -18941,6 +18946,18 @@ arith_nonzero_x:
}
;

alphanumeric_literal:
LITERAL
{
if (CB_TREE_CATEGORY ($1) != CB_CATEGORY_ALPHANUMERIC) {
cb_error_x ($1, _("an alphanumeric literal is expected here"));
$$ = cb_error_node;
} else {
$$ = $1;
}
}
;

numeric_literal:
LITERAL
{
Expand Down Expand Up @@ -20047,9 +20064,9 @@ _dot:
}
;

_dot_or_else_end_of_file_control:
dot_or_else_end_of_file_control:
TOK_DOT
| _file_control_end_delimiter
| file_control_end_delimiter
{
if (! cb_verify (cb_missing_period, _("optional period"))) {
YYERROR;
Expand All @@ -20067,10 +20084,10 @@ level_number_in_area_a:
}
;

_dot_or_else_end_of_file_description:
dot_or_else_end_of_file_description:
TOK_DOT
| level_number_in_area_a
| _file_description_end_delimiter
| level_number_in_area_a /* repeats last token */
| file_description_end_delimiter
{
if (! cb_verify (cb_missing_period, _("optional period"))) {
YYERROR;
Expand All @@ -20079,19 +20096,19 @@ _dot_or_else_end_of_file_description:
}
;

_dot_or_else_end_of_communication_description:
_dot_or_else_end_of_record_description;
dot_or_else_end_of_communication_description:
dot_or_else_end_of_record_description;

_dot_or_else_end_of_report_description:
_dot_or_else_end_of_record_description;
dot_or_else_end_of_report_description:
dot_or_else_end_of_record_description;

_dot_or_else_end_of_report_group_description:
_dot_or_else_end_of_record_description;
dot_or_else_end_of_report_group_description:
dot_or_else_end_of_record_description;

_dot_or_else_end_of_record_description:
dot_or_else_end_of_record_description:
TOK_DOT
| level_number_in_area_a
| _record_description_end_delimiter
| level_number_in_area_a /* repeats last token */
| record_description_end_delimiter
{
if (! cb_verify (cb_missing_period, _("optional period"))) {
YYERROR;
Expand All @@ -20100,15 +20117,14 @@ _dot_or_else_end_of_record_description:
}
;

_file_control_end_delimiter:
file_control_end_delimiter:
SELECT | I_O_CONTROL | DATA | PROCEDURE;

_file_description_end_delimiter:
LEVEL_NUMBER | TOK_FILE | PROCEDURE;
file_description_end_delimiter:
TOK_FILE | PROCEDURE;

_record_description_end_delimiter:
LEVEL_NUMBER | PROCEDURE | COMMUNICATION | LOCAL_STORAGE
| LINKAGE | REPORT | SCREEN;
record_description_end_delimiter:
PROCEDURE | COMMUNICATION | LOCAL_STORAGE | LINKAGE | REPORT | SCREEN;

_dot_or_else_area_a: /* in PROCEDURE DIVISION */
TOK_DOT
Expand Down
Loading

0 comments on commit 412c46a

Please sign in to comment.