
from grammpy import Grammar
from .NongeneratingSymbolsRemove import remove_nongenerating_symbols
from .UnreachableSymbolsRemove import remove_unreachable_symbols


class ContextFree:
    @staticmethod
    def remove_nongenerating_symbols(grammar: Grammar, transform_grammar=False):
        return remove_nongenerating_symbols(grammar, transform_grammar)

    @staticmethod
    def is_grammar_generating(grammar: Grammar, tranform_gramar=False, perform_remove=True):
        g = grammar
        if perform_remove:
            g = ContextFree.remove_nongenerating_symbols(grammar, transform_grammar=tranform_gramar)
        return g.start_get() in g.nonterms()

    @staticmethod
    def remove_unreachable_symbols(grammar: Grammar, transform_grammar=False):
        return remove_unreachable_symbols(grammar, transform_grammar)


from grammpy import Grammar
from .NongeneratingSymbolsRemove import remove_nongenerating_symbols
from .UnreachableSymbolsRemove import remove_unreachable_symbols


class ContextFree:
    @staticmethod
    def remove_nongenerating_symbols(grammar: Grammar, transform_grammar=False):
        return remove_nongenerating_symbols(grammar, transform_grammar)

    @staticmethod
    def is_grammar_generating(grammar: Grammar, transform_grammar=False, perform_remove=True):
        g = grammar
        if perform_remove:
            g = ContextFree.remove_nongenerating_symbols(grammar, transform_grammar=transform_grammar)
        return g.start_get() in g.nonterms()

    @staticmethod
    def remove_unreachable_symbols(grammar: Grammar, transform_grammar=False):
        return remove_unreachable_symbols(grammar, transform_grammar)

    @staticmethod
    def remove_useless_symbols(grammar: Grammar, transform_grammar=False, *,
                                   perform_unreachable_alg = True,
                                   perform_nongenerating_alg = True) -> Grammar:
        if perform_nongenerating_alg:
            grammar = ContextFree.remove_nongenerating_symbols(grammar, transform_grammar=transform_grammar)
            transform_grammar = False
        if perform_unreachable_alg:
            grammar = ContextFree.remove_unreachable_symbols(grammar, transform_grammar=transform_grammar)
        return grammar

Implement alg to remove useless symbols
Implement alg to remove useless symbols

  
  from grammpy import Grammar
  from .NongeneratingSymbolsRemove import remove_nongenerating_symbols
  from .UnreachableSymbolsRemove import remove_unreachable_symbols
  
  
  class ContextFree:
      @staticmethod
      def remove_nongenerating_symbols(grammar: Grammar, transform_grammar=False):
          return remove_nongenerating_symbols(grammar, transform_grammar)
  
      @staticmethod
-     def is_grammar_generating(grammar: Grammar, tranform_gramar=False, perform_remove=True):
+     def is_grammar_generating(grammar: Grammar, transform_grammar=False, perform_remove=True):
          g = grammar
          if perform_remove:
-             g = ContextFree.remove_nongenerating_symbols(grammar, transform_grammar=tranform_gramar)
+             g = ContextFree.remove_nongenerating_symbols(grammar, transform_grammar=transform_grammar)
          return g.start_get() in g.nonterms()
  
      @staticmethod
      def remove_unreachable_symbols(grammar: Grammar, transform_grammar=False):
          return remove_unreachable_symbols(grammar, transform_grammar)
  
+     @staticmethod
+     def remove_useless_symbols(grammar: Grammar, transform_grammar=False, *,
+                                    perform_unreachable_alg = True,
+                                    perform_nongenerating_alg = True) -> Grammar:
+         if perform_nongenerating_alg:
+             grammar = ContextFree.remove_nongenerating_symbols(grammar, transform_grammar=transform_grammar)
+             transform_grammar = False
+         if perform_unreachable_alg:
+             grammar = ContextFree.remove_unreachable_symbols(grammar, transform_grammar=transform_grammar)
+         return grammar
+ 
Implement alg to remove useless symbols
## Code Before:

from grammpy import Grammar
from .NongeneratingSymbolsRemove import remove_nongenerating_symbols
from .UnreachableSymbolsRemove import remove_unreachable_symbols


class ContextFree:
    @staticmethod
    def remove_nongenerating_symbols(grammar: Grammar, transform_grammar=False):
        return remove_nongenerating_symbols(grammar, transform_grammar)

    @staticmethod
    def is_grammar_generating(grammar: Grammar, tranform_gramar=False, perform_remove=True):
        g = grammar
        if perform_remove:
            g = ContextFree.remove_nongenerating_symbols(grammar, transform_grammar=tranform_gramar)
        return g.start_get() in g.nonterms()

    @staticmethod
    def remove_unreachable_symbols(grammar: Grammar, transform_grammar=False):
        return remove_unreachable_symbols(grammar, transform_grammar)

## Instruction:
Implement alg to remove useless symbols
## Code After:

from grammpy import Grammar
from .NongeneratingSymbolsRemove import remove_nongenerating_symbols
from .UnreachableSymbolsRemove import remove_unreachable_symbols


class ContextFree:
    @staticmethod
    def remove_nongenerating_symbols(grammar: Grammar, transform_grammar=False):
        return remove_nongenerating_symbols(grammar, transform_grammar)

    @staticmethod
    def is_grammar_generating(grammar: Grammar, transform_grammar=False, perform_remove=True):
        g = grammar
        if perform_remove:
            g = ContextFree.remove_nongenerating_symbols(grammar, transform_grammar=transform_grammar)
        return g.start_get() in g.nonterms()

    @staticmethod
    def remove_unreachable_symbols(grammar: Grammar, transform_grammar=False):
        return remove_unreachable_symbols(grammar, transform_grammar)

    @staticmethod
    def remove_useless_symbols(grammar: Grammar, transform_grammar=False, *,
                                   perform_unreachable_alg = True,
                                   perform_nongenerating_alg = True) -> Grammar:
        if perform_nongenerating_alg:
            grammar = ContextFree.remove_nongenerating_symbols(grammar, transform_grammar=transform_grammar)
            transform_grammar = False
        if perform_unreachable_alg:
            grammar = ContextFree.remove_unreachable_symbols(grammar, transform_grammar=transform_grammar)
        return grammar
