Careylq/spell/src/dic does not have a README file

    DicParseError

    pub(all) suberror DicParseError {
    DicParseError(line~ : Int, message~ : String)
    } derive(Eq,
    Debug
    )

    The error raised when the .dic text cannot be parsed.

    line is the 1-based line number in the original text.

    DicParseError::output

    fn DicParseError::output(self : DicParseError, logger : &Logger) -> Unit

    DicParseError::to_string

    fn DicParseError::to_string(self : DicParseError) -> String

    DicEntry

    pub(all) struct DicEntry {
    word : String
    flags : Array[String]
    morph : Array[String]
    full_word : String
    full_flags : Array[String]
    } derive(Eq,
    Debug
    )

    One entry line of a .dic file: word[/FLAGS] [morph...].

    flags is already decoded according to the matching .aff file's FlagType, so a FLAG long file yields two-character flags and a FLAG num file yields one decimal-number string per flag.

    DicFile

    pub(all) struct DicFile {
    declared_count : Int
    entries : Array[DicEntry]
    } derive(Eq,
    Debug
    )

    A parsed Hunspell .dic file.

    declared_count is the integer on the file's first non-empty line. It is kept even when it disagrees with entries.length(): real dictionaries are sometimes stale, and the manual's count is advisory, so a mismatch is not an error.

    decode_flags

    fn decode_flags(raw : String, flag_type :
    FlagType
    ) -> Array[String]

    Decode the flag text after / according to the file's flag mode.

    • SingleChar and Utf8: one character (Unicode scalar value) per flag.
    • Long: two characters per flag; a trailing odd character is ignored, because it cannot form a flag.
    • Num: comma-separated decimal numbers, kept verbatim as strings; empty fields between commas are skipped.

    This is also how the continuation flags after the / of an affix rule's add field are decoded (SFX A 0 s/123 .), so it is part of the package interface rather than a private helper.

    parse_dic

    fn parse_dic(text : String, flag_type :
    FlagType
    ) -> DicFile raise DicParseError

    Parse the text of a Hunspell .dic file.

    flag_type comes from the matching .aff file (FLAG long / num / UTF-8, anything else being single-character flags) and decides how the text after / is split into flags.

    Blank lines are ignored and \r\n, \n and lone \r all end a line. The first non-empty line must be the declared entry count: it is stored as-is even when the file holds a different number of entries, because stale counts are common and harmless. A malformed count line raises DicParseError; malformed entry lines do not, since the format gives them no syntax to violate.

    On an entry line the first whitespace-separated field is the word (with any \/ unescaped) optionally followed by / and its flags; the remaining fields are morphological fields. A literal / in a word may be escaped as \/.