mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Introduce SyntaxErrorKind and TextRange in SyntaxError
This commit is contained in:
parent
576b9a0727
commit
3b42ddae60
10 changed files with 159 additions and 68 deletions
|
@ -100,10 +100,6 @@ impl<'a> Parser<'a> {
|
|||
// Char parsing methods
|
||||
|
||||
fn parse_unicode_escape(&mut self, start: TextUnit) -> CharComponent {
|
||||
// Note: validation of UnicodeEscape will be done elsewhere:
|
||||
// * Only hex digits or underscores allowed
|
||||
// * Max 6 chars
|
||||
// * Within allowed range (must be at most 10FFFF)
|
||||
match self.peek() {
|
||||
Some('{') => {
|
||||
self.advance();
|
||||
|
@ -127,9 +123,6 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
fn parse_ascii_code_escape(&mut self, start: TextUnit) -> CharComponent {
|
||||
// Note: validation of AsciiCodeEscape will be done elsewhere:
|
||||
// * First digit is octal
|
||||
// * Second digit is hex
|
||||
let code_start = self.get_pos();
|
||||
while let Some(next) = self.peek() {
|
||||
if next == '\'' || (self.get_pos() - code_start == 2.into()) {
|
||||
|
@ -144,9 +137,6 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
fn parse_escape(&mut self, start: TextUnit) -> CharComponent {
|
||||
// Note: validation of AsciiEscape will be done elsewhere:
|
||||
// * The escape sequence is non-empty
|
||||
// * The escape sequence is valid
|
||||
if self.peek().is_none() {
|
||||
return CharComponent::new(TextRange::from_to(start, start), AsciiEscape);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue