mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-23 18:21:38 +03:00
removed more dead lexer code
This commit is contained in:
parent
938f1fdbc1
commit
c767907b25
@ -76,17 +76,17 @@ impl Token {
|
||||
|
||||
if escaped.len() != 1 {
|
||||
return None;
|
||||
}
|
||||
|
||||
return match escaped.chars().next().unwrap() {
|
||||
'0' => Some(Char::Scalar(0 as char)),
|
||||
't' => Some(Char::Scalar(9 as char)),
|
||||
'n' => Some(Char::Scalar(10 as char)),
|
||||
'r' => Some(Char::Scalar(13 as char)),
|
||||
'\"' => Some(Char::Scalar(34 as char)),
|
||||
'\'' => Some(Char::Scalar(39 as char)),
|
||||
'\\' => Some(Char::Scalar(92 as char)),
|
||||
_ => None,
|
||||
} else {
|
||||
return match escaped.chars().next().unwrap() {
|
||||
'0' => Some(Char::Scalar(0 as char)),
|
||||
't' => Some(Char::Scalar(9 as char)),
|
||||
'n' => Some(Char::Scalar(10 as char)),
|
||||
'r' => Some(Char::Scalar(13 as char)),
|
||||
'\"' => Some(Char::Scalar(34 as char)),
|
||||
'\'' => Some(Char::Scalar(39 as char)),
|
||||
'\\' => Some(Char::Scalar(92 as char)),
|
||||
_ => None,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@ -96,15 +96,13 @@ impl Token {
|
||||
|
||||
if hex_string.len() != 2 {
|
||||
return None;
|
||||
}
|
||||
|
||||
if let Ok(ascii_number) = u8::from_str_radix(hex_string, 16) {
|
||||
} else if let Ok(ascii_number) = u8::from_str_radix(hex_string, 16) {
|
||||
// According to RFC, we allow only values less than 128.
|
||||
if ascii_number > 127 {
|
||||
return None;
|
||||
} else {
|
||||
return Some(Char::Scalar(ascii_number as char));
|
||||
}
|
||||
|
||||
return Some(Char::Scalar(ascii_number as char));
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,9 +116,7 @@ impl Token {
|
||||
let len = unicode_number.len();
|
||||
if !(1..=6).contains(&len) {
|
||||
return None;
|
||||
}
|
||||
|
||||
if let Ok(hex) = u32::from_str_radix(unicode_number, 16) {
|
||||
} else if let Ok(hex) = u32::from_str_radix(unicode_number, 16) {
|
||||
if let Some(character) = std::char::from_u32(hex) {
|
||||
// scalar
|
||||
return Some(Char::Scalar(character));
|
||||
|
@ -145,6 +145,17 @@ outputs:
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "'Ӡ'"
|
||||
- Value:
|
||||
Char:
|
||||
character:
|
||||
NonScalar: 55296
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 11
|
||||
path: ""
|
||||
content: "'\\u{d800}'"
|
||||
- Value:
|
||||
Char:
|
||||
character:
|
||||
|
@ -37,4 +37,5 @@ outputs:
|
||||
- "Error [EPAR0370000]: '\n --> test:1:1\n |\n 1 | '\\u00000000'\n | ^"
|
||||
- "Error [EPAR0370000]: '\n --> test:1:1\n |\n 1 | '\\u01000000'\n | ^"
|
||||
- "Error [EPAR0370000]: '\n --> test:1:1\n |\n 1 | '\\u9999999'\n | ^"
|
||||
- "Error [EPAR0370000]: '\n --> test:1:1\n |\n 1 | '\\u{110000}'\n | ^"
|
||||
- "Error [EPAR0370000]: '\n --> test:1:1\n |\n 1 | '😭😂😘'\n | ^"
|
||||
|
@ -16,6 +16,7 @@ expectation: Pass
|
||||
'å'
|
||||
'\u{4e0}'
|
||||
'Ӡ'
|
||||
'\u{d800}'
|
||||
'\u{2764}'
|
||||
'❤'
|
||||
'\u{1F622}'
|
||||
|
@ -45,5 +45,6 @@ expectation: Fail
|
||||
'\u00000000'
|
||||
'\u01000000'
|
||||
'\u9999999'
|
||||
'\u{110000}'
|
||||
|
||||
'😭😂😘'
|
||||
|
Loading…
Reference in New Issue
Block a user