Skip to content

Commit 52338d6

Browse files
Started to remove whitespace
1 parent 67684c8 commit 52338d6

File tree

4 files changed

+40
-360
lines changed

4 files changed

+40
-360
lines changed

src/dialect/snowflake.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ pub fn parse_stage_name_identifier(parser: &mut Parser) -> Result<Ident, ParserE
10511051
let mut ident = String::new();
10521052
while let Some(next_token) = parser.next_token_no_skip() {
10531053
match &next_token.token {
1054-
Token::Whitespace(_) | Token::SemiColon => break,
1054+
Token::SemiColon => break,
10551055
Token::Period => {
10561056
parser.prev_token();
10571057
break;

src/parser/mod.rs

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4034,13 +4034,6 @@ impl<'a> Parser<'a> {
40344034
core::array::from_fn(|_| loop {
40354035
let token = self.tokens.get(index);
40364036
index += 1;
4037-
if let Some(TokenWithSpan {
4038-
token: Token::Whitespace(_),
4039-
span: _,
4040-
}) = token
4041-
{
4042-
continue;
4043-
}
40444037
break token.cloned().unwrap_or(TokenWithSpan {
40454038
token: Token::EOF,
40464039
span: Span::empty(),
@@ -4057,13 +4050,6 @@ impl<'a> Parser<'a> {
40574050
core::array::from_fn(|_| loop {
40584051
let token = self.tokens.get(index);
40594052
index += 1;
4060-
if let Some(TokenWithSpan {
4061-
token: Token::Whitespace(_),
4062-
span: _,
4063-
}) = token
4064-
{
4065-
continue;
4066-
}
40674053
break token.unwrap_or(&EOF_TOKEN);
40684054
})
40694055
}
@@ -4078,18 +4064,10 @@ impl<'a> Parser<'a> {
40784064
let mut index = self.index;
40794065
loop {
40804066
index += 1;
4081-
match self.tokens.get(index - 1) {
4082-
Some(TokenWithSpan {
4083-
token: Token::Whitespace(_),
4084-
span: _,
4085-
}) => continue,
4086-
non_whitespace => {
4087-
if n == 0 {
4088-
return non_whitespace.unwrap_or(&EOF_TOKEN);
4089-
}
4090-
n -= 1;
4091-
}
4067+
if n == 0 {
4068+
return self.tokens.get(index - 1).unwrap_or(&EOF_TOKEN);
40924069
}
4070+
n -= 1;
40934071
}
40944072
}
40954073

@@ -4147,16 +4125,7 @@ impl<'a> Parser<'a> {
41474125
///
41484126
/// See [`Self::get_current_token`] to get the current token after advancing
41494127
pub fn advance_token(&mut self) {
4150-
loop {
4151-
self.index += 1;
4152-
match self.tokens.get(self.index - 1) {
4153-
Some(TokenWithSpan {
4154-
token: Token::Whitespace(_),
4155-
span: _,
4156-
}) => continue,
4157-
_ => break,
4158-
}
4159-
}
4128+
self.index += 1;
41604129
}
41614130

41624131
/// Returns a reference to the current token
@@ -4187,18 +4156,8 @@ impl<'a> Parser<'a> {
41874156
///
41884157
// TODO rename to backup_token and deprecate prev_token?
41894158
pub fn prev_token(&mut self) {
4190-
loop {
4191-
assert!(self.index > 0);
4192-
self.index -= 1;
4193-
if let Some(TokenWithSpan {
4194-
token: Token::Whitespace(_),
4195-
span: _,
4196-
}) = self.tokens.get(self.index)
4197-
{
4198-
continue;
4199-
}
4200-
return;
4201-
}
4159+
assert!(self.index > 0);
4160+
self.index -= 1;
42024161
}
42034162

42044163
/// Report `found` was encountered instead of `expected`
@@ -9999,14 +9958,6 @@ impl<'a> Parser<'a> {
99999958
let mut content = String::from("");
100009959
while let Some(t) = self.next_token_no_skip().map(|t| &t.token) {
100019960
match t {
10002-
Token::Whitespace(Whitespace::Tab) => {
10003-
values.push(Some(content.to_string()));
10004-
content.clear();
10005-
}
10006-
Token::Whitespace(Whitespace::Newline) => {
10007-
values.push(Some(content.to_string()));
10008-
content.clear();
10009-
}
100109961
Token::Backslash => {
100119962
if self.consume_token(&Token::Period) {
100129963
return values;
@@ -11396,7 +11347,7 @@ impl<'a> Parser<'a> {
1139611347
// otherwise foo-123a will be parsed as `foo-123` with the alias `a`.
1139711348
if requires_whitespace {
1139811349
let token = self.next_token();
11399-
if !matches!(token.token, Token::EOF | Token::Whitespace(_)) {
11350+
if !matches!(token.token, Token::EOF) {
1140011351
return self
1140111352
.expected("whitespace following hyphenated identifier", token);
1140211353
}

0 commit comments

Comments
 (0)