
Description="C and C++"

Categories = {"source"}

Digits = [[ (?:0x|0X|0b)[0-9a-fA-F']+|\d*[\.]?\d+(?:[eE][\-\+]\d+)?[lLuU]* ]]

Keywords={
  { Id=1,
    List={
      "goto", "break", "return", "continue", "asm", "case", "default", "if", "else", "switch", "while", "for", "do", "sizeof",
      "typeof", "stdcall", "cdecl", "const_cast", "delete", "dynamic_cast", "goto", "namespace", "new", "pascal",
      "reinterpret_cast", "static_cast", "this", "throw", "try", "catch", "using", "true", "false", "bitand", "and", "bitor", "or", "xor",
      "compl", "and_eq", "or_eq", "xor_eq", "not", "not_eq", "assert", "static_assert",
      "alignas","alignof","concept","consteval","constexpr","constinit","co_await","co_return","co_yield","decltype",
      "noexcept","requires","thread_local", "module", "import", "export", "transaction_safe", "transaction_safe_dynamic",
      "await", "reflexpr"
    }
  },
  { Id=2,
    List= {
      "int", "long", "short", "char", "void", "signed", "unsigned", "float", "double", "size_t", "wchar_t",
      "ptrdiff_t", "sig_atomic_t", "fpos_t", "clock_t", "time_t", "va_list", "jmp_buf", "FILE", "DIR", "div_t", "ldiv_t", "static",
      "mbstate_t", "wctrans_t", "wint_t", "wctype_t", "const", "bool", "complex", "struct", "union", "enum",
      "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t", "int_least8_t", "int_least16_t",
      "int_least32_t", "int_least64_t", "uint_least8_t", "uint_least16_t", "uint_least32_t", "uint_least64_t",
      "int_fast8_t", "int_fast16_t", "int_fast32_t", "int_fast64_t", "uint_fast8_t", "uint_fast16_t", "uint_fast32_t",
      "uint_fast64_t", "intptr_t", "uintptr_t", "intmax_t", "uintmax_t", "char8_t","char16_t","char32_t"
    }
  },
  { Id=4,
    List= {
      "typedef", "inline", "auto", "class", "explicit", "extern", "friend", "inline", "mutable", "operator",
      "register", "template", "private", "protected", "public", "typeid", "virtual", "volatile", "constexpr", "nullptr", "decltype",
      "final", "override", "synchronized"
    }
  },
  { Id=5,
    Regex=[[(\w+)\s*\:\:]]
  },
  { Id=4,
    Regex=[[(\w+)\s*\(]]
  },
  { Id=6,
    Regex=[=[ \[\[[\w\:\,\s]+?\]\] ]=]
  }
}

Strings = {
  Delimiter=[["|']],
  RawPrefix="R",
  Interpolation = [[ %\w ]],
  DelimiterPairs= {
    { Open=[[R\"\(]], Close=[[\)\"]] },
  }
}

Comments = {
  { Block=true,
    Nested=false,
    Delimiter = { [[\/\*]], [[\*\/]] }
  },
  {
    Block=false,
    Delimiter = { [[//]] }
  }
}

IgnoreCase=false

PreProcessor = {
  Prefix=[[#]],
  Continuation="\\",
}

Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\.|\:|\&|<|>|\!|=|\/|\*|\%|\+|\-|\~|\||\^|\?]]

EnableIndentation=true

function OnStateChange(oldState, newState, token)

  -- resolve issue with C++14 number separator syntax
  if token=="'" and oldState==HL_NUMBER and newState==HL_STRING then
    return HL_NUMBER
  end

  --resolve issue with raw string delimiters: cout << (uint8_t*)"1";
  if token==")\"" and oldState ~= HL_STRING then
    return HL_REJECT
  end

  return newState
end
