-
Notifications
You must be signed in to change notification settings - Fork 25
TypeCobolTypes
Future plan: * Weak, Strict and strong type * How to convert a type to another
A TYPE
is both a structure of data and definition of a type.
## Structure of data
01 Person TYPEDEF STRICT.
05 Id pic 9(05).
05 lastName pic X(30).
05 FirstName pic X(30).
05 BirthDate pic X(08).
Person
as a structure:
01 person1 TYPE Person.
01 person1.
02 Id pic 9(05).
02 lastName pic X(30).
02 FirstName pic X(30).
02 BirthDate pic X(08).
A TYPE
can be used at any level, but be aware that Cobol limits the number of level to 49.
01 person1 TYPE Person.
01 MyData.
05 Array occurs 5.
10 person2 TYPE Person.
01 person1.
02 Id pic 9(05).
02 lastName pic X(30).
02 FirstName pic X(30).
02 BirthDate pic X(08).
01 MyData.
05 Array occurs 5.
10 person2.
11 Id pic 9(05).
11 lastName pic X(30).
11 FirstName pic X(30).
11 BirthDate pic X(08).
A TYPE
allow you to control assignment to a variable.
Only variable of the same TYPE
can be moved into each other. (Note: only
With the following declaration:
01 Person TYPEDEF STRICT.
05 Id pic 9(05).
05 lastName pic X(30).
05 FirstName pic X(30).
05 BirthDate pic X(08).
01 person1 TYPE Person.
01 person2 TYPE Person.
01 person3 pic X(30).
person2
is of TYPE Person
and can only be assigned from Person1
.
move person1 to person2 *> OK
move person3 to person2 *> KO - type not equals
TODO:
TypeCobol syntax (almost like Cobol 2002) |
Translation into Cobol 85 |
01 Person TYPEDEF STRICT.
05 Id pic 9(05).
05 lastName pic X(30).
05 FirstName pic X(30).
05 BirthDate pic X(08). |
Define a type |
01 myPerson TYPE Person. |
01 myPerson.
02 Id pic 9(05).
02 lastName pic X(30).
02 FirstName pic X(30).
02 BirthDate pic X(08). |
01 myPerson type Person.
01 myPerson2 type Person.
move myPerson to myPerson2 |
*Ok because myPerson is of the same type as myPerson2
move myPerson to myPerson2 In a future release: * typed pointer * How to share type between programs * link to operator :: |
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