mirror of
https://github.com/liljencrantz/crush.git
synced 2024-11-20 19:21:22 +03:00
Backslash escaped newline support
This commit is contained in:
parent
e0bb07676b
commit
8c2bf5ab79
@ -61,6 +61,15 @@ impl<'input> Lexer<'input> {
|
||||
Some((i, '|')) => return Some(Token::Pipe(Location::from(i)).into()),
|
||||
Some((i, ';')) => return Some(Token::Separator(";", Location::from(i)).into()),
|
||||
Some((i, '\n')) => return Some(Token::Separator("\n", Location::from(i)).into()),
|
||||
Some((i, '\\')) =>
|
||||
match self.chars.peek() {
|
||||
Some((_, '\n')) => {
|
||||
self.chars.next();
|
||||
continue;
|
||||
}
|
||||
Some((_, ch)) => return Some(Err(LexicalError::UnexpectedCharacter(*ch))),
|
||||
None => return Some(Err(LexicalError::UnexpectedEOFWithSuggestion('\n'))),
|
||||
}
|
||||
Some((i, '<')) =>
|
||||
match self.chars.peek() {
|
||||
Some((_, '=')) => {
|
||||
@ -339,6 +348,15 @@ impl<'input> Lexer<'input> {
|
||||
Some((i, ';')) => return Some(Token::Separator(";", Location::from(i)).into()),
|
||||
Some((i, ',')) => return Some(Token::Separator(",", Location::from(i)).into()),
|
||||
Some((i, '\n')) => return Some(Token::Separator("\n", Location::from(i)).into()),
|
||||
Some((i, '\\')) =>
|
||||
match self.chars.peek() {
|
||||
Some((_, '\n')) => {
|
||||
self.chars.next();
|
||||
continue;
|
||||
}
|
||||
Some((_, ch)) => return Some(Err(LexicalError::UnexpectedCharacter(*ch))),
|
||||
None => return Some(Err(LexicalError::UnexpectedEOFWithSuggestion('\n'))),
|
||||
}
|
||||
|
||||
Some((i, '<')) =>
|
||||
match self.chars.peek() {
|
||||
|
Loading…
Reference in New Issue
Block a user