private <O> ConfigExpression<I, O> parse(Object object, Class<O> output) {
    if (object == null) {
      return ConfigExpression.constOf(null);
    } else if (ConfigExpressionScript.isScript(object)) {
      return ConfigExpression.script(signature(output), ConfigExpressionScript.extractScript(object));
    } else if (object instanceof Collection<?> collection) {
      return parseMatch(collection, true, output);
    } else if (object instanceof Map<?, ?> map) {
      if (map.get("type") != null) {
        var map2 = new HashMap<>(map);
        var type = map2.remove("type");
        DataType dataType = DataType.from(Objects.toString(type));
        if (!dataType.id().equals(type)) {
          throw new ParseException("Unrecognized datatype '" + type + "' supported values: " +
            Stream.of(DataType.values()).map(DataType::id).collect(
              Collectors.joining(", ")));
        }
        var child = parse(map2, Object.class);
        return cast(signature(output), child, dataType);
      } else {
        var keys = map.keySet();
        if (keys.equals(Set.of("coalesce")) && map.get("coalesce") instanceof Collection<?> cases) {
          return coalesce(cases.stream().map(item -> parse(item, output)).toList());
        } else if (keys.equals(Set.of("match"))) {
          return parseMatch(map.get("match"), true, output);
        } else if (keys.equals(Set.of("default_value", "overrides"))) {
          var match = parseMatch(map.get("overrides"), false, output);
          var defaultValue = parse(map.get("default_value"), output);
          return match.withDefaultValue(defaultValue);
        } else if (keys.equals(Set.of("tag_value"))) {
          var tagProducer = parse(map.get("tag_value"), String.class);
          return getTag(signature(output), tagProducer);
        } else if (keys.equals(Set.of("arg_value"))) {
          var keyProducer = parse(map.get("arg_value"), String.class);
          return getArg(signature(output), keyProducer);
        } else if (keys.equals(Set.of("value"))) {
          return parse(map.get("value"), output);
        }
        try {
          return parseMatch(map, true, output);
        } catch (ParseException e) {
          throw new ParseException("Failed to parse: " + map);
        }
      }
    } else {
      object = unescape(object);
      return constOf(TypeConversion.convert(object, output));
    }
  }
Attempts to evaluate {@code expression} from a yaml config, using only globally-available environmental variables
from the {@code root} context.
planetiler-custommap/src/main/java/com/onthegomap/planetiler/custommap/ConfigExpressionParser.java