Skip to content

Commit c7e166e

Browse files
committed
handle public/protected/private in variable declarations
1 parent 946a37b commit c7e166e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/fortran/ofp/XMLPrinter.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,25 @@ public void declaration_type_spec(Token udtKeyword, int type) {
439439
}
440440

441441
public void attr_spec(Token attrKeyword, int attr) {
442+
Element preceeding = null;
442443
String nestIn = "";
443444
switch (attr) {
444445
case IActionEnums.AttrSpec_access:
445-
// private
446+
preceeding = contextNode(-1);
447+
int accessType = Integer.parseInt(getAttribute("type", preceeding).getValue());
448+
switch (accessType) {
449+
case IActionEnums.AttrSpec_PUBLIC:
450+
nestIn = "public";
451+
break;
452+
case IActionEnums.AttrSpec_PROTECTED:
453+
nestIn = "protected";
454+
break;
455+
case IActionEnums.AttrSpec_PRIVATE:
456+
nestIn = "private";
457+
break;
458+
default:
459+
throw new IllegalArgumentException(Integer.toString(attr) + " - " + attrKeyword + ", type=" + Integer.toString(accessType));
460+
}
446461
break;
447462
case IActionEnums.AttrSpec_language_binding:
448463
// bind
@@ -497,6 +512,8 @@ public void attr_spec(Token attrKeyword, int attr) {
497512
}
498513
if (nestIn.length() > 0)
499514
contextOpen("attribute-" + nestIn);
515+
if (preceeding != null)
516+
moveHere(preceeding);
500517
super.attr_spec(attrKeyword, attr);
501518
if (nestIn.length() > 0)
502519
contextClose();

0 commit comments

Comments
 (0)