

syntaxdef csharp {

/\s+/m : ;


# inline doc-comment
/\/\/\/(.*)$/m : {
      doccomment(${1});
      region {
         type=comment;
         index=prose;
         findlinks=true;
      }
   }

# multiline doc-comment
/\/\*\*(.*?)\*\//s : {
      doccomment(${1});
      region {
         type=comment;
         index=prose;
         findlinks=true;
      }
   }

context doccomment {
# find xml tag-like things

/  < \/?
   ([\p{N}\p{L}:_-]+)
   ((\s+[\p{N}\p{L}:_-]+((="[^"]*")|(=[^\s>]+))?)*)
   \s*
   \/? >
/mx : {
          region {
            type=commentmeta;
          }
      }
   }

# inline comment
/\/\/.*$/m : {
      region {
         type=comment;
         index=prose;
         findlinks=true;
      }
   }

# multiline comment
/\/\*(.*?)\*\//s : {
      region {
         type=comment;
         index=prose;
         findlinks=true;
      }
   }

# numeric
/(0x[0-9a-f]+l?)|([0-9]+(\.[0-9]*)?|\.[0-9]+)(e(\+|-)?[0-9]+)?(f|l|d)?/i : {
       region {
          type=numeric;
       }
   }

# string literal
/"((\\.|[^"])*?)("|$)/m : {
      region {
         type=string;
      }
      region ${1} {
         index=prose;
      }
   }   

# verbatim string literal
/@"((""|[^"])*?)("|$)/m : {
      region {
         type=string;
      }
      region ${1} {
         index=prose;
      }
   }   


# char literal
/'(\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|\\x[0-9a-fA-F]{1,4}|\\.|.)'/ : {
      region {
        type=char_literal; 
      }
      region ${1} {
         index=word;
      }
   }

# keywords
/(a(bstract|s)|b(ase|ool|reak|yte)|\
c(a(se|tch)|h(ar|ecked)|lass|on(st|tinue))|\
d(e(cimal|fault|legate)|o(|uble))|e(lse|num|\
vent|x(plicit|tern))|f(alse|i(nally|xed)|loat|\
or(|each))|goto|i([fns]|mplicit|nt(|er(face|nal)))|\
lo(ck|ng)|n(amespace|ew|ull)|o(bject|perator|ut|verride)|\
p(arams|r(ivate|otected)|ublic)|re(adonly|f|turn)|s(byte|\
ealed|hort|izeof|t(a(ckalloc|tic)|r(ing|uct))|witch)|\
t(h(is|row)|r(ue|y)|ypeof)|u(int|long|n(checked|safe)|\
s(hort|ing))|v(irtual|o(id|latile))|while)\b/ : {
        region {
          type=keyword;
          index=word;
      }
    }




# preprocessing directive
/^[^\r\n]*#[^\r\n]*(def(ault|ine)|e(l(if|se)|nd(if|region)|rror)|if|line|region|undef|warning).*$/m : {
       region {
         type=preprocessor;
         index=prose;
       } 
  }

# identifier
/[\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}\p{Nl}_][\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}\p{Nl}\p{Nd}\p{Pc}\p{Cf}]*/ : {
      region {
         type=identifier;
         index=word;
      }
    }

}