private String toCastVariableParseExpression(TypeDefinition baseType, Field field, VariableLiteral variableLiteral, List<Argument> parserArguments, Tracer tracer) {
        tracer = tracer.dive("CAST");
        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new FreemarkerException("A Cast expression needs arguments"));
        if (arguments.size() != 2) {
            throw new FreemarkerException("A CAST expression expects exactly two arguments.");
        }
        VariableLiteral firstArgument = arguments.get(0).asLiteral()
            .orElseThrow(() -> new FreemarkerException("First argument should be a literal"))
            .asVariableLiteral()
            .orElseThrow(() -> new FreemarkerException("First argument should be a Variable literal"));
        StringLiteral typeLiteral = arguments.get(1).asLiteral()
            .orElseThrow(() -> new FreemarkerException("Second argument should be a String literal"))
            .asStringLiteral()
            .orElseThrow(() -> new FreemarkerException("Second argument should be a String literal"));

        final TypeDefinition castType = getTypeDefinitions().get(typeLiteral.getValue());
        // If we're casting to a sub-type of a discriminated value, we got to cast to the parent
        // type instead and add the name of the sub-type as prefix to the property we're trying to
        // access next.
        StringBuilder sb = new StringBuilder();
        sb.append("((");
        Optional<ComplexTypeDefinition> potentialParentType = castType.asComplexTypeDefinition().flatMap(ComplexTypeDefinition::getParentType);
        if (potentialParentType.isPresent()) {
            sb.append(getCTypeName(potentialParentType.get().getName()));
        } else {
            sb.append(getCTypeName(castType.getName()));
        }
        sb.append("*) (");
        sb.append(toVariableParseExpression(baseType, field, firstArgument, parserArguments)).append("))");
        if (variableLiteral.getChild().isPresent()) {
            if (potentialParentType.isPresent()) {
                // Change the name of the property to contain the sub-type-prefix.
                sb.append("->").append(camelCaseToSnakeCase(castType.getName())).append("_");
                appendVariableExpressionRest(sb, baseType, variableLiteral.getChild().get());
            } else {
                sb.append("->");
                appendVariableExpressionRest(sb, castType, variableLiteral.getChild().get());
            }
        }
        return tracer + sb.toString();
    }
Ge the type-size suffix in case of simple types.

@param field the field we want to get the type-size for
@return a type-size string for the given field or an empty string if this does not apply
code-generation/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java