You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Symbols - Document and support type mapping for basic PIC symbols (#11)
* Add some PIC and copybook docco
* From doc matrix, prep fallthrough type filter
* Add "complex" length calc
* Update greedy regex
* Update PIC type and length parsers
* Use updated PIC type and length parsers
* Update template and example
* Update binary name and references to it
* Update readme
Copy file name to clipboardExpand all lines: README.md
+18-17Lines changed: 18 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Get started using `gopic` by installing the struct-generation tool from the root
15
15
16
16
## Tag-based unmarshalling
17
17
18
-
go-pic's main focus is enabling simpler 1:1 mapping of PIC definitions to Go structs.
18
+
`gopic`'s main focus is enabling simpler 1:1 mapping of PIC definitions to Go structs.
19
19
20
20
For example, if your PIC definitions look like:
21
21
```
@@ -38,40 +38,41 @@ type Copybook struct{
38
38
}
39
39
```
40
40
41
-
Or you can make use of `go-pics` other feature below, so that you don't have to define the struct yourself...
41
+
Or you can make use of `gopic`s other feature below, so that you don't have to define the struct yourself...
42
42
43
43
## Generating tagged structs
44
44
45
-
`go-pic` provides support to generate flattened Go struct representations of your COBOL copybooks, tagged with length statements and assigned the appropriate type for unmarshalling files that match your COBOL copybook definitions.
45
+
`gopic` provides support to generate flattened Go struct representations of your COBOL copybooks, tagged with length statements and assigned the appropriate type for unmarshalling files that match your COBOL copybook definitions.
46
46
47
47
`cmd` contains go struct generation tool from textual PIC definitions
Basic info below sourced from [tutorialspoint](https://www.tutorialspoint.com/cobol/cobol_data_types.htm).
5
+
```
6
+
01 TOTAL-STUDENTS PIC9(5) VALUE '125'.
7
+
| | | |
8
+
| | | |
9
+
| | | |
10
+
Level Number Data Name Picture Clause Value Clause
11
+
```
12
+
13
+
### Level Number
14
+
Level number is used to specify the level of data in a record. They are used for differentiating between elementary items and group items. Elementary items can be grouped together to create group items.
15
+
16
+
Level numbers adhere to the following rules:
17
+
18
+
| Sr.No. | Level Number & Description
19
+
|----------|----------------------------
20
+
| 01 | Record description entry
21
+
| 02 - 49 | Group and Elementary items
22
+
| 66 | Rename Clause items
23
+
| 77 | Items which cannot be sub-divided
24
+
| 88 | Condition name entry
25
+
26
+
- Elementary items cannot be divided further. Level number, Data name, Picture clause, and Value clause (optional) are used to describe an elementary item.
27
+
28
+
- Group items consist of one or more elementary items. Level number, Data name, and Value clause (optional) are used to describe a group item. Group level number is always 01
29
+
30
+
### Data Name
31
+
Data names must be defined in the Data Division before using them in the Procedure Division. They must have a user-defined name; reserved words cannot be used. Data names give reference to the memory locations where actual data is stored. They can be elementary or group type.
32
+
33
+
### Picture clause
34
+
35
+
A Picture clause is used to define the following items:
36
+
37
+
- Data type can be numeric, alphabetic, or alphanumeric. Numeric type consists of only digits 0 to 9. Alphabetic type consists of letters A to Z and spaces. Alphanumeric type consists of digits, letters, and special characters.
38
+
39
+
- Sign can be used with numeric data. It can be either + or –.
40
+
41
+
- Decimal point position can be used with numeric data. Assumed position is the position of decimal point and not included in the data.
42
+
43
+
- Length defines the number of bytes used by the data item.
44
+
45
+
| Symbol | Description
46
+
|--------|----------------------------
47
+
| 9 | Numeric
48
+
| A | Alphabetic
49
+
| X | Alphanumeric
50
+
| V | Implicit decimal
51
+
| S | Sign
52
+
| P | Assumed decimal place
53
+
54
+
## Possible PIC definitions
55
+
Basic:
56
+
-`PIC X.`
57
+
-`PIC 9999.`
58
+
-`PIC X(4).`
59
+
60
+
Mixed:
61
+
-`PIC S99V99`
62
+
-`PIC S9(3)V9(2).`
63
+
-`PIC PPP999.`
64
+
65
+
### Determining applicable Go Types
66
+
`i` - Int
67
+
`u` - Uint
68
+
`s` - String
69
+
70
+
| *X* | *9* | *A* | *X* | *V* | *S* | *P*
71
+
|-----|-----|-----|-----|-----|-----|-----
72
+
| *9* | u | s | s | u | i | u
73
+
| *A* | s | s | s | s | s | s
74
+
| *X* | s | s | s | s | s | s
75
+
| *V* | u | s | s | ? | i | u
76
+
| *S* | i | s | s | i | i | i
77
+
| *P* | u | s | s | u | i | u
78
+
79
+
### Applying regex
80
+
PICs can essentially be comprised of any pattern of the above symbols
81
+
82
+
`S9(5)VXXXXA(12)` is a valid definition for `-12345.AB12DABCDEFGHIJKL`
83
+
84
+
This quickly becomes difficult to handle with regex. So support for basic patterns will be created
0 commit comments