
from .RawGrammar import RawGrammar as Grammar


class StringGrammar(Grammar):
    @staticmethod
    def __to_string_arr(t):
        if isinstance(t, str):
            return [t]
        return t

    def remove_term(self, term=None):
        return super().remove_term(StringGrammar.__to_string_arr(term))

    def add_term(self, term):
        return super().add_term(StringGrammar.__to_string_arr(term))

    def term(self, term=None):
        return super().term(StringGrammar.__to_string_arr(term))

    def get_term(self, term=None):
        return super().get_term(StringGrammar.__to_string_arr(term))

    def have_term(self, term):
        return super().have_term(StringGrammar.__to_string_arr(term))


from .RawGrammar import RawGrammar as Grammar


class StringGrammar(Grammar):
    @staticmethod
    def __to_string_arr(t):
        if isinstance(t, str):
            return [t]
        return t

    def remove_term(self, term=None):
        return super().remove_term(StringGrammar.__to_string_arr(term))

    def add_term(self, term):
        return super().add_term(StringGrammar.__to_string_arr(term))

    def term(self, term=None):
        return super().term(StringGrammar.__to_string_arr(term))

    def get_term(self, term=None):
        res = super().get_term(StringGrammar.__to_string_arr(term))
        if isinstance(term, str):
            return res[0]
        return res

    def have_term(self, term):
        return super().have_term(StringGrammar.__to_string_arr(term))

Correct return of Terminal instance when parameter is string
Correct return of Terminal instance when parameter is string

  
  from .RawGrammar import RawGrammar as Grammar
  
  
  class StringGrammar(Grammar):
      @staticmethod
      def __to_string_arr(t):
          if isinstance(t, str):
              return [t]
          return t
  
      def remove_term(self, term=None):
          return super().remove_term(StringGrammar.__to_string_arr(term))
  
      def add_term(self, term):
          return super().add_term(StringGrammar.__to_string_arr(term))
  
      def term(self, term=None):
          return super().term(StringGrammar.__to_string_arr(term))
  
      def get_term(self, term=None):
-         return super().get_term(StringGrammar.__to_string_arr(term))
+         res = super().get_term(StringGrammar.__to_string_arr(term))
+         if isinstance(term, str):
+             return res[0]
+         return res
  
      def have_term(self, term):
          return super().have_term(StringGrammar.__to_string_arr(term))
  
Correct return of Terminal instance when parameter is string
## Code Before:

from .RawGrammar import RawGrammar as Grammar


class StringGrammar(Grammar):
    @staticmethod
    def __to_string_arr(t):
        if isinstance(t, str):
            return [t]
        return t

    def remove_term(self, term=None):
        return super().remove_term(StringGrammar.__to_string_arr(term))

    def add_term(self, term):
        return super().add_term(StringGrammar.__to_string_arr(term))

    def term(self, term=None):
        return super().term(StringGrammar.__to_string_arr(term))

    def get_term(self, term=None):
        return super().get_term(StringGrammar.__to_string_arr(term))

    def have_term(self, term):
        return super().have_term(StringGrammar.__to_string_arr(term))

## Instruction:
Correct return of Terminal instance when parameter is string
## Code After:

from .RawGrammar import RawGrammar as Grammar


class StringGrammar(Grammar):
    @staticmethod
    def __to_string_arr(t):
        if isinstance(t, str):
            return [t]
        return t

    def remove_term(self, term=None):
        return super().remove_term(StringGrammar.__to_string_arr(term))

    def add_term(self, term):
        return super().add_term(StringGrammar.__to_string_arr(term))

    def term(self, term=None):
        return super().term(StringGrammar.__to_string_arr(term))

    def get_term(self, term=None):
        res = super().get_term(StringGrammar.__to_string_arr(term))
        if isinstance(term, str):
            return res[0]
        return res

    def have_term(self, term):
        return super().have_term(StringGrammar.__to_string_arr(term))
