diff --git a/src/org/rascalmpl/values/parsetrees/TreeAdapter.java b/src/org/rascalmpl/values/parsetrees/TreeAdapter.java index 0a2a4040ab6..5ebdba4f390 100644 --- a/src/org/rascalmpl/values/parsetrees/TreeAdapter.java +++ b/src/org/rascalmpl/values/parsetrees/TreeAdapter.java @@ -194,6 +194,26 @@ else if (ProductionAdapter.isRegular(prod)) { return null; } } + else if (ProductionAdapter.isError(prod)) { + var eprod = ProductionAdapter.getErrorProd(prod); + int dot = ProductionAdapter.getErrorDot(prod); + int index = SymbolAdapter.indexOfLabel(ProductionAdapter.getSymbols(eprod), field); + IList args = getArgs(tree); + + if (index != -1) { + if (index < dot) { + // changing the normal part of the tree + return setArgs(tree, args.put(index, repl)); + } + else if (index == dot) { + // extending the accepted part of the tree by one field + eprod = prod.set("prod", IRascalValueFactory.getInstance().integer(dot + 1)); + return setProduction(setArgs(tree, args.append(repl)), eprod); + } + + // otherwise we return null which indicates the field does not exist. + } + } } return null;