@@ -255,25 +255,17 @@ impl<'a> Converter<'a> {
255255 "Missing trailing `'` symbol to terminate the hex bit string literal"
256256 . into ( ) ,
257257 ) ;
258- } else {
259- let inside = & token_text[ 2 ..token_text. len ( ) - 1 ] ;
260- if let Some ( c) = inside. chars ( ) . find ( |c| !c. is_ascii_hexdigit ( ) ) {
261- err = Some ( format ! ( "\" {c}\" is not a valid hexadecimal digit" ) ) ;
262- }
263258 }
259+ // digit validation in squawk_syntax
264260 SyntaxKind :: BYTE_STRING
265261 }
266262 squawk_lexer:: LiteralKind :: BitStr { terminated } => {
267263 if !terminated {
268264 err = Some (
269265 "Missing trailing `'` symbol to terminate the bit string literal" . into ( ) ,
270266 ) ;
271- } else {
272- let inside = & token_text[ 2 ..token_text. len ( ) - 1 ] ;
273- if let Some ( c) = inside. chars ( ) . find ( |& c| c != '0' && c != '1' ) {
274- err = Some ( format ! ( "\" {c}\" is not a valid binary digit" ) ) ;
275- }
276267 }
268+ // digit validation in squawk_syntax
277269 SyntaxKind :: BIT_STRING
278270 }
279271 squawk_lexer:: LiteralKind :: DollarQuotedString { terminated } => {
@@ -298,9 +290,8 @@ impl<'a> Converter<'a> {
298290 err = Some (
299291 "Missing trailing `'` symbol to terminate the escape string literal" . into ( ) ,
300292 ) ;
301- } else {
302- err = validate_escape_string_unicode_escapes ( token_text) ;
303293 }
294+ // unicode escape sequences validated in squawk_syntax
304295 SyntaxKind :: ESC_STRING
305296 }
306297 } ;
@@ -309,32 +300,6 @@ impl<'a> Converter<'a> {
309300 }
310301}
311302
312- fn validate_escape_string_unicode_escapes ( token_text : & str ) -> Option < String > {
313- let mut chars = token_text[ 2 ..token_text. len ( ) - 1 ] . chars ( ) ;
314-
315- while let Some ( c) = chars. next ( ) {
316- if c != '\\' {
317- continue ;
318- }
319-
320- let ( required, example) = match chars. next ( ) {
321- Some ( 'u' ) => ( 4 , r"\uXXXX" ) ,
322- Some ( 'U' ) => ( 8 , r"\UXXXXXXXX" ) ,
323- _ => continue ,
324- } ;
325-
326- for _ in 0 ..required {
327- if !chars. next ( ) . is_some_and ( |c| c. is_ascii_hexdigit ( ) ) {
328- return Some ( format ! (
329- "Unicode escape requires {required} hex digits: {example}"
330- ) ) ;
331- }
332- }
333- }
334-
335- None
336- }
337-
338303#[ cfg( test) ]
339304mod tests {
340305 use annotate_snippets:: { AnnotationKind , Level , Renderer , Snippet , renderer:: DecorStyle } ;
@@ -390,16 +355,6 @@ mod tests {
390355 " ) ;
391356 }
392357
393- #[ test]
394- fn hex_invalid_digit ( ) {
395- assert_snapshot ! ( lex( "select X'1FZ';" ) , @r#"
396- error: "Z" is not a valid hexadecimal digit
397- ββΈ
398- 1 β select X'1FZ';
399- β°β΄ ββββββ
400- "# ) ;
401- }
402-
403358 #[ test]
404359 fn unterminated_hex_bit_string_error ( ) {
405360 assert_snapshot ! ( lex( "select X'1F;" ) , @"
@@ -420,16 +375,6 @@ mod tests {
420375 " ) ;
421376 }
422377
423- #[ test]
424- fn invalid_binary_digit_error ( ) {
425- assert_snapshot ! ( lex( "select b'0 ';" ) , @r#"
426- error: " " is not a valid binary digit
427- ββΈ
428- 1 β select b'0 ';
429- β°β΄ βββββ
430- "# ) ;
431- }
432-
433378 #[ test]
434379 fn unterminated_dollar_quoted_string_error ( ) {
435380 assert_snapshot ! ( lex( "select $tag$hello;" ) , @"
@@ -459,24 +404,4 @@ mod tests {
459404 β°β΄ ββββββββ
460405 " ) ;
461406 }
462-
463- #[ test]
464- fn invalid_unicode_escape_4_digits_error ( ) {
465- assert_snapshot ! ( lex( r"select E'\u00';" ) , @r"
466- error: Unicode escape requires 4 hex digits: \uXXXX
467- ββΈ
468- 1 β select E'\u00';
469- β°β΄ βββββββ
470- " ) ;
471- }
472-
473- #[ test]
474- fn invalid_unicode_escape_8_digits_error ( ) {
475- assert_snapshot ! ( lex( r"select E'\UFFFF';" ) , @r"
476- error: Unicode escape requires 8 hex digits: \UXXXXXXXX
477- ββΈ
478- 1 β select E'\UFFFF';
479- β°β΄ βββββββββ
480- " ) ;
481- }
482407}
0 commit comments