syntaxdef c {

/\s+/m : ;

# keywords
/(auto|break|c(ase|har|on(st|tinue))|d(efault|o(|uble))|\
e(lse|num|xtern)|f(loat|or)|goto|i(f|nt)|long|re(gister|turn)|\
s(hort|i(gned|zeof)|t(atic|ruct)|witch)|typedef|un(ion|signed)|\
vo(id|latile)|while)\b/ : {
       region {
         type=keyword;
         index=word;
       }
    }


# preprocessor line
/^#.*$/m : {
       region {
         type=keyword;
       }
    }

# char literal
/L?'(\\.|\\[0-7]{3}|\\x[0-9a-fA-F]{2}|.)'/ : {
       region {
          type=char_literal;
       }

    }

# string literal
/L?"/ : {
    context {
        /\\./: ;
        /$/m : exit;
        "\"" : exit;
    }
    region ${ALL} {
           type=string;
    }
}

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

# identifier
/[a-zA-Z_][a-zA-Z_0-9]*/ : {
      region {
         type=identifier;
         index=word;
      }
   }


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

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