Skip to content

Commit dbd76e7

Browse files
authored
VB and COBOL with restructuring
1 parent 66ba701 commit dbd76e7

17 files changed

+874
-32
lines changed

ASTCompositeTerm.java

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40301,7 +40301,34 @@ public Vector cobolDataDefinitions(java.util.Map context, Vector invs)
4030140301
}
4030240302
return res;
4030340303
}
40304+
40305+
if ("fileSection".equals(tag))
40306+
{ // FILE SECTION . fileDescriptionEntry*
40307+
40308+
for (int i = 3; i < terms.size(); i++)
40309+
{ ASTTerm tt = (ASTTerm) terms.get(i);
40310+
Vector ttres = tt.cobolDataDefinitions(context, invs);
40311+
res.addAll(ttres);
40312+
}
40313+
return res;
40314+
}
4030440315

40316+
if ("fileDescriptionEntry".equals(tag))
40317+
{ // (FD | SD) fileName (.? fileDescriptionEntryClause)* . dataDescriptionEntry*
40318+
40319+
context.put("container", null);
40320+
context.put("previousLevel", new Integer(-1));
40321+
context.put("startPosition", new Integer(1));
40322+
40323+
for (int i = 2; i < terms.size(); i++)
40324+
{ ASTTerm tt = (ASTTerm) terms.get(i);
40325+
if ("dataDescriptionEntry".equals(tt.getTag()))
40326+
{ Vector ttres = tt.cobolDataDefinitions(context, invs); res.addAll(ttres);
40327+
}
40328+
}
40329+
return res;
40330+
}
40331+
4030540332
if ("dataDescriptionEntry".equals(tag))
4030640333
{ // dataDescriptionEntryFormat1 |
4030740334
// dataDescriptionEntryFormat2 |
@@ -40381,7 +40408,8 @@ public Vector cobolDataDefinitions(java.util.Map context, Vector invs)
4038140408
}
4038240409

4038340410
if (container == null) // no container, so top-level attribute
40384-
{ if ("FILLER".equals(fieldName)) { }
40411+
{ if ("FILLER".equals(fieldName))
40412+
{ /* Should not occur */ }
4038540413
else
4038640414
{ Attribute att =
4038740415
new Attribute(fieldName, typ,
@@ -40395,11 +40423,19 @@ public Vector cobolDataDefinitions(java.util.Map context, Vector invs)
4039540423
{ int contLevel = container.levelNumber;
4039640424
int contMult = container.cardinalityValue;
4039740425

40398-
Integer startPosition = (Integer) context.get("startPosition");
40426+
Integer startPosition =
40427+
(Integer) context.get("startPosition");
40428+
40429+
int startPos = 1;
40430+
int endPos = wdth;
40431+
4039940432
if (startPosition != null)
40400-
{ int startPos = startPosition.intValue();
40401-
int endPos = startPos + wdth - 1;
40433+
{ startPos = startPosition.intValue();
40434+
endPos = startPos + wdth - 1;
4040240435
context.put("startPosition", endPos + 1);
40436+
40437+
if ("FILLER".equals(fieldName))
40438+
{ fieldName = "FILLER_" + startPos + "_" + endPos; }
4040340439

4040440440
String cname = container.getName();
4040540441
String ownername =
@@ -40532,28 +40568,40 @@ else if (multiplicity == 1 & contMult > 1)
4053240568
else
4053340569
{ context.put("startPosition", 1 + wdth); }
4053440570

40535-
Integer previousLevel = (Integer) context.get("previousLevel");
40571+
Integer previousLevel =
40572+
(Integer) context.get("previousLevel");
4053640573
int prevLevel = previousLevel.intValue();
4053740574

4053840575
if (levelNumber >= prevLevel)
4053940576
{ // attribute of container
40540-
if ("FILLER".equals(fieldName)) {}
40577+
if ("FILLER".equals(fieldName))
40578+
{ fieldName = "FILLER_" + startPos + "_" + endPos; }
4054140579
else
40542-
{ Attribute att =
40580+
{ ASTTerm.setTaggedValue(fieldName, "startPosition",
40581+
"" + startPos);
40582+
ASTTerm.setTaggedValue(fieldName, "endPosition",
40583+
"" + endPos);
40584+
} // For the CSTL.
40585+
40586+
Attribute att =
4054340587
new Attribute(fieldName, typ,
4054440588
ModelElement.INTERNAL);
40545-
container.addAttribute(att);
40546-
} // could itself be composite
40589+
att.setWidth(wdth);
40590+
container.addAttribute(att);
40591+
// could itself be composite
40592+
4054740593
context.put("previousLevel",
4054840594
new Integer(levelNumber));
4054940595
}
4055040596
else if (levelNumber < prevLevel)
4055140597
{ // attribute of another container
40552-
if ("FILLER".equals(fieldName)) {}
40598+
if ("FILLER".equals(fieldName))
40599+
{ fieldName = "FILLER_" + startPos + "_" + endPos; }
4055340600
else
4055440601
{ Attribute att =
4055540602
new Attribute(fieldName, typ,
4055640603
ModelElement.INTERNAL);
40604+
att.setWidth(wdth);
4055740605
Entity actualContainer =
4055840606
container.findContainer(levelNumber);
4055940607
if (actualContainer != null)

Attribute.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class Attribute extends ModelElement
3636
private Vector parameters = new Vector();
3737
private boolean isArray = false;
3838

39+
private int width = 1; // for COBOL
3940

4041
public Attribute(String nme, Type t, int k)
4142
{ super(nme);
@@ -299,6 +300,12 @@ public boolean isArray()
299300
public void setArray(boolean b)
300301
{ isArray = b; }
301302

303+
public void setWidth(int w)
304+
{ width = w; }
305+
306+
public int getWidth()
307+
{ return width; }
308+
302309
public boolean isFunction()
303310
{ return type != null && type.isFunction(); }
304311

@@ -1053,6 +1060,24 @@ public boolean equals(Object x)
10531060
return false;
10541061
}
10551062

1063+
public static boolean equivalentAttributeGroups(
1064+
Vector atts1, Vector atts2)
1065+
{ // size is same & elements correspond item by item
1066+
1067+
if (atts1.size() == atts2.size()) { }
1068+
else
1069+
{ return false; }
1070+
1071+
for (int i = 0; i < atts1.size(); i++)
1072+
{ Attribute att1 = (Attribute) atts1.get(i);
1073+
Attribute att2 = (Attribute) atts2.get(i);
1074+
if (att1.equals(att2)) { }
1075+
else
1076+
{ return false; }
1077+
}
1078+
return true;
1079+
}
1080+
10561081
public boolean isManyValued()
10571082
{ return upper == 0; }
10581083

0 commit comments

Comments
 (0)