gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[open-cobol-list] CVS Update 20050628 - FUNCTION's !


From: Roger While
Subject: [open-cobol-list] CVS Update 20050628 - FUNCTION's !
Date: Tue Jun 28 07:15:41 2005

CVS Updated.
Fix LENGTH with literal parameter.

I think I have finally solved the mf add/subtract problem.
(Peg's report) - Needs further testing.

So, and now to FUNCTION's.
What is implemented -
ABS
ACOS
ANNUITY
ASIN
ATAN
CHAR
COS
CURRENT-DATE
DATE-OF-INTEGER
DAY-OF-INTEGER
E
EXP
EXP10
FACTORIAL
INTEGER
INTEGER-OF-DATE
INTEGER-OF-DAY
INTEGER-PART
LENGTH
LOG
LOG10
LOWER-CASE
MAX
MEAN
MEDIAN
MIDRANGE
MIN
MOD
NUMVAL
NUMVAL-C
ORD
ORD-MAX
ORD-MIN
PI
PRESENT-VALUE
RANDOM
RANGE
REM
REVERSE
SIN
SQRT
STANDARD-DEVIATION
SUM
TAN
TEST-DATE-YYYYMMDD
TEST-DAY-YYYYDDD
UPPER-CASE
VARIANCE
WHEN-COMPILED

The Cobol85 "IF" (Intrinsic Function) tests have been activated.

Notes/deficiencies/comments :

At the moment, we do not cater for :
a) The "ALL" keyword ie. FUNCTION SUM ( MYFIELD(ALL) )
b) Numeric expressions partially work; exception is eg.
     FUNCTION SUM ( A * B,  (C + 1) / D )
    OC is currently getting rid of the commas in the lexxer so we end up
    parsing A * B (C + 1) / D, which OC interprets as B having a subscript
    and therefore raises a compile error.
    Note that putting brackets arounf the params works ie.
    FUNCTIOM SUM ( (A * B), ( (C + 1) / D) )

The above constructs appear in the Cobol85 "IF" tests.
In order not to produce compile errors in the IF tests, I have added an extra
step in the make process to edit occurrences of the above to :
in the case of (a) - Replace ALL with a full param list
in the case of (b) - Put brackets arounfd the parameters.

The function list is in cobc/reserved.c
The list of functions is taken from the 2002 standard.
Each entry has the following 6 fields :
1 - The function name
2 - The number of expected paramaters :
      0 or positive number - Expected number of parameters
-1 - Variable number of parameters. There must be at least one except in
                case of RANDOM.
3 - An indicator if the function is implemented
      0 = Not implemented
      1 = Implemented
4 - An enum for the function
5 - The name of the runtime function to call.
      This has the format "cob_intr_xxxx", where xxxx is the function name
       converted to lower case and with hyphens replaced with underscore.
      This can be NULL for unimplemented functions or where the function
      is resolved by a compile time constant eg WHEN-COMPILED, PI.
6 - The function type.

The runtime consists of libcob/intrinsic.h and libcob/intrinsic.c

Day/date functions are calculated (as per standard) based on the
Gregorian epoch beginning December 31 1600. ie. Day 1 is 01/01/1601.

The LOWER-CASE, REVERSE, UPPER-CASE functions correctly cater
for variable length fields (ODO).

Nested functions work as expected.

What still is missing/needs to be done :
We need to type check the parameters.
Within the runtime functions, we need to control the results at various stages.
There remains a question of what to do in case of an invalid parameter -
we could just return 0 (or whatever is appropiate) or we could raise an
exception and terminate the program. Thoughts ?

A few functions are missing, I might be able to get 2-3 in by the weekend.
NUMVAL-C is (incorrectly) implemented as NUMVAL.

Any comments, improvement suggestions, problem/deficiency reports
welcome.

Have fun.

Roger




reply via email to

[Prev in Thread] Current Thread [Next in Thread]