swc_ecma_regexp/parser/reader/string_literal_parser/
diagnostics.rs

1use swc_common::Span;
2
3use crate::diagnostics::RegexpDiagnostic;
4
5#[cold]
6pub fn invalid_input(span: Span) -> RegexpDiagnostic {
7    RegexpDiagnostic::error(
8        "String literal should be wrapped with ' or \", or escaped properly".to_string(),
9    )
10    .with_label(span)
11}
12
13#[cold]
14pub fn legacy_in_strict_mode(kind: &str, span: Span) -> RegexpDiagnostic {
15    RegexpDiagnostic::error(format!("Not allowed {kind} in strict mode")).with_label(span)
16}
17
18#[cold]
19pub fn too_large_unicode_escape_sequence(span: Span) -> RegexpDiagnostic {
20    RegexpDiagnostic::error("Too large unicode escape sequence".to_string()).with_label(span)
21}