diff --git a/common/pattern_uni.y b/common/pattern_uni.y
index 35940696988f7054704a72bea078482102aa2da6..5955b3f1e7da6b02190a4704fb297c2fb167aa0d 100644
--- a/common/pattern_uni.y
+++ b/common/pattern_uni.y
@@ -609,9 +609,11 @@ char* TTCN_pattern_to_regexp_uni(const char* p_pattern, bool p_nocase, int** gro
   pattern_yy_delete_buffer(flex_buffer);
 
   // needed by regexp to find user specified groups
-  if (user_groups && groups) {
-    *groups = (int*)Malloc(sizeof(int) * (user_groups + 1));
-    (*groups)[0] = user_groups;
+  if (user_groups /*&& groups*/) {
+    if (groups) {
+      *groups = (int*)Malloc(sizeof(int) * (user_groups + 1));
+      (*groups)[0] = user_groups;
+    }
 
     int par = -1, index = 1;
     for (size_t i = 0; i < strlen(ret_val); i++) {
@@ -621,7 +623,7 @@ char* TTCN_pattern_to_regexp_uni(const char* p_pattern, bool p_nocase, int** gro
       if (ret_val[i] == '<') {
         ret_val[i] = '(';
         par++;
-        (*groups)[index++] = par;
+        if (groups) (*groups)[index++] = par;
       }
     }
   } else if (groups)
diff --git a/compiler2/subtype.cc b/compiler2/subtype.cc
index db93bb03d7aec69dce986f004cf9d26418abe3ab..4cf50a312bb88df294a3c00c3edfc40cc85b6b79 100644
--- a/compiler2/subtype.cc
+++ b/compiler2/subtype.cc
@@ -2770,6 +2770,10 @@ void SubType::print_full_warning() const
     "it does not constrain the root type.", my_owner->get_typename().c_str());
 }
 
+vector<SubTypeParse> * SubType::get_subtype_parsed() const {
+  return parsed;
+}
+
 void SubType::chk()
 {
   if ((checked!=STC_NO) || (subtype==ST_ERROR)) FATAL_ERROR("SubType::chk()");
diff --git a/compiler2/subtype.hh b/compiler2/subtype.hh
index 1075bbe62d2965fca95066163472472e108d8d41..b62b203ea7ce09f5ad901b9fe79582a5ba8801f9 100644
--- a/compiler2/subtype.hh
+++ b/compiler2/subtype.hh
@@ -257,6 +257,8 @@ public:
   SubtypeConstraint* get_extension() { return extension; }
 
   string to_string() const;
+  
+  vector<SubTypeParse> * get_subtype_parsed() const;
 
   /** Set restrictions.
    *
diff --git a/compiler2/ttcn3/PatternString.cc b/compiler2/ttcn3/PatternString.cc
index 3feb9093094ceb6b0380f79a93b55bb2eebb2abf..db00bc1e559cfcdc5691039e7f5349220642cd5c 100644
--- a/compiler2/ttcn3/PatternString.cc
+++ b/compiler2/ttcn3/PatternString.cc
@@ -36,12 +36,14 @@ namespace Ttcn {
       PSE_REF,
       PSE_REFDSET
     } kind;
-    union {
-      string *str;
-      Ttcn::Reference *ref;
-    };
+    string *str;
+    Ttcn::Reference *ref;
+    Type * t; // The type of the reference in the case of PSE_REFDSET
+    boolean with_N; // If the reference was given as \N{ref} in the pattern
+    boolean is_charstring; // \N{charstring}
+    boolean is_universal_charstring; // \N{universal charstring}
     ps_elem_t(kind_t p_kind, const string& p_str);
-    ps_elem_t(kind_t p_kind, Ttcn::Reference *p_ref);
+    ps_elem_t(kind_t p_kind, Ttcn::Reference *p_ref, boolean N);
     ps_elem_t(const ps_elem_t& p);
     ~ps_elem_t();
     ps_elem_t* clone() const;
@@ -52,13 +54,15 @@ namespace Ttcn {
   };
 
   PatternString::ps_elem_t::ps_elem_t(kind_t p_kind, const string& p_str)
-    : kind(p_kind)
+    : kind(p_kind), ref(NULL), t(NULL), with_N(FALSE), is_charstring(FALSE),
+    is_universal_charstring(FALSE)
   {
     str = new string(p_str);
   }
 
-  PatternString::ps_elem_t::ps_elem_t(kind_t p_kind, Ttcn::Reference *p_ref)
-    : kind(p_kind)
+  PatternString::ps_elem_t::ps_elem_t(kind_t p_kind, Ttcn::Reference *p_ref, boolean N)
+    : kind(p_kind), str(NULL), with_N(N), is_charstring(FALSE),
+    is_universal_charstring(FALSE)
   {
     if (!p_ref) FATAL_ERROR("PatternString::ps_elem_t::ps_elem_t()");
     ref = p_ref;
@@ -69,10 +73,11 @@ namespace Ttcn {
     switch(kind) {
     case PSE_STR:
       delete str;
-      break;
+      // fall through
     case PSE_REF:
     case PSE_REFDSET:
       delete ref;
+      // do not delete t
       break;
     } // switch kind
   }
@@ -111,6 +116,13 @@ namespace Ttcn {
     if (kind != PSE_REF) FATAL_ERROR("PatternString::ps_elem_t::chk_ref()");
     Value* v = 0;
     Value* v_last = 0;
+    if (ref->get_id()->get_name() == "CHARSTRING") {
+      is_charstring = TRUE;
+      return;
+    } else if (ref->get_id()->get_name() == "UNIVERSAL_CHARSTRING") {
+      is_universal_charstring = TRUE;
+      return;
+    }
     Common::Assignment* ass = ref->get_refd_assignment();
     if (!ass)
       return;
@@ -137,8 +149,15 @@ namespace Ttcn {
     }
     Type* refcheckertype = Type::get_pooltype(tt);
     switch (ass->get_asstype()) {
+    case Common::Assignment::A_TYPE:
+      kind = PSE_REFDSET;
+      t = ass->get_Type();
+      break;
     case Common::Assignment::A_MODULEPAR_TEMP:
-    case Common::Assignment::A_VAR_TEMPLATE:
+    case Common::Assignment::A_VAR_TEMPLATE: 
+    case Common::Assignment::A_PAR_TEMPL_IN:
+    case Common::Assignment::A_PAR_TEMPL_OUT:
+    case Common::Assignment::A_PAR_TEMPL_INOUT:
       // error reporting moved up
       break;
     case Common::Assignment::A_TEMPLATE: {
@@ -150,16 +169,20 @@ namespace Ttcn {
       case Template::SPECIFIC_VALUE:
         v_last = templ->get_specific_value();
         break;
-      case Template::CSTR_PATTERN: {
-        Ttcn::PatternString* ps = templ->get_cstr_pattern();
-        if (!ps->has_refs())
-          v_last = ps->get_value();
-        break; }
-      case Template::USTR_PATTERN: {
-        Ttcn::PatternString* ps = templ->get_ustr_pattern();
-        if (!ps->has_refs())
-          v_last = ps->get_value();
-        break; }
+      case Template::CSTR_PATTERN: 
+        if (!with_N) {
+          Ttcn::PatternString* ps = templ->get_cstr_pattern();
+          if (!ps->has_refs())
+            v_last = ps->get_value();
+          break;
+        }
+      case Template::USTR_PATTERN: 
+        if (!with_N) {
+          Ttcn::PatternString* ps = templ->get_ustr_pattern();
+          if (!ps->has_refs())
+            v_last = ps->get_value();
+          break;
+        }
       default:
         TTCN_pattern_error("Unable to resolve referenced '%s' to character "
           "string type. '%s' template cannot be used.",
@@ -183,12 +206,18 @@ namespace Ttcn {
       v_last->get_valuetype() == Value::V_USTR)) {
       // the reference points to a constant
       // substitute the reference with the known value
-      delete ref;
-      kind = PSE_STR;
-      if (v_last->get_valuetype() == Value::V_CSTR)
+      if (v_last->get_valuetype() == Value::V_CSTR) {
+        if (with_N && v_last->get_val_str().size() != 1) {
+          ref->error("The length of the charstring must be of length one, when it is being referenced in a pattern with \\N{ref}");
+        }
         str = new string(v_last->get_val_str());
-      else
+      } else {
+        if (with_N && v_last->get_val_ustr().size() != 1) {
+          ref->error("The length of the universal charstring must be of length one, when it is being referenced in a pattern with \\N{ref}");
+        }
         str = new string(v_last->get_val_ustr().get_stringRepr_for_pattern());
+      }
+      kind = PSE_STR;
     }
     delete v;
   }
@@ -283,20 +312,15 @@ namespace Ttcn {
   
   void PatternString::addStringUSI(char **usi_str, const size_t size)
   {
-    ustring s = ustring((const char**)usi_str, size);
+    ustring s = ustring(const_cast<const char**>(usi_str), size);
     ps_elem_t *last_elem = get_last_elem();
     if (last_elem) *last_elem->str += s.get_stringRepr_for_pattern().c_str();
     else elems.add(new ps_elem_t(ps_elem_t::PSE_STR, s.get_stringRepr_for_pattern()));
   }
 
-  void PatternString::addRef(Ttcn::Reference *p_ref)
-  {
-    elems.add(new ps_elem_t(ps_elem_t::PSE_REF, p_ref));
-  }
-
-  void PatternString::addRefdCharSet(Ttcn::Reference *p_ref)
+  void PatternString::addRef(Ttcn::Reference *p_ref, boolean N)
   {
-    elems.add(new ps_elem_t(ps_elem_t::PSE_REFDSET, p_ref));
+    elems.add(new ps_elem_t(ps_elem_t::PSE_REF, p_ref, N));
   }
 
   string PatternString::get_full_str() const
@@ -371,7 +395,7 @@ namespace Ttcn {
     for (size_t i = 0; i < elems.size(); i++) {
       ps_elem_t *pse = elems[i];
       if (pse->kind != ps_elem_t::PSE_STR)
-	FATAL_ERROR("PatternString::chk_pattern()");
+	      FATAL_ERROR("PatternString::chk_pattern()");
       str += *pse->str;
     }
     char* posix_str = 0;
@@ -441,7 +465,7 @@ namespace Ttcn {
     }
   }
 
-  string PatternString::create_charstring_literals(Common::Module *p_mod)
+  string PatternString::create_charstring_literals(Common::Module *p_mod, string& preamble)
   {
     /* The cast is there for the benefit of OPTIONAL<CHARSTRING>, because
      * it doesn't have operator+(). Only the first member needs the cast
@@ -455,42 +479,170 @@ namespace Ttcn {
     size_t nof_elems = elems.size();
     if (nof_elems > 0) {
       // the pattern is not empty
-      for (size_t i = 0; i < nof_elems; i++) {
-	if (i > 0) s += " + ";
-	ps_elem_t *pse = elems[i];
-	switch (pse->kind) {
-	case ps_elem_t::PSE_STR:
+    for (size_t i = 0; i < nof_elems; i++) {
+      if (i > 0) s += " + ";
+      ps_elem_t *pse = elems[i];
+      
+      // \N{charstring} and \N{universal charstring}
+      if (pse->is_charstring) {
+        s += p_mod->add_charstring_literal(string("?"));
+        continue;
+      } else if (pse->is_universal_charstring) {
+        s += p_mod->add_charstring_literal(string("?"));
+        continue;
+      }
+
+      switch (pse->kind) {
+        // Known in compile time: string literal, const etc.
+        case ps_elem_t::PSE_STR:
           s += p_mod->add_charstring_literal(*pse->str);
           break;
-	case ps_elem_t::PSE_REFDSET:
-          /* actually, not supported */
-          FATAL_ERROR("PatternString::create_charstring_literals()");
-          break;
-	case ps_elem_t::PSE_REF: {
-	  expression_struct expr;
-	  Code::init_expr(&expr);
-	  pse->ref->generate_code(&expr);
-	  if (expr.preamble || expr.postamble)
-	    FATAL_ERROR("PatternString::create_charstring_literals()");
+        // Known in compile time: string type with(out) range or list
+        case ps_elem_t::PSE_REFDSET: {
+          if (!pse->t)
+            FATAL_ERROR("PatternString::create_charstring_literals()");
+          if (!pse->t->get_sub_type()) {
+            // just a string type without any restrictions (or alias)
+            s += "\"?\"";
+            continue;
+          }
+          vector<Common::SubTypeParse> * vec = pse->t->get_sub_type()->get_subtype_parsed();
+
+          while (vec == NULL) { // go through aliases to find where the restrictions are
+            if (pse->t->get_Reference()) {
+              pse->t = pse->t->get_Reference()->get_refd_assignment(FALSE)->get_Type();
+            } else {
+              break;
+            }
+            if (pse->t->get_sub_type()) {
+              vec = pse->t->get_sub_type()->get_subtype_parsed();
+            } else {
+              break;
+            }
+          }
+          if (vec == NULL) {
+            // I don't think it can happen, but to be sure...
+            s += "\"?\"";
+            continue;
+          }
+          s+= "\"";
+          if (vec->size() > 1) s+= "(";
+          for (size_t j = 0; j < vec->size(); j++) {
+            Common::SubTypeParse* stp = (*vec)[j];
+            if (j > 0) {
+              s+="|\"+"; // todo what if default    
+            }else {
+              s+= "\"+";
+            }
+            switch (stp->get_selection()) {
+              case SubTypeParse::STP_RANGE: // type charstring ("a" .. "z")
+                s+="\"[\" + ";
+                switch (stp->Min()->get_valuetype()) {
+                  case Value::V_CSTR:
+                    s+= p_mod->add_charstring_literal(stp->Min()->get_val_str());
+                    s+= "+ \"-\" +";
+                    s+= p_mod->add_charstring_literal(stp->Max()->get_val_str());
+                    break;
+                  case Value::V_USTR:
+                    s+= p_mod->add_charstring_literal(stp->Min()->get_val_ustr().get_stringRepr_for_pattern());
+                    s+= "+ \"-\" +";
+                    s+= p_mod->add_charstring_literal(stp->Max()->get_val_ustr().get_stringRepr_for_pattern());
+                    break;
+                  default:
+                    FATAL_ERROR("PatternString::create_charstring_literals()");
+                }
+                s+=" + \"]\"";
+                break;
+              case SubTypeParse::STP_SINGLE: // type charstring ("a", "b")
+                switch (stp->Single()->get_valuetype()) {
+                  case Value::V_CSTR:
+                    s+= p_mod->add_charstring_literal(stp->Single()->get_val_str());
+                    break;
+                  case Value::V_USTR:
+                    s+= p_mod->add_charstring_literal(stp->Single()->get_val_ustr().get_stringRepr_for_pattern());
+                    break;
+                  default:
+                    FATAL_ERROR("PatternString::create_charstring_literals()");
+                    break;
+                }
+                break;
+              default:
+                FATAL_ERROR("PatternString::create_charstring_literals()");
+            }
+            s+= "+\"";
+          }
+          if (vec->size() > 1) s+= ")";
+          s+= "\"";
+          break; }
+        // Not known in compile time
+        case ps_elem_t::PSE_REF: {
+          expression_struct expr;
+          Code::init_expr(&expr);
+          pse->ref->generate_code(&expr);
+          if (expr.preamble || expr.postamble)
+            FATAL_ERROR("PatternString::create_charstring_literals()");
           s += expr.expr;
           Common::Assignment* assign = pse->ref->get_refd_assignment();
-
+          char* str = NULL;
+          
+          // TODO: these checks will generated each time a reference is referenced in a pattern
+          // and it could be generated once
+          if (pse->with_N) {
+            if ((assign->get_asstype() == Common::Assignment::A_TEMPLATE
+                  || assign->get_asstype() == Common::Assignment::A_MODULEPAR_TEMP
+                  || assign->get_asstype() == Common::Assignment::A_VAR_TEMPLATE
+                  || assign->get_asstype() == Common::Assignment::A_PAR_TEMPL_IN
+                  || assign->get_asstype() == Common::Assignment::A_PAR_TEMPL_OUT
+                  || assign->get_asstype() == Common::Assignment::A_PAR_TEMPL_INOUT))
+            {
+            string value_literal = p_mod->add_charstring_literal(string("value"));
+            str = mputprintf(str,
+              "if (%s.get_istemplate_kind(%s) == FALSE) {\n"
+              "TTCN_error(\"Only specific value template allowed in pattern reference with \\\\N{ref}\");\n"
+              "}\n"
+              , expr.expr
+              , value_literal.c_str());
+            }
+            
+            str = mputprintf(str,
+              "if (%s.lengthof() != 1)\n"
+              "{\n"
+              "TTCN_error(\"The length of the %scharstring must be of length one, when it is being referenced in a pattern with \\\\N{ref}\");\n"
+              "}\n"
+              , expr.expr
+              , assign->get_Type()->get_typetype() == Type::T_USTR ? "universal " : "");
+            preamble += str;
+            Free(str);
+          }
           if ((assign->get_asstype() == Common::Assignment::A_TEMPLATE
             || assign->get_asstype() == Common::Assignment::A_MODULEPAR_TEMP
-            || assign->get_asstype() == Common::Assignment::A_VAR_TEMPLATE))
+            || assign->get_asstype() == Common::Assignment::A_VAR_TEMPLATE
+            || assign->get_asstype() == Common::Assignment::A_PAR_TEMPL_IN
+            || assign->get_asstype() == Common::Assignment::A_PAR_TEMPL_OUT
+            || assign->get_asstype() == Common::Assignment::A_PAR_TEMPL_INOUT))
           {
             if ((assign->get_Type()->get_typetype() == Type::T_CSTR
-              || assign->get_Type()->get_typetype() == Type::T_USTR)) {
+              || assign->get_Type()->get_typetype() == Type::T_USTR) && !pse->with_N) {
               s += ".get_single_value()";
             }
-            else {
+            else if (assign->get_Type()->get_typetype() == Type::T_USTR && pse->with_N) {
+              s += ".valueof().get_stringRepr_for_pattern()";
+            } else {
               s += ".valueof()";
             }
+          } else if ((assign->get_asstype() == Common::Assignment::A_MODULEPAR
+            || assign->get_asstype() == Common::Assignment::A_VAR
+            || assign->get_asstype() == Common::Assignment::A_PAR_VAL
+            || assign->get_asstype() == Common::Assignment::A_PAR_VAL_IN
+            || assign->get_asstype() == Common::Assignment::A_PAR_VAL_OUT
+            || assign->get_asstype() == Common::Assignment::A_PAR_VAL_INOUT)
+            && assign->get_Type()->get_typetype() == Type::T_USTR) {
+            s += ".get_stringRepr_for_pattern()";
           }
 
-	  Code::free_expr(&expr);
-	  break; }
-	} // switch kind
+          Code::free_expr(&expr);
+          break; }
+        } // switch kind
       } // for
     } else {
       // empty pattern: create an empty string literal for it
diff --git a/compiler2/ttcn3/PatternString.hh b/compiler2/ttcn3/PatternString.hh
index e8876b5cdf1d5b2807af1e078d3439a829301eb8..91e9d78f15e0aa7bc1a5817d5feeba6ce49768dd 100644
--- a/compiler2/ttcn3/PatternString.hh
+++ b/compiler2/ttcn3/PatternString.hh
@@ -69,8 +69,7 @@ namespace Ttcn {
     void addString(const char *p_str);
     void addString(const string& p_str);
     void addStringUSI(char **usi_str, const size_t size);
-    void addRef(Ttcn::Reference *p_ref);
-    void addRefdCharSet(Ttcn::Reference *p_ref);
+    void addRef(Ttcn::Reference *p_ref, boolean N);
     string get_full_str() const;
 
     void set_pattern_type(pstr_type_t p_type);
@@ -88,7 +87,7 @@ namespace Ttcn {
      * generation. */
     void join_strings();
     /** Temporary hack... */
-    string create_charstring_literals(Common::Module *p_mod);
+    string create_charstring_literals(Common::Module *p_mod, string& preamble);
     virtual void dump(unsigned level) const;
 
     /** Called by Value::get_value_refd_last() */
diff --git a/compiler2/ttcn3/Statement.cc b/compiler2/ttcn3/Statement.cc
index aa2e8cba767530479315f1d89dc392af9fd51b74..1563245199747363599238f9af7f6aa8840a5478 100644
--- a/compiler2/ttcn3/Statement.cc
+++ b/compiler2/ttcn3/Statement.cc
@@ -5028,7 +5028,7 @@ error:
               // make sure all possible indices are allowed by the element 
               // type's subtype
               for (size_t i = 0; i < nof_dims; ++i) {
-                Error_Context cntxt(p_index_ref, "In dimension #%lu",
+                Error_Context context(p_index_ref, "In dimension #%lu",
                   (unsigned long)(i + 1));
                 ArrayDimension* dim = p_array_dims->get_dim_byIndex(i);
                 for (size_t j = 0; j < dim->get_size(); ++j) {
diff --git a/compiler2/ttcn3/TtcnTemplate.cc b/compiler2/ttcn3/TtcnTemplate.cc
index c507d3cc079535abc7ef5dedb3323a9c1d01f742..44a8ebcf2d1e30915677ae2ecf49004c5c53793e 100644
--- a/compiler2/ttcn3/TtcnTemplate.cc
+++ b/compiler2/ttcn3/TtcnTemplate.cc
@@ -3109,10 +3109,14 @@ end:
     case BSTR_PATTERN:
     case HSTR_PATTERN:
     case OSTR_PATTERN:
-    case CSTR_PATTERN:
-    case USTR_PATTERN:
       str = mputprintf(str, "%s = %s;\n", name, get_single_expr(false).c_str());
-      break;
+      break;  
+    case CSTR_PATTERN:
+    case USTR_PATTERN: {
+      string preamble;
+      string expr = generate_code_str_pattern(false, preamble);
+      str = mputprintf(str, "%s%s = %s;\n", preamble.c_str(), name, expr.c_str());
+      break; }
     case SPECIFIC_VALUE:
       if (get_code_section() == CS_POST_INIT)
         str = u.specific_value->rearrange_init_code(str, my_scope->get_scope_mod_gen());
@@ -4846,10 +4850,11 @@ compile_time:
     case BSTR_PATTERN:
     case HSTR_PATTERN:
     case OSTR_PATTERN:
-    case CSTR_PATTERN:
-    case USTR_PATTERN:
     case TEMPLATE_NOTUSED:
       return true;
+    case CSTR_PATTERN: // Some preamble needed when \N{ref} used
+    case USTR_PATTERN:
+      return false;
     case SPECIFIC_VALUE:
       return u.specific_value->has_single_expr();
     case TEMPLATE_REFD: {
@@ -4893,6 +4898,25 @@ compile_time:
     }
   }
 
+  
+  string Template::generate_code_str_pattern(bool cast_needed, string& preamble) {
+    if (cast_needed && (length_restriction || is_ifpresent))
+      FATAL_ERROR("Template::generate_code_str_pattern()");
+    string ret_val;
+    switch(templatetype) {
+      case CSTR_PATTERN:
+      case USTR_PATTERN:
+        ret_val = u.pstring
+        ->create_charstring_literals(get_my_scope()->get_scope_mod_gen(), preamble);
+        break;
+      default:
+        FATAL_ERROR("Template::generate_code_str_pattern()");
+    }
+    if (cast_needed) ret_val = my_governor->get_genname_template(my_scope) +
+      "(" + ret_val + ")";
+    return ret_val;
+  }
+  
   string Template::get_single_expr(bool cast_needed)
   {
     if (cast_needed && (length_restriction || is_ifpresent))
@@ -4955,10 +4979,6 @@ compile_time:
     case OSTR_PATTERN:
       return get_my_scope()->get_scope_mod_gen()
         ->add_octetstring_pattern(*u.pattern);
-    case CSTR_PATTERN:
-    case USTR_PATTERN:
-      return u.pstring
-        ->create_charstring_literals(get_my_scope()->get_scope_mod_gen());
     default:
       FATAL_ERROR("Template::get_single_expr()");
     }
diff --git a/compiler2/ttcn3/TtcnTemplate.hh b/compiler2/ttcn3/TtcnTemplate.hh
index 2742ffb60bb979912eb1f2914b1019f9b5da47c6..92520ac95831f1b29be87827d3cb950f069885a6 100644
--- a/compiler2/ttcn3/TtcnTemplate.hh
+++ b/compiler2/ttcn3/TtcnTemplate.hh
@@ -480,6 +480,8 @@ namespace Ttcn {
 
     char *generate_code_init_all_from(char *str, const char *name);
     char *generate_code_init_all_from_list(char *str, const char *name);
+    
+    string generate_code_str_pattern(bool cast_needed, string& preamble);
 
     /** Helper function for \a generate_code_expr() and get_single_expr().
      * It handles the invoke operation. */
diff --git a/compiler2/ttcn3/pstring_la.l b/compiler2/ttcn3/pstring_la.l
index da5e3d8b91dca7831febcb0eaad1d1a086c0f540..ec616f400f0aea1b8e29bbde45c21d165ba05732 100644
--- a/compiler2/ttcn3/pstring_la.l
+++ b/compiler2/ttcn3/pstring_la.l
@@ -182,7 +182,7 @@ if (in_set) {
     Location loc(current_file, old_line, old_column, current_line, current_column);
     if (ref) {
       ref->set_location(loc);
-      ps->addRef(ref);
+      ps->addRef(ref, FALSE);
     } else {
       loc.error("Invalid reference expression");
     }
@@ -213,26 +213,42 @@ if (in_set) {
   while (isalnum(yytext[id_begin + id_len]) || yytext[id_begin + id_len] == '_')
     id_len++;
   string id_str(id_len, yytext + id_begin);
-  /*
+  
   Ttcn::Reference *ref = new Ttcn::Reference(new Identifier(
     Identifier::ID_TTCN, id_str));
-  ref->set_location(loc);
-  ps->addRefdCharSet(ref);
-  */
+  ps->addRef(ref, TRUE);
+  
   int first_line = current_line, first_column = current_column;
   UPDATE_LOCATION(0, yyleng);
   Location loc(current_file, first_line, first_column, current_line,
     current_column);
+  ref->set_location(loc);
   if (Identifier::is_reserved_word(id_str, Identifier::ID_TTCN)) {
     loc.error("Invalid character set reference: `%s' is a reserved word in "
       "TTCN-3", id_str.c_str());
   } else if (in_set) {
     loc.warning("Character set reference `\\N{%s}' is not supported, "
       "dropped out from the set", id_str.c_str());
-  } else {
+  }
+}
+
+
+"\\N"{WS}"{"{WS}"universal"{WS}"charstring"{WS}"}" {
+  /** The third {WS} is optional but if it's empty then the previous rule catches it**/
+  string id_str("universal charstring");
+  
+  Ttcn::Reference *ref = new Ttcn::Reference(new Identifier(
+    Identifier::ID_TTCN, id_str));
+  ps->addRef(ref, TRUE);
+  
+  int first_line = current_line, first_column = current_column;
+  UPDATE_LOCATION(0, yyleng);
+  Location loc(current_file, first_line, first_column, current_line,
+    current_column);
+  ref->set_location(loc);
+  if (in_set) {
     loc.warning("Character set reference `\\N{%s}' is not supported, "
-      "substituted with `?'", id_str.c_str());
-    ps->addChar('?');
+      "dropped out from the set", id_str.c_str());
   }
 }
 
diff --git a/function_test/Semantic_Analyser/Makefile.semantic b/function_test/Semantic_Analyser/Makefile.semantic
index 98adb3425c09d7528f8f067d21b920a66987a6fd..acfcce783b3a0bb2b98aa5ec659ea52ed9c2374f 100644
--- a/function_test/Semantic_Analyser/Makefile.semantic
+++ b/function_test/Semantic_Analyser/Makefile.semantic
@@ -11,7 +11,7 @@
 #   Ormandi, Matyas
 #
 ##############################################################################
-SADIRS := ver xer encode param template any_from
+SADIRS := ver xer encode param template any_from pattern_ref
 ifeq ($(RT2), yes)
 SADIRS += deprecated
 endif
diff --git a/function_test/Semantic_Analyser/pattern_ref/Makefile b/function_test/Semantic_Analyser/pattern_ref/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..895b6a5b94888a0f8c7dd0d149825c99ec6fcc4d
--- /dev/null
+++ b/function_test/Semantic_Analyser/pattern_ref/Makefile
@@ -0,0 +1,12 @@
+##############################################################################
+# Copyright (c) 2000-2016 Ericsson Telecom AB
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#   Bence Janos Szabo
+#
+##############################################################################
+include ../common.mk
diff --git a/function_test/Semantic_Analyser/pattern_ref/pattern_ref_SE.ttcn b/function_test/Semantic_Analyser/pattern_ref/pattern_ref_SE.ttcn
new file mode 100644
index 0000000000000000000000000000000000000000..823412d990aba967a13e74b1bd4b7a7c42aca663
--- /dev/null
+++ b/function_test/Semantic_Analyser/pattern_ref/pattern_ref_SE.ttcn
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * Copyright (c) 2000-2016 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Szabo, Bence Janos
+ *
+ ******************************************************************************/
+module pattern_ref_SE { //^In TTCN-3 module//
+
+const charstring c_v := "a";
+const charstring c_v2 := "aa";
+template charstring c_v3 := "a";
+template charstring c_v4 := "aa";
+
+template charstring ct := pattern "\N{c_v}";
+template charstring ct2 := pattern "\N{c_v2}"; //^In template definition \`ct2\'// //^In character string pattern// //^error\: The length of the charstring must be of length one\, when it is being referenced in a pattern with \\N\{ref\}//
+template charstring ct3 := pattern "\N{c_v3}";
+template charstring ct4 := pattern "\N{c_v4}"; //^In template definition \`ct4\'// //^In character string pattern// //^error\: The length of the charstring must be of length one\, when it is being referenced in a pattern with \\N\{ref\}//
+
+
+const universal charstring c_u := char(1,2,3,4);
+const universal charstring c_u2 := char(1,2,3,4) & char(5,6,7,8);
+template universal charstring c_u3 := char(1,2,3,4);
+template universal charstring c_u4 := char(1,2,3,4) & char(5,6,7,8);
+
+template universal charstring tu := pattern "\N{c_u}";
+template universal charstring tu2 := pattern "\N{c_u2}"; //^In template definition \`tu2\'// //^In universal string pattern// //^error\: The length of the universal charstring must be of length one\, when it is being referenced in a pattern with \\N\{ref\}//
+template universal charstring tu3 := pattern "\N{c_u3}";
+template universal charstring tu4 := pattern "\N{c_u4}"; //^In template definition \`tu4\'// //^In universal string pattern// //^error\: The length of the universal charstring must be of length one\, when it is being referenced in a pattern with \\N\{ref\}//
+
+
+modulepar charstring c_m := "a";
+modulepar charstring c_m2 := "aa";
+
+template charstring tm1 := pattern "\N{c_m}";
+template charstring tm2 := pattern "\N{c_m2}"; // Not known at compile time
+
+
+template universal charstring c_u5 := char(1,2,3,4); //^error\: This string value cannot contain multiple\-byte characters\, but it has quadruple char\(1\, 2\, 3\, 4\) at index 0$//
+template charstring ct5 := pattern "\N{c_u5}"; //^In template definition \`ct5\'// //^In character string pattern// //^error\: Charstring pattern\: Type of the referenced template \'c_u5\' should be \'charstring\'//
+
+template charstring ct6 := ?;
+template charstring ct7 := *;
+template charstring ct8 := pattern "abc";
+
+template charstring ct9 := pattern "\N{ct6}"; //^In template definition \`ct9\'// //^In character string pattern// //^error\: Charstring pattern\: Unable to resolve referenced \'ct6\' to character string type\. \'any value\' template cannot be used//
+template charstring ct10 := pattern "\N{ct7}"; //^In template definition \`ct10\'// //^In character string pattern// //^error\: Charstring pattern\: Unable to resolve referenced \'ct7\' to character string type\. \'any or omit\' template cannot be used//
+template charstring ct11 := pattern "\N{ct8}"; //^In template definition \`ct11\'// //^In character string pattern// //^error\: Charstring pattern\: Unable to resolve referenced \'ct8\' to character string type\. \'character string pattern\' template cannot be used//
+
+}
diff --git a/function_test/Semantic_Analyser/pattern_ref/t b/function_test/Semantic_Analyser/pattern_ref/t
new file mode 100755
index 0000000000000000000000000000000000000000..3a4b58ec16cf2f1390a36c7a92f8823e3b94b425
--- /dev/null
+++ b/function_test/Semantic_Analyser/pattern_ref/t
@@ -0,0 +1,9 @@
+#!/usr/bin/perl
+# note this is called through "perl -w"
+use strict;
+
+my $self = $0;
+$self =~ s!/t!!;
+
+exec('make check --no-print-directory -s -C ' . $self);
+
diff --git a/regression_test/Makefile b/regression_test/Makefile
index 096632bc91a33200636407b7f84988f397d68d97..e21460f9760f71383a830537eb85811b3a0f0f3e 100644
--- a/regression_test/Makefile
+++ b/regression_test/Makefile
@@ -47,7 +47,7 @@ macros visibility hexstrOper ucharstrOper objidOper CRTR00015758 slider \
 XML ipv6 implicitOmit testcase_defparam transparent HQ16404 cfgFile \
 all_from lazyEval tryCatch text2ttcn json junitlogger ttcn2json profiler templateOmit \
 customEncoding makefilegen uidChars checkstate hostid templateIstemplatekind \
-selectUnion templateExclusiveRange any_from
+selectUnion templateExclusiveRange any_from templatePatternRef
 
 ifdef DYN
 DIRS += loggerplugin
diff --git a/regression_test/templatePatternRef/Makefile b/regression_test/templatePatternRef/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..d259ad7a3bd1cfa49b68c66e846ca280797945cb
--- /dev/null
+++ b/regression_test/templatePatternRef/Makefile
@@ -0,0 +1,56 @@
+##############################################################################
+# Copyright (c) 2000-2016 Ericsson Telecom AB
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#   Szabo, Bence Janos
+#
+##############################################################################
+TOPDIR := ..
+include $(TOPDIR)/Makefile.regression
+
+.SUFFIXES: .ttcn .hh
+.PHONY: all clean dep run
+
+TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX)
+
+TTCN3_MODULES = TemplatePatternRefTest.ttcn
+
+GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc)
+GENERATED_HEADERS = $(GENERATED_SOURCES:.cc=.hh)
+ifdef CODE_SPLIT
+GENERATED_SOURCES := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), .cc _seq.cc _set.cc  _seqof.cc _setof.cc _union.cc))
+else ifdef SPLIT_TO_SLICES
+POSTFIXES := $(foreach file, $(SPLIT_TO_SLICES), $(addsuffix $(file), _part_))
+POSTFIXES := $(foreach file, $(POSTFIXES), $(addprefix $(file), .cc))
+GENERATED_SOURCES2 := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), $(POSTFIXES)))
+GENERATED_SOURCES += $(GENERATED_SOURCES2)
+endif
+
+OBJECTS = $(GENERATED_SOURCES:.cc=.o)
+
+TARGET = TemplatePatternRefTest$(EXESUFFIX)
+
+all: $(TARGET)
+
+$(TARGET): $(GENERATED_SOURCES) $(USER_SOURCES)
+	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ -L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) -L$(OPENSSL_DIR)/lib -lcrypto $($(PLATFORM)_LIBS)
+
+$(GENERATED_SOURCES) $(GENERATED_HEADERS): $(TTCN3_MODULES)
+	$(TTCN3_COMPILER) $^
+
+clean distclean:
+	-rm -f $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \
+	$(GENERATED_SOURCES) *.log Makefile.bak
+
+dep: $(GENERATED_SOURCES)
+	makedepend $(CPPFLAGS) $(GENERATED_SOURCES)
+
+run: $(TARGET)
+	./$^ config.cfg
+
+.NOTPARALLEL:
+
diff --git a/regression_test/templatePatternRef/TemplatePatternRefTest.ttcn b/regression_test/templatePatternRef/TemplatePatternRefTest.ttcn
new file mode 100644
index 0000000000000000000000000000000000000000..7882219be766cea963887b4fc0ec0f0024161d41
--- /dev/null
+++ b/regression_test/templatePatternRef/TemplatePatternRefTest.ttcn
@@ -0,0 +1,1160 @@
+/******************************************************************************
+ * Copyright (c) 2000-2016 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Bence Janos Szabo
+ *
+ ******************************************************************************/
+module TemplatePatternRefTest {
+
+type component EmptyCT {}
+
+modulepar charstring m_r := "r";
+
+
+type charstring MyCharRange ("a".."z");
+type charstring MyCharList ("a", "z");
+type MyCharList MyCharList2 ("a");
+type MyCharList2 MyCharList3;
+type MyCharRange MyCharRange2 ("b".."g");
+type MyCharRange2 MyCharRange3;
+type MyCharRange3 MyCharRange4;
+type charstring MyCharRangeNormal;
+type MyCharRangeNormal MyCharRangeNormal2;
+const charstring c_myCharR := "r";
+template charstring t_char_temp := "r";
+
+
+template charstring mw_myTempPatt1 := pattern "\N{c_myCharR}";
+template charstring mw_myTempPatt2 := pattern "\N{t_char_temp}";
+template charstring mw_myTempPatt4 := pattern "\N{m_r}";
+
+testcase tc_single_char() runs on EmptyCT {
+  if (not match("r", mw_myTempPatt1)) {
+    setverdict(fail);
+   }
+
+   if (match("s", mw_myTempPatt1)) {
+    setverdict(fail);
+   }
+
+   if (not match("r", mw_myTempPatt2)) {
+    setverdict(fail);
+   }
+
+   if (match("s", mw_myTempPatt2)) {
+    setverdict(fail);
+   }
+
+   if (not match("r", mw_myTempPatt4)) {
+    setverdict(fail);
+   }
+
+   if (match("s", mw_myTempPatt4)) {
+    setverdict(fail);
+   }
+
+   setverdict(pass);
+}
+
+
+
+template charstring mw_myTempPatt5 := pattern "v\N{c_myCharR}v";
+template charstring mw_myTempPatt6 := pattern "v\N{t_char_temp}v";
+template charstring mw_myTempPatt8 := pattern "v\N{m_r}v";
+
+
+testcase tc_single_char_middle() runs on EmptyCT {
+   if (not match("vrv", mw_myTempPatt5)) {
+    setverdict(fail);
+   }
+
+   if (match("vsv", mw_myTempPatt5)) {
+    setverdict(fail);
+   }
+
+   if (not match("vrv", mw_myTempPatt6)) {
+    setverdict(fail);
+   }
+
+   if (match("vsv", mw_myTempPatt6)) {
+    setverdict(fail);
+   }
+
+   if (not match("vrv", mw_myTempPatt8)) {
+    setverdict(fail);
+   }
+
+   if (match("vsv", mw_myTempPatt8)) {
+    setverdict(fail);
+   }
+
+   setverdict(pass);
+}
+
+
+template charstring mw_myTempPatt10 := pattern "\N{MyCharRange}";
+template charstring mw_myTempPatt11 := pattern "\N{MyCharRange2}";
+template charstring mw_myTempPatt12 := pattern "\N{MyCharRange3}";
+template charstring mw_myTempPatt13 := pattern "\N{MyCharRange4}";
+template charstring mw_myTempPatt14 := pattern "\N{MyCharRangeNormal}";
+template charstring mw_myTempPatt20 := pattern "\N{MyCharRangeNormal2}";
+
+testcase tc_type_range() runs on EmptyCT {
+  if (not match("a", mw_myTempPatt10)) {
+    setverdict(fail);
+  }
+
+  if (not match("r", mw_myTempPatt10)) {
+    setverdict(fail);
+  }
+
+  if (not match("z", mw_myTempPatt10)) {
+    setverdict(fail);
+  }
+
+   if (match("aa", mw_myTempPatt10)) {
+    setverdict(fail);
+   }
+
+   if (not match("c", mw_myTempPatt11)) {
+    setverdict(fail);
+   }
+
+   if (match("aa", mw_myTempPatt11)) {
+    setverdict(fail);
+   }
+
+   if (not match("c", mw_myTempPatt12)) {
+    setverdict(fail);
+   }
+
+   if (match("y", mw_myTempPatt12)) {
+    setverdict(fail);
+   }
+
+   if (match("a", mw_myTempPatt12)) {
+    setverdict(fail);
+   }
+
+   if (not match("b", mw_myTempPatt12)) {
+    setverdict(fail);
+   }
+
+   if (not match("g", mw_myTempPatt12)) {
+    setverdict(fail);
+   }
+
+   if (match("h", mw_myTempPatt12)) {
+    setverdict(fail);
+   }
+
+   if (not match("c", mw_myTempPatt13)) {
+    setverdict(fail);
+   }
+
+   if (match("y", mw_myTempPatt13)) {
+    setverdict(fail);
+   }
+
+   if (not match("g", mw_myTempPatt14)) { // any char
+    setverdict(fail);
+   }
+
+   if (match("gg", mw_myTempPatt14)) {
+    setverdict(fail);
+   }
+
+   if (not match("g", mw_myTempPatt20)) { // any char
+    setverdict(fail);
+   }
+
+   if (match("gg", mw_myTempPatt20)) {
+    setverdict(fail);
+   }
+
+   setverdict(pass);
+}
+
+
+
+template charstring mw_myTempPatt15 := pattern "v\N{MyCharRange}v";
+template charstring mw_myTempPatt16 := pattern "v\N{MyCharRange2}v";
+template charstring mw_myTempPatt17 := pattern "v\N{MyCharRange3}v";
+template charstring mw_myTempPatt18 := pattern "v\N{MyCharRange4}v";
+template charstring mw_myTempPatt19 := pattern "v\N{MyCharRangeNormal}v";
+template charstring mw_myTempPatt21 := pattern "v\N{MyCharRangeNormal2}v";
+
+testcase tc_type_range_middle() runs on EmptyCT {
+  if (not match("vrv", mw_myTempPatt15)) {
+    setverdict(fail);
+   }
+
+   if (match("vaav", mw_myTempPatt15)) {
+    setverdict(fail);
+   }
+
+   if (not match("vcv", mw_myTempPatt16)) {
+    setverdict(fail);
+   }
+
+   if (match("vaav", mw_myTempPatt16)) {
+    setverdict(fail);
+   }
+
+   if (not match("vcv", mw_myTempPatt17)) {
+    setverdict(fail);
+   }
+
+   if (match("vyv", mw_myTempPatt17)) {
+    setverdict(fail);
+   }
+
+   if (not match("vcv", mw_myTempPatt18)) {
+    setverdict(fail);
+   }
+
+   if (match("vyv", mw_myTempPatt18)) {
+    setverdict(fail);
+   }
+
+   if (not match("vgv", mw_myTempPatt19)) { // any char
+    setverdict(fail);
+   }
+
+   if (match("vggv", mw_myTempPatt19)) {
+    setverdict(fail);
+   }
+
+      if (not match("vgv", mw_myTempPatt21)) { // any char
+    setverdict(fail);
+   }
+
+   if (match("vggv", mw_myTempPatt21)) {
+    setverdict(fail);
+   }
+
+   setverdict(pass);
+}
+
+
+template charstring mw_myTempPatt22 := pattern "\N{MyCharList}";
+template charstring mw_myTempPatt23 := pattern "\N{MyCharList2}";
+template charstring mw_myTempPatt24 := pattern "\N{MyCharList3}";
+
+testcase tc_type_list() runs on EmptyCT {
+  if (not match("a", mw_myTempPatt22)) {
+    setverdict(fail);
+  }
+
+  if (not match("z", mw_myTempPatt22)) {
+    setverdict(fail);
+  }
+
+  if (match("g", mw_myTempPatt22)) {
+    setverdict(fail);
+  }
+
+  if (not match("a", mw_myTempPatt23)) {
+    setverdict(fail);
+  }
+
+  if (match("z", mw_myTempPatt23)) {
+    setverdict(fail);
+  }
+
+  if (not match("a", mw_myTempPatt24)) {
+    setverdict(fail);
+  }
+
+  if (match("z", mw_myTempPatt24)) {
+    setverdict(fail);
+  }
+
+  setverdict(pass);
+
+}
+
+
+
+template charstring mw_myTempPatt25 := pattern "v\N{MyCharList}v";
+template charstring mw_myTempPatt26 := pattern "v\N{MyCharList2}v";
+template charstring mw_myTempPatt27 := pattern "v\N{MyCharList3}v";
+
+
+testcase tc_type_list_middle() runs on EmptyCT {
+  if (not match("vav", mw_myTempPatt25)) {
+    setverdict(fail);
+  }
+
+  if (not match("vzv", mw_myTempPatt25)) {
+    setverdict(fail);
+  }
+
+  if (match("vgv", mw_myTempPatt26)) {
+    setverdict(fail);
+  }
+
+  if (not match("vav", mw_myTempPatt26)) {
+    setverdict(fail);
+  }
+
+  if (match("vzv", mw_myTempPatt26)) {
+    setverdict(fail);
+  }
+
+  if (not match("vav", mw_myTempPatt27)) {
+    setverdict(fail);
+  }
+
+  if (match("vzv", mw_myTempPatt27)) {
+    setverdict(fail);
+  }
+
+  setverdict(pass);
+
+}
+
+
+//===========================================================================//
+
+
+modulepar universal charstring m_Unir := "r";
+
+type universal charstring MyUniCharRange ("a".."z");
+type universal charstring MyUniCharList ("a", "z", char(1,2,3,4));
+type MyUniCharList MyUniCharList2 ("a");
+type MyUniCharList2 MyUniCharList3;
+type MyUniCharRange MyUniCharRange2 ("b".."g");
+type MyUniCharRange2 MyUniCharRange3;
+type MyUniCharRange3 MyUniCharRange4;
+type universal charstring MyUniCharRangeNormal;
+type MyUniCharRangeNormal MyUniCharRangeNormal2;
+const universal charstring c_myUniCharR := "r";
+template universal charstring t_unichar_temp := "r";
+
+
+template universal charstring unimw_myTempPatt1 := pattern "\N{c_myUniCharR}";
+template universal charstring unimw_myTempPatt2 := pattern "\N{t_unichar_temp}";
+template universal charstring unimw_myTempPatt4 := pattern "\N{m_Unir}";
+
+testcase tc_single_unichar() runs on EmptyCT {
+  var universal charstring str := "r";
+  if (not match(str, unimw_myTempPatt1)) {
+    setverdict(fail);
+   }
+
+   str := "s";
+   if (match(str, unimw_myTempPatt1)) {
+    setverdict(fail);
+   }
+
+   str := "r";
+   if (not match(str, unimw_myTempPatt2)) {
+    setverdict(fail);
+   }
+
+   str := "s";
+   if (match(str, unimw_myTempPatt2)) {
+    setverdict(fail);
+   }
+
+   str := "r";
+   if (not match(str, unimw_myTempPatt4)) {
+    setverdict(fail);
+   }
+
+   str := "s";
+   if (match(str, unimw_myTempPatt4)) {
+    setverdict(fail);
+   }
+
+   setverdict(pass);
+}
+
+template universal charstring unimw_myTempPatt5 := pattern "v\N{c_myUniCharR}v";
+template universal charstring unimw_myTempPatt6 := pattern "v\N{t_unichar_temp}v";
+template universal charstring unimw_myTempPatt8 := pattern "v\N{m_Unir}v";
+
+testcase tc_single_unichar_middle() runs on EmptyCT {
+   var universal charstring str := "vrv";
+   if (not match(str, unimw_myTempPatt5)) {
+    setverdict(fail);
+   }
+
+   str := "vsv";
+   if (match(str, unimw_myTempPatt5)) {
+    setverdict(fail);
+   }
+
+   str := "vrv";
+   if (not match(str, unimw_myTempPatt6)) {
+    setverdict(fail);
+   }
+
+   str := "vsv";
+   if (match(str, unimw_myTempPatt6)) {
+    setverdict(fail);
+   }
+
+   str := "vrv";
+   if (not match(str, unimw_myTempPatt8)) {
+    setverdict(fail);
+   }
+
+   str := "vsv";
+   if (match(str, unimw_myTempPatt8)) {
+    setverdict(fail);
+   }
+
+   setverdict(pass);
+}
+
+template universal charstring unimw_myTempPatt10 := pattern "\N{MyUniCharRange}";
+template universal charstring unimw_myTempPatt11 := pattern "\N{MyUniCharRange2}";
+template universal charstring unimw_myTempPatt12 := pattern "\N{MyUniCharRange3}";
+template universal charstring unimw_myTempPatt13 := pattern "\N{MyUniCharRange4}";
+template universal charstring unimw_myTempPatt14 := pattern "\N{MyUniCharRangeNormal}";
+template universal charstring unimw_myTempPatt20 := pattern "\N{MyUniCharRangeNormal2}";
+
+testcase tc_unitype_range() runs on EmptyCT {
+  var universal charstring str := "r";
+  if (not match(str, unimw_myTempPatt10)) {
+    setverdict(fail);
+   }
+
+   str := "aa";
+   if (match(str, unimw_myTempPatt10)) {
+    setverdict(fail);
+   }
+
+   str := "a";
+   if (not match(str, unimw_myTempPatt10)) {
+    setverdict(fail);
+   }
+
+   str := "z";
+   if (not match(str, unimw_myTempPatt10)) {
+    setverdict(fail);
+   }
+
+   str := "c";
+   if (not match(str, unimw_myTempPatt11)) {
+    setverdict(fail);
+   }
+
+   str := "aa";
+   if (match(str, unimw_myTempPatt11)) {
+    setverdict(fail);
+   }
+
+   str := "c";
+   if (not match(str, unimw_myTempPatt12)) {
+    setverdict(fail);
+   }
+
+   str := "y";
+   if (match(str, unimw_myTempPatt12)) {
+    setverdict(fail);
+   }
+
+   str := "a";
+   if (match(str, unimw_myTempPatt12)) {
+    setverdict(fail);
+   }
+
+   str := "b";
+   if (not match(str, unimw_myTempPatt12)) {
+    setverdict(fail);
+   }
+
+   str := "g";
+   if (not match(str, unimw_myTempPatt12)) {
+    setverdict(fail);
+   }
+
+   str := "h";
+   if (match(str, unimw_myTempPatt12)) {
+    setverdict(fail);
+   }
+
+   str := "c";
+   if (not match(str, unimw_myTempPatt13)) {
+    setverdict(fail);
+   }
+
+   str := "y";
+   if (match(str, unimw_myTempPatt13)) {
+    setverdict(fail);
+   }
+
+   str := "g";
+   if (not match(str, unimw_myTempPatt14)) { // any char
+    setverdict(fail);
+   }
+
+   str := "gg";
+   if (match(str, unimw_myTempPatt14)) {
+    setverdict(fail);
+   }
+
+   str := "g";
+   if (not match(str, unimw_myTempPatt20)) { // any char
+    setverdict(fail);
+   }
+
+   str := "gg";
+   if (match(str, unimw_myTempPatt20)) {
+    setverdict(fail);
+   }
+
+   setverdict(pass);
+}
+
+template universal charstring unimw_myTempPatt15 := pattern "v\N{MyUniCharRange}v";
+template universal charstring unimw_myTempPatt16 := pattern "v\N{MyUniCharRange2}v";
+template universal charstring unimw_myTempPatt17 := pattern "v\N{MyUniCharRange3}v";
+template universal charstring unimw_myTempPatt18 := pattern "v\N{MyUniCharRange4}v";
+template universal charstring unimw_myTempPatt19 := pattern "v\N{MyUniCharRangeNormal}v";
+template universal charstring unimw_myTempPatt21 := pattern "v\N{MyUniCharRangeNormal2}v";
+
+testcase tc_unitype_range_middle() runs on EmptyCT {
+  var universal charstring str := "vrv";
+  if (not match(str, unimw_myTempPatt15)) {
+    setverdict(fail);
+   }
+
+   str := "vaav";
+   if (match(str, unimw_myTempPatt15)) {
+    setverdict(fail);
+   }
+
+   str := "vcv";
+   if (not match(str, unimw_myTempPatt16)) {
+    setverdict(fail);
+   }
+
+   str := "vaav";
+   if (match(str, unimw_myTempPatt16)) {
+    setverdict(fail);
+   }
+
+   str := "vcv";
+   if (not match(str, unimw_myTempPatt17)) {
+    setverdict(fail);
+   }
+
+   str := "vyv";
+   if (match(str, unimw_myTempPatt17)) {
+    setverdict(fail);
+   }
+
+   str := "vcv";
+   if (not match(str, unimw_myTempPatt18)) {
+    setverdict(fail);
+   }
+
+   str := "vyv";
+   if (match(str, unimw_myTempPatt18)) {
+    setverdict(fail);
+   }
+
+   str := "vgv";
+   if (not match(str, unimw_myTempPatt19)) { // any char
+    setverdict(fail);
+   }
+
+   str := "vggv";
+   if (match(str, unimw_myTempPatt19)) {
+    setverdict(fail);
+   }
+ 
+   str := "vgv";
+   if (not match(str, unimw_myTempPatt21)) { // any char
+    setverdict(fail);
+   }
+
+   str := "vggv";
+   if (match(str, unimw_myTempPatt21)) {
+    setverdict(fail);
+   }
+
+   setverdict(pass);
+}
+
+
+template universal charstring unimw_myTempPatt22 := pattern "\N{MyUniCharList}";
+template universal charstring unimw_myTempPatt23 := pattern "\N{MyUniCharList2}";
+template universal charstring unimw_myTempPatt24 := pattern "\N{MyUniCharList3}";
+
+testcase tc_unitype_list() runs on EmptyCT {
+  var universal charstring str := "a";
+  if (not match(str, unimw_myTempPatt22)) {
+    setverdict(fail);
+  }
+
+  str := "z";
+  if (not match(str, unimw_myTempPatt22)) {
+    setverdict(fail);
+  }
+
+  str := char(1,2,3,4);
+  if (not match(str, unimw_myTempPatt22)) {
+    setverdict(fail);
+  }
+
+  str := "g";
+  if (match(str, unimw_myTempPatt22)) {
+    setverdict(fail);
+  }
+
+  str := "a";
+  if (not match(str, unimw_myTempPatt23)) {
+    setverdict(fail);
+  }
+
+  str := "z";
+  if (match(str, unimw_myTempPatt23)) {
+    setverdict(fail);
+  }
+
+  str := "a";
+  if (not match(str, unimw_myTempPatt24)) {
+    setverdict(fail);
+  }
+
+  str := "z";
+  if (match(str, unimw_myTempPatt24)) {
+    setverdict(fail);
+  }
+
+  setverdict(pass);
+
+}
+
+template universal charstring unimw_myTempPatt25 := pattern "v\N{MyUniCharList}v";
+template universal charstring unimw_myTempPatt26 := pattern "v\N{MyUniCharList2}v";
+template universal charstring unimw_myTempPatt27 := pattern "v\N{MyUniCharList3}v";
+
+testcase tc_unitype_list_middle() runs on EmptyCT {
+  var universal charstring str := "vav";
+  if (not match(str, unimw_myTempPatt25)) {
+    setverdict(fail);
+  }
+
+  str := "vzv";
+  if (not match(str, unimw_myTempPatt25)) {
+    setverdict(fail);
+  }
+
+  str := "vgv";
+  if (match(str, unimw_myTempPatt26)) {
+    setverdict(fail);
+  }
+
+  str := "vav";
+  if (not match(str, unimw_myTempPatt26)) {
+    setverdict(fail);
+  }
+
+  str := "vzv";
+  if (match(str, unimw_myTempPatt26)) {
+    setverdict(fail);
+  }
+
+  str := "vav";
+  if (not match(str, unimw_myTempPatt27)) {
+    setverdict(fail);
+  }
+
+  str := "vzv";
+  if (match(str, unimw_myTempPatt27)) {
+    setverdict(fail);
+  }
+
+  setverdict(pass);
+
+}
+
+//===========================================================================//
+
+template charstring t_char := pattern "\N{charstring}";
+template universal charstring t_unichar := pattern "\N{universal charstring}";
+
+testcase tc_special() runs on EmptyCT {
+  if (not match("s", t_char)) {
+    setverdict(fail);
+  }
+
+  if (match("ss", t_char)) {
+    setverdict(fail);
+  }
+
+  var universal charstring str := "s";
+  if (not match(str, t_unichar)) {
+    setverdict(fail);
+  }
+
+  str := "ss";
+  if (match(str, t_unichar)) {
+    setverdict(fail);
+  }
+
+  setverdict(pass);
+}
+
+
+//===========================================================================//
+
+modulepar charstring m_charstring;
+modulepar universal charstring m_unicharstring;
+modulepar template charstring m_charstring_template;
+modulepar template universal charstring m_unicharstring_template;
+
+testcase tc_modulepar() runs on EmptyCT {
+  var template charstring t_chartemp := pattern "\N{m_charstring}";
+
+  if (not match("r", t_chartemp)) {
+    setverdict(fail);
+  }
+
+  if (match("s", t_chartemp)) {
+    setverdict(fail);
+  }
+
+  t_chartemp := pattern "\N{m_charstring_template}";
+  if (not match("r", t_chartemp)) {
+    setverdict(fail);
+  }
+
+  if (match("s", t_chartemp)) {
+    setverdict(fail);
+  }
+
+  var template universal charstring t_unichartemp := pattern "\N{m_unicharstring}";
+  var universal charstring str := "r";
+  if (not match(str, t_unichartemp)) {
+    setverdict(fail);
+  }
+  
+  str := "s";
+  if (match(str, t_unichartemp)) {
+    setverdict(fail);
+  }
+
+  t_unichartemp := pattern "\N{m_unicharstring_template}";
+  str := "r";
+  if (not match(str, t_unichartemp)) {
+    setverdict(fail);
+  }
+  
+  str := "s";
+  if (match(str, t_unichartemp)) {
+    setverdict(fail);
+  }
+
+  setverdict(pass);
+}
+
+
+// Values not known at compile time
+testcase tc_variable() runs on EmptyCT {
+  var charstring loc_char := "r";
+  var universal charstring loc_unichar := "r";
+  var template charstring loc_chartemp := "r";
+  var template universal charstring loc_unichartemp := "r";
+
+  var template charstring t_chartemp := pattern "\N{loc_char}";
+  if (not match("r", t_chartemp)) {
+    setverdict(fail);
+  }
+
+  if (match("s", t_chartemp)) {
+    setverdict(fail);
+  }
+
+  var universal charstring str := "r";
+  var template universal charstring t_unichartemp := pattern "\N{loc_unichar}";
+  if (not match(str, t_unichartemp)) {
+    setverdict(fail);
+  }
+
+  str := "s";
+  if (match(str, t_unichartemp)) {
+    setverdict(fail);
+  }
+
+  t_chartemp := pattern "\N{loc_chartemp}";
+  if (not match("r", t_chartemp)) {
+    setverdict(fail);
+  }
+
+  if (match("s", t_chartemp)) {
+    setverdict(fail);
+  }
+
+  str := "r";
+  t_unichartemp := pattern "\N{loc_unichartemp}";
+  if (not match(str, t_unichartemp)) {
+    setverdict(fail);
+  }
+
+  str := "s";
+  if (match(str, t_unichartemp)) {
+    setverdict(fail);
+  }
+
+  setverdict(pass);
+}
+
+//===========================================================================//
+
+
+const charstring c_a := "a";
+template charstring t_b := "b";
+type charstring CtoD ("c" .. "d");
+type charstring EorF ("e", "f");
+
+// param1 is "i", param2 is "j"
+testcase tc_complex(charstring param1, template charstring param2) runs on EmptyCT {
+
+  var charstring loc_g := "g";
+  var template charstring t_h := "h";
+
+  var template charstring loc_pattern := pattern "A\N{c_a}\N{c_a}B\N{t_b}\N{t_b}\N{CtoD}\N{CtoD}\N{EorF}\N{EorF}\N{charstring}\N{loc_g}\N{t_h}\N{param1}\N{param1}\N{param2}\N{param2}";
+
+  var charstring str := "AaaBbbcdefYghiijj";
+  if (not match(str, loc_pattern)) {
+    setverdict(fail);
+  }
+
+  setverdict(pass);
+
+}
+
+const universal charstring c_1 := char(1,2,3,4);
+template universal charstring t_2 := char(1,2,3,5);
+type universal charstring FromTo (char(1,1,1,1) .. char(2,2,2,2));
+type universal charstring Either (char(3,3,3,3), char(4,4,4,4));
+
+// param1 is char(7,7,7,7), param2 is char(8,8,8,8)
+testcase tc_complex_unichar(universal charstring param1, template universal charstring param2) runs on EmptyCT {
+  var universal charstring loc_3 := char(5,5,5,5);
+  var template universal charstring loc_4 := char(6,6,6,6);
+
+  var template universal charstring loc_pattern := pattern "A\N{c_1}\N{c_1}B\N{t_2}\N{t_2}\N{FromTo}\N{FromTo}\N{Either}\N{Either}\N{universal charstring}\N{loc_3}\N{loc_4}\N{param1}\N{param1}\N{param2}\N{param2}";
+  
+  var universal charstring str := "A"& char(1,2,3,4) & char(1,2,3,4) & "B" & char(1,2,3,5) & char(1,2,3,5) & char (1,1,1,1) & char(2,2,2,2) & char (3,3,3,3) & char(4,4,4,4) & char(9,9,9,9) & char(5,5,5,5) & char(6,6,6,6) & char(7,7,7,7) & char(7,7,7,7) & char(8,8,8,8) & char(8,8,8,8);
+  if (not match(str, loc_pattern)) {
+    setverdict(fail);
+  }
+
+  setverdict(pass);
+
+}
+
+
+
+//===========================================================================//
+
+
+modulepar charstring m_charstring_bad;
+modulepar charstring m_charstring_bad2;
+modulepar template charstring m_charstring_templ_bad;
+modulepar template charstring m_charstring_templ_bad2;
+modulepar universal charstring m_unicharstring_bad;
+modulepar universal charstring m_unicharstring_bad2;
+modulepar template universal charstring m_unicharstring_templ_bad;
+modulepar template universal charstring m_unicharstring_templ_bad2;
+
+testcase tc_pattern_DTE() runs on EmptyCT {
+
+  // DTE tests with variables 
+
+  var charstring charstr := "aa";
+  var charstring dte_message := "Dynamic test case error: The length of the charstring must be of length one, when it is being referenced in a pattern with \\N{ref}";
+  @try {
+    var template charstring templ := pattern "\N{charstr}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  charstr := "";
+  @try {
+    var template charstring templ := pattern "\N{charstr}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  dte_message := "Dynamic test case error: The length of the universal charstring must be of length one, when it is being referenced in a pattern with \\N{ref}";
+  var universal charstring unicharstr := "aa";
+  @try {
+    var template universal charstring templ := pattern "\N{unicharstr}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  unicharstr := "";
+  @try {
+    var template universal charstring templ := pattern "\N{unicharstr}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  unicharstr := char(1,2,3,4) & char(1,2,3,3);
+  @try {
+    var template universal charstring templ := pattern "\N{unicharstr}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  // DTE tests with templates
+
+  var template charstring charstrtempl := "aa";
+  dte_message := "Dynamic test case error: The length of the charstring must be of length one, when it is being referenced in a pattern with \\N{ref}";
+  @try {
+    var template charstring templ := pattern "\N{charstrtempl}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  charstrtempl := "";
+  @try {
+    var template charstring templ := pattern "\N{charstrtempl}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  dte_message := "Dynamic test case error: The length of the universal charstring must be of length one, when it is being referenced in a pattern with \\N{ref}";
+  var template universal charstring unicharstrtempl := "aa";
+  @try {
+    var template universal charstring templ := pattern "\N{unicharstrtempl}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  unicharstrtempl := "";
+  @try {
+    var template universal charstring templ := pattern "\N{unicharstrtempl}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  unicharstrtempl := char(1,2,3,4) & char(1,2,3,3);
+  @try {
+    var template universal charstring templ := pattern "\N{unicharstrtempl}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  // DTE tests with modulepar variables
+
+  dte_message := "Dynamic test case error: The length of the charstring must be of length one, when it is being referenced in a pattern with \\N{ref}";
+  @try {
+    var template charstring templ := pattern "\N{m_charstring_bad}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  @try {
+    var template charstring templ := pattern "\N{m_charstring_bad2}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  dte_message := "Dynamic test case error: The length of the universal charstring must be of length one, when it is being referenced in a pattern with \\N{ref}";
+  @try {
+    var template universal charstring templ := pattern "\N{m_unicharstring_bad}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  @try {
+    var template universal charstring templ := pattern "\N{m_unicharstring_bad2}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+
+  // DTE tests with modulepar templates
+
+  dte_message := "Dynamic test case error: The length of the charstring must be of length one, when it is being referenced in a pattern with \\N{ref}";
+  @try {
+    var template charstring templ := pattern "\N{m_charstring_templ_bad}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  @try {
+    var template charstring templ := pattern "\N{m_charstring_templ_bad2}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  dte_message := "Dynamic test case error: The length of the universal charstring must be of length one, when it is being referenced in a pattern with \\N{ref}";
+  @try {
+    var template universal charstring templ := pattern "\N{m_unicharstring_templ_bad}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  @try {
+    var template universal charstring templ := pattern "\N{m_unicharstring_templ_bad2}";
+    setverdict(fail, "Expected dynamic test case error when referencing a long string in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+
+  // DTE when non value template used
+
+  dte_message := "Dynamic test case error: Only specific value template allowed in pattern reference with \\N{ref}";
+  @try {
+    var template universal charstring s := pattern "sdf";
+    var template universal charstring templ := pattern "\N{s}";
+    setverdict(fail, "Expected dynamic test case error when referencing a non value template in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  @try {
+    var template universal charstring s := ("a", "b");
+    var template universal charstring templ := pattern "\N{s}";
+    setverdict(fail, "Expected dynamic test case error when referencing a non value template in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  @try {
+    var template universal charstring s := *;
+    var template universal charstring templ := pattern "\N{s}";
+    setverdict(fail, "Expected dynamic test case error when referencing a non value template in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  @try {
+    var template universal charstring s := ?;
+    var template universal charstring templ := pattern "\N{s}";
+    setverdict(fail, "Expected dynamic test case error when referencing a non value template in pattern with \\N{ref} ");
+  }
+  @catch (msg) {
+    if (not match(msg, dte_message)) {
+      setverdict(fail, "Expected error: ", dte_message, ", got: ", msg);
+    }
+  }
+
+  setverdict(pass);
+}
+
+control {
+ 
+ execute(tc_single_char());
+ execute(tc_single_char_middle());
+ execute(tc_type_range());
+ execute(tc_type_range_middle());
+ execute(tc_type_list());
+ execute(tc_type_list_middle());
+
+ execute(tc_single_unichar());
+ execute(tc_single_unichar_middle());
+ execute(tc_unitype_range());
+ execute(tc_unitype_range_middle());
+ execute(tc_unitype_list());
+ execute(tc_unitype_list_middle());
+
+
+ execute(tc_special());
+ execute(tc_modulepar());
+ execute(tc_variable());
+ execute(tc_complex("i", "j"));
+ execute(tc_complex_unichar(char(7,7,7,7), char(8,8,8,8)));
+ execute(tc_pattern_DTE());
+
+}
+
+}
\ No newline at end of file
diff --git a/regression_test/templatePatternRef/config.cfg b/regression_test/templatePatternRef/config.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..2a8abc97f3b8a9ea2ed33685f89e4e9bfccc273e
--- /dev/null
+++ b/regression_test/templatePatternRef/config.cfg
@@ -0,0 +1,28 @@
+###############################################################################
+# Copyright (c) 2000-2016 Ericsson Telecom AB
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#   Bence Janos Szabo
+#
+###############################################################################
+[MODULE_PARAMETERS]
+m_charstring := "r";
+m_unicharstring := "r";
+m_charstring_template := "r";
+m_unicharstring_template := "r";
+
+m_charstring_bad := "";
+m_charstring_bad2 := "aa";
+m_charstring_templ_bad := "";
+m_charstring_templ_bad2 := "aa";
+m_unicharstring_bad := "";
+m_unicharstring_bad2 := char(1,2,5,7) & char(1,3,7,9);
+m_unicharstring_templ_bad := "";
+m_unicharstring_templ_bad2 := char(1,2,5,7) & char(1,3,7,9);
+
+[EXECUTE]
+TemplatePatternRefTest.control