-
Notifications
You must be signed in to change notification settings - Fork 25
TypeCobolFunctions
Format : function
FUNCTION function-name (parameters)
This syntax is the same as the syntax for COBOL intrinsic functions and can be used in the same contexts (in particular as part of any statement where an intrinsic function would be acceptable).
A function is defined by:
- its function name
- its library
- its list of input parameters, each parameter being defined by:
- its type or format
- One returning parameter, being defined by:
- its type or format
A function can have any number of parameters. Each parameter can be of any type (either from COBOL or a custom defined type). A parameter is always an input parameter: it is written by the caller but read-only for the callee
Each function should have the return code as an output parameter. Note that TypeCobol doesn't enforce that.
TypeCobol will provide native functions included directly in our Library. These are called "TypeCobol intrinsic fucnctions".
Functions are grouped in libraries.
You can pass any data to a function, provided each data is of the type expected by the function definition.
You can pass identifiers or directly literals with no particular concern.
If a function needs more than one parameter, you need to separate parameters with commas (,
).
If the method implementation allows it, you can imply some parameters you don't want to bother with. To do this, you just have to put nothing between the parameters separators.
To imply the third parameter of a call to fun
, a four-parameters function:
FUNCTION fun(param1, param2, , param4)
To imply the second and third parameters of a call to fun2
, a three-parameters function, you could write any of the following:
FUNCTION fun2(param1)
FUNCTION fun2(param1, , )
FUNCTION fun2(param1, )
Once defined, a custom function which has only one output parameter (in addition to its return code) can be used the same way a COBOL intrinsic function would be. For example, the following would be perfectly valid:
MOVE FUNCTION SOFUN(myVar1, 'literal', , myVar4) TO myResultVar.
TODO
TODO
Introduction
TypeCobol language
-
In a nutshell
-
TypeCobol concepts
TypeCobol Editor
(Type)Cobol parser API
TypeCobol architecture
- Glossary
- Main phases
- How to extend the grammar and semantic check (full example)
- File
- Text
- Code analysis steps
- Program class parser
- Type checker
- Error handler
- Grammars Composition
- Code generation
- Compilation process
(Type)Cobol concepts / reference doc
Contributing