Menu

#454 Full support for conditional compilation (arithmetic)

unclassified
accepted
nobody
CDF (3) cobc (63)
5 - default
2023-11-11
2023-11-05
No

Hi,

Thank you for the work done.

I notice that the conditional compilation directives >>define, >>if, >>evaluate, which are part of the COBOL ISO 2002 standard, do not work as expected by the standard, or are not supported.

My observations:

  • the declaration >>define varname as b'0' is not accepted, (the literal b'0' is not accepted)
  • the declaration >>if varname1 + varname2 = value is not accepted, even if varname1 and varname2 are declared beforehand and associated with numeric values.
  • in general, arithmetic expressions are not accepted in declarations >>define, >>if, >>when and boolean literals b'0' and b'1' are not recognized as such but as variables.
  • directives >>evaluate, >>when, >>end-evaluate are not supported.
>>DEFINE VAR1 AS PARAMETER
>>DEFINE VAR2 AS VAR1 + 2
>>IF VAR2 < 12
compute x = x + 1 *> this code should NOT be included
>>ELSE
compute x = x  1 *> this code should be included
>>END-IF

syntax error, unexpected Variable, expecting OFF or PARAMETER or Literal

   10 |            >>DEFINE VAR1 AS PARAMETER
   11 >            >>DEFINE VAR2 AS VAR1 + 2
   12 |            >>IF VAR2 < 12
   13 |            compute x = x + 1 *> this code should NOT be included
statut de retour :      1
>>DEFINE VAR1 AS 6
>>DEFINE VAR2 AS 1
>>EVALUATE VAR1
>>WHEN VAR2 + 2
compute x = x + 1 *> this code should NOT be included
>>WHEN 4 THRU 8
compute x = x  1 *> this code should be included
>>WHEN OTHER
compute x = x * 2 *> this code should NOT be included
>>END-EVALUATE

warning: invalid directive is ignored : « >>EVALUATE » [-Wothers]
   10 |            >>DEFINE VAR1 AS 6
   11 |            >>DEFINE VAR2 AS 1
   12 >            >>EVALUATE VAR1
   13 |            >>WHEN VAR2 + 2
   14 |            compute x = x + 1 *> this code should NOT be included
warning: invalid directive is ignored : « >>EVALUATE » [-Wothers]
   11 |            >>DEFINE VAR2 AS 1
   12 |            >>EVALUATE VAR1
   13 >            >>WHEN VAR2 + 2
   14 |            compute x = x + 1 *> this code should NOT be included
   15 |            >>WHEN 4 THRU 8
warning: invalid directive is ignored : « >>EVALUATE » [-Wothers]
   13 |            >>WHEN VAR2 + 2
   14 |            compute x = x + 1 *> this code should NOT be included
   15 >            >>WHEN 4 THRU 8
   16 |            compute x = x -  1 *> this code should be included
   17 |            >>WHEN OTHER
warning: invalid directive is ignored : « >>EVALUATE » [-Wothers]
   15 |            >>WHEN 4 THRU 8
   16 |            compute x = x - 1 *> this code should be included
   17 >            >>WHEN OTHER
   18 |            compute x = x * 2 *> this code should NOT be included
   19 |            >>END-EVALUATE
warning: invalid directive is ignored : « >>EVALUATE » [-Wothers]
   17 |            >>WHEN OTHER
   18 |            compute x = x * 2 *> this code should NOT be included
   19 >            >>END-EVALUATE
statut de retour :      0

Discussion

  • Simon Sobisch

    Simon Sobisch - 2023-11-06
    • labels: --> CDF, cobc
    • summary: Full support for conditional compilation --> Full support for conditional compilation (arithmetic)
    • status: open --> accepted
    • Group: GC 3.2 --> unclassified
     
  • Simon Sobisch

    Simon Sobisch - 2023-11-06
    That seems like multiple wish-list items, most of those already output a warning about missing support, so I don't consider that a bug. Biggest parts:
    

    I'll leave this open for arithmetic statements in conditional compilation.

     

    Related

    Wish List: #303
    Wish List: #46

  • Simon Sobisch

    Simon Sobisch - 2023-11-06

    Ticket moved from /p/gnucobol/bugs/929/

     
  • Denis FALLAI

    Denis FALLAI - 2023-11-11

    Hi,
    Thanks.
    Not sure that >>define xxx as b'0' / >>define xxxx as b'1' relate to [feature-requests:#303]. >>define only accept these two boolean constant.

     

    Related

    Wish List: #303


Log in to post a comment.