code: private String findPackageName (final String grammar)
    {
      final String packageDeclaration = "package\\s+([^\\s.;]+(\\.[^\\s.;]+)*)\\s*;";
      final Matcher matcher = Pattern.compile (packageDeclaration).matcher (grammar);
      if (matcher.find ())
      {
        return matcher.group (1);
      }
      return "";
    }
docs: Extracts the declared package name from the specified grammar file.
  
  @param grammar
  The contents of the grammar file, must not be <code>null</code>.
  @return The declared package name or an empty string if not found.