termi 0.1.0

A modal terminal code editor written in Rust
//! C++ language definition.
//!
//! Unlike C, `capitalised_types` is on: C++ code overwhelmingly uses
//! `PascalCase` for classes, so the guess is right far more often than not.

use crate::syntax::{HighlightKind, Language};

/// C++.
pub static CPP: Language = Language {
    name: "cpp",
    extensions: &["cpp", "cc", "cxx", "hpp", "hh", "hxx", "ipp"],
    filenames: &[],
    keywords: &[
        "alignas",
        "alignof",
        "and",
        "asm",
        "auto",
        "break",
        "case",
        "catch",
        "class",
        "co_await",
        "co_return",
        "co_yield",
        "concept",
        "const",
        "consteval",
        "constexpr",
        "constinit",
        "const_cast",
        "continue",
        "decltype",
        "default",
        "delete",
        "do",
        "dynamic_cast",
        "else",
        "enum",
        "explicit",
        "export",
        "extern",
        "final",
        "for",
        "friend",
        "goto",
        "if",
        "inline",
        "mutable",
        "namespace",
        "new",
        "noexcept",
        "not",
        "operator",
        "or",
        "override",
        "private",
        "protected",
        "public",
        "register",
        "reinterpret_cast",
        "requires",
        "return",
        "sizeof",
        "static",
        "static_assert",
        "static_cast",
        "struct",
        "switch",
        "template",
        "this",
        "thread_local",
        "throw",
        "try",
        "typedef",
        "typeid",
        "typename",
        "union",
        "using",
        "virtual",
        "volatile",
        "while",
        "xor",
    ],
    types: &[
        "bool",
        "char",
        "char8_t",
        "char16_t",
        "char32_t",
        "double",
        "float",
        "int",
        "long",
        "short",
        "signed",
        "unsigned",
        "void",
        "wchar_t",
        "size_t",
        "ssize_t",
        "ptrdiff_t",
        "int8_t",
        "int16_t",
        "int32_t",
        "int64_t",
        "uint8_t",
        "uint16_t",
        "uint32_t",
        "uint64_t",
        "string",
        "string_view",
        "vector",
        "map",
        "unordered_map",
        "set",
        "unordered_set",
        "array",
        "pair",
        "tuple",
        "optional",
        "variant",
        "span",
        "unique_ptr",
        "shared_ptr",
        "weak_ptr",
        "function",
        "std",
    ],
    constants: &["true", "false", "nullptr", "NULL"],
    line_comment: Some("//"),
    block_comment: Some(("/*", "*/")),
    nested_block_comments: false,
    macro_suffix: false,
    capitalised_types: true,
    extra_rules: &[
        // The include target is matched as part of the directive; a standalone
        // `<...>` rule would swallow `vector<int>`.
        (
            r#"^\s*#\s*include\s*(?:<[^>]*>|"[^"]*")"#,
            HighlightKind::Attribute,
        ),
        (r"^\s*#\s*[a-z]+", HighlightKind::Attribute),
        (r"\[\[[A-Za-z_:, ]+\]\]", HighlightKind::Attribute),
        // Raw string literals ignore escapes entirely.
        (r#"R"\([^)]*\)""#, HighlightKind::String),
    ],
    prose: false,
};