Skip to content

Commit

Permalink
Add method getTagValue that generalizes getCategory (#2082)
Browse files Browse the repository at this point in the history
  • Loading branch information
sungshik authored Nov 18, 2024
1 parent 120e1a8 commit eda3949
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/org/rascalmpl/values/parsetrees/ProductionAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,15 @@ public static boolean isKeyword(IConstructor tree) {
}

public static String getCategory(IConstructor tree) {
return getTagValue(tree, "category");
}

public static String getTagValue(IConstructor tree, String name) {
if (!isRegular(tree)) {
for (IValue attr : getAttributes(tree)) {
if (attr.getType().isAbstractData() && ((IConstructor) attr).getConstructorType() == RascalValueFactory.Attr_Tag) {
IValue value = ((IConstructor)attr).get("tag");
if (value.getType().isNode() && ((INode) value).getName().equals("category")) {
if (value.getType().isNode() && ((INode) value).getName().equals(name)) {
return ((IString) ((INode) value).get(0)).getValue();
}
}
Expand Down

0 comments on commit eda3949

Please sign in to comment.