From e964a650db84b8c4f37cf5f8059b52ca7546f973 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 13 Nov 2024 10:59:48 +0100 Subject: [PATCH] returns "recovered" for getConstructor name on error productions such that "is" operator and others work on error trees. This does reserve the constructor name "recovered" for use in error versions.. --- .../interpreter/result/ConcreteSyntaxResult.java | 1 + .../values/parsetrees/ProductionAdapter.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/org/rascalmpl/interpreter/result/ConcreteSyntaxResult.java b/src/org/rascalmpl/interpreter/result/ConcreteSyntaxResult.java index 135d5b5f55f..8eaf7ff7211 100644 --- a/src/org/rascalmpl/interpreter/result/ConcreteSyntaxResult.java +++ b/src/org/rascalmpl/interpreter/result/ConcreteSyntaxResult.java @@ -55,6 +55,7 @@ public Result is(Name name) { return ResultFactory.bool(Names.name(name).equals(consName), ctx); } } + return ResultFactory.bool(false, ctx); } diff --git a/src/org/rascalmpl/values/parsetrees/ProductionAdapter.java b/src/org/rascalmpl/values/parsetrees/ProductionAdapter.java index 23312c01c01..d66d2027a03 100644 --- a/src/org/rascalmpl/values/parsetrees/ProductionAdapter.java +++ b/src/org/rascalmpl/values/parsetrees/ProductionAdapter.java @@ -38,10 +38,15 @@ private ProductionAdapter() { * @return a constructor name if present or null otherwise */ public static String getConstructorName(IConstructor tree) { - IConstructor def = getDefined(tree); + if (isDefault(tree)) { + IConstructor def = getDefined(tree); - if (SymbolAdapter.isLabel(def)) { - return SymbolAdapter.getLabel(def); + if (SymbolAdapter.isLabel(def)) { + return SymbolAdapter.getLabel(def); + } + } + else if (isError(tree)) { + return "recovered"; } return null;