#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
pub enum DiagnosticCode {
UnexpectedToken,
UnterminatedString,
UnterminatedComment,
UnterminatedTemplate,
InvalidEscape,
InvalidNumber,
InvalidRegex,
InvalidLHS,
InvalidAssignment,
DuplicateBinding,
UndeclaredBinding,
StrictModeViolation,
IllegalReturn,
IllegalBreak,
IllegalContinue,
IllegalAwait,
IllegalYield,
IllegalSuper,
IllegalNewTarget,
UnexpectedReserved,
UnterminatedArrow,
MissingParamName,
DuplicateParam,
TooManyArgs,
SyntaxError,
NotImplemented,
InvalidTypeAnnotation,
InvalidDecorator,
InvalidImport,
InvalidExport,
#[cfg_attr(feature = "serde", serde(rename = "invalid_jsx"))]
InvalidJSX,
#[cfg_attr(feature = "serde", serde(rename = "unterminated_jsx"))]
UnterminatedJSX,
InputTooLarge,
TokenLimitExceeded,
MaxRecursionExceeded,
}
impl DiagnosticCode {
pub fn message(&self) -> &'static str {
match self {
DiagnosticCode::UnexpectedToken => "Unexpected token",
DiagnosticCode::UnterminatedString => "Unterminated string constant",
DiagnosticCode::UnterminatedComment => "Unterminated comment",
DiagnosticCode::UnterminatedTemplate => "Unterminated template literal",
DiagnosticCode::InvalidEscape => "Invalid escape sequence",
DiagnosticCode::InvalidNumber => "Invalid number literal",
DiagnosticCode::InvalidRegex => "Invalid regular expression",
DiagnosticCode::InvalidLHS => "Invalid left-hand side in assignment",
DiagnosticCode::InvalidAssignment => "Invalid assignment target",
DiagnosticCode::DuplicateBinding => "Duplicate binding",
DiagnosticCode::UndeclaredBinding => "Undeclared binding",
DiagnosticCode::StrictModeViolation => "Strict mode violation",
DiagnosticCode::IllegalReturn => "Illegal return statement",
DiagnosticCode::IllegalBreak => "Illegal break statement",
DiagnosticCode::IllegalContinue => "Illegal continue statement",
DiagnosticCode::IllegalAwait => "Illegal await expression",
DiagnosticCode::IllegalYield => "Illegal yield expression",
DiagnosticCode::IllegalSuper => "Illegal super expression",
DiagnosticCode::IllegalNewTarget => "Illegal new.target expression",
DiagnosticCode::UnexpectedReserved => "Unexpected reserved word",
DiagnosticCode::UnterminatedArrow => "Unterminated arrow function",
DiagnosticCode::MissingParamName => "Missing parameter name",
DiagnosticCode::DuplicateParam => "Duplicate parameter name",
DiagnosticCode::TooManyArgs => "Too many arguments",
DiagnosticCode::SyntaxError => "Syntax error",
DiagnosticCode::NotImplemented => "Not yet implemented",
DiagnosticCode::InvalidTypeAnnotation => "Invalid type annotation",
DiagnosticCode::InvalidDecorator => "Invalid decorator",
DiagnosticCode::InvalidImport => "Invalid import statement",
DiagnosticCode::InvalidExport => "Invalid export statement",
DiagnosticCode::InvalidJSX => "Invalid JSX element",
DiagnosticCode::UnterminatedJSX => "Unterminated JSX element",
DiagnosticCode::InputTooLarge => "Input too large",
DiagnosticCode::TokenLimitExceeded => "Token limit exceeded",
DiagnosticCode::MaxRecursionExceeded => "Max recursion depth exceeded",
}
}
}