Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 123362e

Browse files
lexer: rename StartHeredoc and EndHeredoc to *DocString
1 parent 1e94506 commit 123362e

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

src/lexer/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ impl Lexer {
557557
state.next();
558558
state.set(StackFrame::DocString(doc_string_kind, label.clone()))?;
559559

560-
TokenKind::StartHeredoc(label, doc_string_kind)
560+
TokenKind::StartDocString(label, doc_string_kind)
561561
}
562562
[b'<', b'<', b'=', ..] => {
563563
state.skip(3);
@@ -772,7 +772,7 @@ impl Lexer {
772772
if state.try_read(&label) {
773773
state.skip(label.len());
774774
state.set(StackFrame::Scripting)?;
775-
break TokenKind::EndHeredoc(label, None, 0);
775+
break TokenKind::EndDocString(label, None, 0);
776776
}
777777

778778
// We know the label isn't at the start of the line, so we can
@@ -861,7 +861,7 @@ impl Lexer {
861861
// to normalize.
862862
state.skip(label.len());
863863
state.set(StackFrame::Scripting)?;
864-
break TokenKind::EndHeredoc(label, indentation_type, current_indentation_amount);
864+
break TokenKind::EndDocString(label, indentation_type, current_indentation_amount);
865865
} else {
866866
buffer.extend(whitespace_buffer);
867867
continue;

src/lexer/token.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ impl Into<u8> for DocStringIndentationType {
3838

3939
#[derive(Debug, PartialEq, PartialOrd, Clone)]
4040
pub enum TokenKind {
41-
StartHeredoc(ByteString, DocStringKind),
42-
EndHeredoc(ByteString, Option<DocStringIndentationType>, usize),
41+
StartDocString(ByteString, DocStringKind),
42+
EndDocString(ByteString, Option<DocStringIndentationType>, usize),
4343
From,
4444
Print,
4545
Dollar,
@@ -239,12 +239,12 @@ impl Default for Token {
239239
impl Display for TokenKind {
240240
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
241241
let s = match self {
242-
Self::StartHeredoc(label, kind) => if kind == &DocStringKind::Nowdoc {
242+
Self::StartDocString(label, kind) => if kind == &DocStringKind::Nowdoc {
243243
return write!(f, "<<<'{}'", label)
244244
} else {
245245
return write!(f, "<<<{}", label)
246246
},
247-
Self::EndHeredoc(label, ..) => return write!(f, "{}", label),
247+
Self::EndDocString(label, ..) => return write!(f, "{}", label),
248248
Self::BangEquals => "!=",
249249
Self::From => "from",
250250
Self::Print => "print",

src/parser/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ impl Parser {
10531053
e
10541054
}
10551055
TokenKind::StringPart(_) => self.interpolated_string(state)?,
1056-
TokenKind::StartHeredoc(label, kind) => {
1056+
TokenKind::StartDocString(label, kind) => {
10571057
let kind = kind.clone();
10581058
let label = label.clone();
10591059

@@ -1578,14 +1578,14 @@ impl Parser {
15781578
DocStringKind::Heredoc => {
15791579
let mut parts = Vec::new();
15801580

1581-
while !matches!(state.current.kind, TokenKind::EndHeredoc(_, _, _)) {
1581+
while !matches!(state.current.kind, TokenKind::EndDocString(_, _, _)) {
15821582
if let Some(part) = self.interpolated_string_part(state)? {
15831583
parts.push(part);
15841584
}
15851585
}
15861586

15871587
let (indentation_type, indentation_amount) = match state.current.kind {
1588-
TokenKind::EndHeredoc(_, indentation_type, indentation_amount) => (indentation_type, indentation_amount),
1588+
TokenKind::EndDocString(_, indentation_type, indentation_amount) => (indentation_type, indentation_amount),
15891589
_ => unreachable!(),
15901590
};
15911591

@@ -1617,7 +1617,7 @@ impl Parser {
16171617
// but since I already had the logic in place for parsing heredocs, this was
16181618
// the fastest way to get nowdocs working too.
16191619
let s = expect_token!([TokenKind::StringPart(s) => s], state, "constant string");
1620-
expect_token!([TokenKind::EndHeredoc(..)], state, "label");
1620+
expect_token!([TokenKind::EndDocString(..)], state, "label");
16211621

16221622
Expression::Nowdoc { value: s }
16231623
},

tests/0224/tokens.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
),
1010
},
1111
Token {
12-
kind: StartHeredoc(
12+
kind: StartDocString(
1313
"EOF",
1414
Heredoc,
1515
),
@@ -28,7 +28,7 @@
2828
),
2929
},
3030
Token {
31-
kind: EndHeredoc(
31+
kind: EndDocString(
3232
"EOF",
3333
None,
3434
0,

tests/0225/tokens.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
),
1010
},
1111
Token {
12-
kind: StartHeredoc(
12+
kind: StartDocString(
1313
"TXT",
1414
Heredoc,
1515
),
@@ -28,7 +28,7 @@
2828
),
2929
},
3030
Token {
31-
kind: EndHeredoc(
31+
kind: EndDocString(
3232
"TXT",
3333
None,
3434
0,

tests/0228/tokens.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
),
1010
},
1111
Token {
12-
kind: StartHeredoc(
12+
kind: StartDocString(
1313
"EOF",
1414
Heredoc,
1515
),
@@ -28,7 +28,7 @@
2828
),
2929
},
3030
Token {
31-
kind: EndHeredoc(
31+
kind: EndDocString(
3232
"EOF",
3333
None,
3434
0,

tests/0229/tokens.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
),
1010
},
1111
Token {
12-
kind: StartHeredoc(
12+
kind: StartDocString(
1313
"EOF",
1414
Heredoc,
1515
),
@@ -28,7 +28,7 @@
2828
),
2929
},
3030
Token {
31-
kind: EndHeredoc(
31+
kind: EndDocString(
3232
"EOF",
3333
Some(
3434
Space,

tests/0230/tokens.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
),
1010
},
1111
Token {
12-
kind: StartHeredoc(
12+
kind: StartDocString(
1313
"EOF",
1414
Heredoc,
1515
),
@@ -28,7 +28,7 @@
2828
),
2929
},
3030
Token {
31-
kind: EndHeredoc(
31+
kind: EndDocString(
3232
"EOF",
3333
Some(
3434
Space,

0 commit comments

Comments
 (0)