private void checkCompounds(List<SyntaxElement> children) {
    for (SyntaxElement syntaxElement : children) {
      if (syntaxElement instanceof CompoundDefinition) {
        CompoundDefinition compound = (CompoundDefinition) syntaxElement;
        Cardinality cardinality = compound.getCardinality();
        boolean hasUnlimitedUpperBound =
            cardinality == Cardinality.PLUS || cardinality == Cardinality.STAR;

        if (hasUnlimitedUpperBound) {
          // check whether the compound allows the empty sentence
          if (csUtil.canBeEmpty(compound.getDefinition(), true)) {
            addProblem(
                CsAnalysisProblemType.EMPTY_COMPOUND,
                EMPTY_COMPOUND_MESSAGE,
                compound,
                new RemoveElementQuickFix("Remove compound", compound));
          }
        }
      }
      checkCompounds(syntaxElement.getChildren());
    }
  }
  private void addRegisterResourceFactoryMethod(JavaComposite sc) {
    final String secondaryConcreteSyntaxName =
        csUtil.getSecondarySyntaxName(getContext().getConcreteSyntax());

    sc.add("public void registerResourceFactory() {");
    if (secondaryConcreteSyntaxName == null) {
      sc.add("// if no resource factory registered, register delegator");

      sc.add(
          "if ("
              + RESOURCE_FACTORY(sc)
              + ".Registry.INSTANCE.getExtensionToFactoryMap().get(getSyntaxName()) == null) {");
      sc.add(
          RESOURCE_FACTORY(sc)
              + ".Registry.INSTANCE.getExtensionToFactoryMap().put(getSyntaxName(), new "
              + resourceFactoryDelegatorClassName
              + "());");
      sc.add("}");
    } else {
      // if this is a secondary syntax, the ResourceFactory is registered
      // using the 'additional_extension_parser' extension point.
      // Unfortunately, we do not know the name of the corresponding
      // registry because it can be implemented in arbitrary ways in the
      // base resource plug-in.
      sc.addComment(
          "This is a secondary syntax. "
              + "Registering the resource factory is done via the 'additional_extension_parser' extension point.");
    }

    // Register resource factory for additional file extensions if required.
    GenerationContext context = getContext();
    ConcreteSyntax syntax = context.getConcreteSyntax();
    Collection<String> additionalFileExtensions =
        OptionManager.INSTANCE.getStringOptionValueAsCollection(
            syntax, OptionTypes.ADDITIONAL_FILE_EXTENSIONS);

    if (additionalFileExtensions != null && !additionalFileExtensions.isEmpty()) {
      sc.addLineBreak();
      sc.add("Factory.Registry registry = " + RESOURCE_FACTORY(sc) + ".Registry.INSTANCE;");
      sc.add(
          MAP(sc)
              + "<String, Object> extensionToFactoryMap = registry.getExtensionToFactoryMap();");
      sc.addLineBreak();
      sc.add(
          resourceFactoryClassName + " resourceFactory = new " + resourceFactoryClassName + "();");
      sc.addLineBreak();
      sc.addComment("Register resource factory for additional extensions.");

      for (String additionalFileExtension : additionalFileExtensions) {
        additionalFileExtension = additionalFileExtension.trim();

        sc.add("if (extensionToFactoryMap.get(\"" + additionalFileExtension + "\") == null) {");
        sc.add("extensionToFactoryMap.put(\"" + additionalFileExtension + "\", resourceFactory);");
        sc.add("}");
        sc.addLineBreak();
      }
    }

    sc.add("}");
    sc.addLineBreak();
  }