code: @DontExtend
      public Rule toRule(final Object obj)
      {
          Objects.requireNonNull(obj);
          if (obj instanceof Rule)
              return (Rule) obj;
          if (obj instanceof Character)
              return fromCharLiteral((Character) obj);
          if (obj instanceof String)
              return fromStringLiteral((String) obj);
          if (obj instanceof char[])
              return fromCharArray((char[]) obj);
          if (obj instanceof Action) {
              final Action<?> action = (Action<?>) obj;
              return new ActionMatcher(action);
          }
  
          final String errmsg = obj instanceof  Boolean
              ? "unwrapped Boolean value in rule (wrap it with ACTION())"
              : "'" + obj + "' cannot be automatically converted to a rule";
          throw new InvalidGrammarException(errmsg);
      }
docs: Converts the given object to a rule
  
  @param obj the object to convert
  @return the rule corresponding to the given object