pr47 0.1.4-CHARLIE

A semi-experimental programming language. Still working in progress.
Documentation
#![allow(non_upper_case_globals)]

// notes
pub const note_commence_placeholder: u32 = 1000;

// errors
pub const err_commence_placeholder: u32 = 2000;
pub const err_unexpected_control_char_0: u32 = 2001;
pub const err_unclosed_string_literal: u32 = 2002;
pub const err_reserved_identifier_0: u32 = 2003;
pub const err_reserved_symbol_0: u32 = 2004;
pub const err_expected_token_0_got_1: u32 = 2005;
pub const err_unexpected_eoi: u32 = 2006;
pub const err_import_decl_disallow_attr: u32 = 2007;
pub const err_export_decl_disallow_attr: u32 = 2008;
pub const err_expected_any_of_0_got_1: u32 = 2009;
pub const err_no_top_level_var_decl: u32 = 2010;
pub const err_expected_unqual_id: u32 = 2011;
pub const err_missing_type_got_0: u32 = 2012;
pub const err_bad_num_literal_hex_oct_bin: u32 = 2013;
pub const err_empty_literal: u32 = 2014;
pub const err_empty_float_exponent: u32 = 2015;
pub const err_bad_escape: u32 = 2016;
pub const err_unclosed_string: u32 = 2017;
pub const err_duplicate_syntax_action_name_0: u32 = 2018;
pub const err_undefined_identifier_0: u32 = 2019;

// warnings
pub const warn_commence_placeholder: u32 = 4000;
pub const warn_space_character_0_ignored: u32 = 4001;
pub const warn_underscored_id_reserved: u32 = 4002;

pub const fn is_error(code: u32) -> bool {
    code >= err_commence_placeholder && code < warn_commence_placeholder
}

#[allow(clippy::match_single_binding)]
pub const fn diag_message(code: u32) -> &'static str {
    if code > warn_commence_placeholder {
        match code {
            warn_space_character_0_ignored => "unicode space character '?0' ignored",
            warn_underscored_id_reserved =>
                "identifiers starting with underscore (`_`) are considered reserved",
            _ => "INVALID_ERROR_CODE"
        }
    } else if code > err_commence_placeholder {
        match code {
            err_unexpected_control_char_0 => "unexpected control character '?0'",
            err_unclosed_string_literal => "unclosed string literal",
            err_reserved_identifier_0 => "unexpected use of reserved identifier `?0`",
            err_reserved_symbol_0 => "unexpected use of reserved symbol `?0`",
            err_expected_token_0_got_1 => "expected ?0, got ?1",
            err_unexpected_eoi => "unexpected end of input",
            err_import_decl_disallow_attr => "cannot add attribute to `import`s",
            err_export_decl_disallow_attr => "cannot add attribute to `export`s",
            err_expected_any_of_0_got_1 => "expected any of ?0, got ?1",
            err_no_top_level_var_decl => "variable declaration cannot appear at top level",
            err_expected_unqual_id => "expected unqualified identifier",
            err_missing_type_got_0 => "missing type specifier, got ?0",
            err_bad_num_literal_hex_oct_bin =>
                "expected '0x', '0o' or '0b' for hex, oct or bin literals",
            err_empty_literal => "empty literal",
            err_empty_float_exponent => "empty float exponent",
            err_bad_escape => "bad escape sequence \\?0",
            err_unclosed_string => "unclosed string literal",
            err_duplicate_syntax_action_name_0 => "duplicate syntax action name `?0`",
            err_undefined_identifier_0 => "undefined identifier `?0`",
            _ => "INVALID_ERROR_CODE"
        }
    } else /* if code > note_commence_placeholder */ {
        match code {
            _ => "INVALID_ERROR_CODE"
        }
    }
}