@predictive-text-studio/lexical-model-compiler
Version:
Keyman Developer lexical model compiler
73 lines (72 loc) • 2.18 kB
TypeScript
/**
* Log levels.
*
* Note: Currently, this acts like a bit set, where the upper 4 bits of an
* unsigned 16 bit value are the log level flags.
*/
export declare enum LogLevel {
CERR_FATAL = 32768,
CERR_ERROR = 16384,
CERR_WARNING = 8192,
CERR_INFO = 0
}
/**
* Error codes. Use these when logging messages.
*
* Extends https://github.com/keymanapp/keyman/blob/99db3c0d2448f448242e6397f9d72e9a7ccee4b9/windows/src/global/inc/Comperr.h
*/
export declare enum KeymanCompilerError {
CERR_LEXICAL_MODEL_MIN = 2048,
CERR_LEXICAL_MODEL_MAX = 2303,
CERR_FATAL_LM = 34816,
CERR_ERROR_LM = 18432,
CERR_WARN_LM = 10240,
CWARN_MixedNormalizationForms = 10241,
CWARN_DuplicateWordInSameFile = 10242,
CWARN_TooManyErrorsOrWarnings = 8359
}
/**
* How many errors or warnings are too many!
*/
export declare const MAX_MESSAGES = 100;
/**
* Logs compiler messages (warnings, errors, logs).
*
* @param code Error code
* @param message A helpful message!
* @param source [optional] the filename/line number in the source that induced this error
*
* @see https://github.com/keymanapp/keyman/blob/99db3c0d2448f448242e6397f9d72e9a7ccee4b9/windows/src/developer/TIKE/project/Keyman.Developer.System.Project.ProjectLog.pas#L60-L77
*/
export declare function log(code: KeymanCompilerError, message: string, source?: FilenameAndLineNo): void;
/**
* Override where log messages go.
*
* @param fn The desired log message handler.
*/
export declare function redirectLogMessagesTo(fn: (log: LogMessage) => void): void;
/**
* Reset the log message handler to the default.
*/
export declare function resetLogMessageHandler(): void;
/**
* Prints log messages to stdout. The default log action.
*/
export declare function printLogs(log: LogMessage): void;
/**
* Duct tapes together a filename and a line number of a log.
*/
interface FilenameAndLineNo {
readonly filename: string;
readonly lineno: number;
}
/**
* A log message that knows how to format itself.
*/
export interface LogMessage {
readonly code: KeymanCompilerError;
readonly level: LogLevel;
readonly message: string;
format(): string;
}
export {};