termi 0.1.6

A modal terminal code editor written in Rust
//! C language definition.
//!
//! `capitalised_types` is off: in C a capitalised identifier is far more often a
//! macro or an enum constant than a type, so guessing "type" would mis-colour
//! most of a typical header.

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

/// C.
pub static C: Language = Language {
    name: "c",
    extensions: &["c", "h"],
    filenames: &[],
    keywords: &[
        "auto",
        "break",
        "case",
        "const",
        "continue",
        "default",
        "do",
        "else",
        "enum",
        "extern",
        "for",
        "goto",
        "if",
        "inline",
        "register",
        "restrict",
        "return",
        "sizeof",
        "static",
        "struct",
        "switch",
        "typedef",
        "union",
        "volatile",
        "while",
        "_Alignas",
        "_Alignof",
        "_Atomic",
        "_Generic",
        "_Noreturn",
        "_Static_assert",
        "_Thread_local",
    ],
    types: &[
        "char",
        "double",
        "float",
        "int",
        "long",
        "short",
        "signed",
        "unsigned",
        "void",
        "_Bool",
        "bool",
        "size_t",
        "ssize_t",
        "ptrdiff_t",
        "wchar_t",
        "intptr_t",
        "uintptr_t",
        "int8_t",
        "int16_t",
        "int32_t",
        "int64_t",
        "uint8_t",
        "uint16_t",
        "uint32_t",
        "uint64_t",
        "FILE",
        "va_list",
    ],
    constants: &[
        "NULL",
        "true",
        "false",
        "EOF",
        "EXIT_SUCCESS",
        "EXIT_FAILURE",
    ],
    line_comment: Some("//"),
    block_comment: Some(("/*", "*/")),
    nested_block_comments: false,
    macro_suffix: false,
    capitalised_types: false,
    extra_rules: &[
        // The include target is matched as part of the directive, so the angle
        // brackets are never read as comparison operators.
        (
            r#"^\s*#\s*include\s*(?:<[^>]*>|"[^"]*")"#,
            HighlightKind::Attribute,
        ),
        (r"^\s*#\s*[a-z]+", HighlightKind::Attribute),
    ],
    prose: false,
};