mirror of
https://github.com/danog/parser.git
synced 2025-01-22 04:51:13 +01:00
chore: DocStringIndentationType -> DocStringIndentationKind
This commit is contained in:
parent
de2bf3eb6a
commit
a2d591938c
@ -21,7 +21,7 @@ use crate::ident;
|
||||
use crate::ident_start;
|
||||
|
||||
pub use self::state::DocStringKind;
|
||||
use self::token::DocStringIndentationType;
|
||||
use self::token::DocStringIndentationKind;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct Lexer;
|
||||
@ -706,24 +706,24 @@ impl Lexer {
|
||||
let mut buffer = Vec::new();
|
||||
let mut new_line = false;
|
||||
|
||||
let mut indentation_type: Option<DocStringIndentationType> = None;
|
||||
let mut indentation_type: Option<DocStringIndentationKind> = None;
|
||||
let mut indentation_amount: usize = 0;
|
||||
|
||||
// 1. Check if there's any whitespace here. It can either be a space or tab character.
|
||||
if matches!(state.peek_buf(), [b' ' | b'\t', ..]) {
|
||||
indentation_type = Some(DocStringIndentationType::from(state.current.unwrap()));
|
||||
indentation_type = Some(DocStringIndentationKind::from(state.current.unwrap()));
|
||||
}
|
||||
|
||||
// 2. Count how much whitespace there is on this line.
|
||||
if let Some(indentation_type) = indentation_type {
|
||||
loop {
|
||||
match (indentation_type, state.peek_buf()) {
|
||||
(DocStringIndentationType::Space, [b' ', ..]) => {
|
||||
(DocStringIndentationKind::Space, [b' ', ..]) => {
|
||||
indentation_amount += 1;
|
||||
state.next();
|
||||
buffer.push(b' ');
|
||||
}
|
||||
(DocStringIndentationType::Tab, [b'\t', ..]) => {
|
||||
(DocStringIndentationKind::Tab, [b'\t', ..]) => {
|
||||
indentation_amount += 1;
|
||||
state.next();
|
||||
buffer.push(b'\t');
|
||||
@ -794,8 +794,8 @@ impl Lexer {
|
||||
|
||||
|
||||
let current_indentation_type = match state.peek_buf() {
|
||||
[b' ', ..] => DocStringIndentationType::Space,
|
||||
[b'\t', ..] => DocStringIndentationType::Tab,
|
||||
[b' ', ..] => DocStringIndentationKind::Space,
|
||||
[b'\t', ..] => DocStringIndentationKind::Tab,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
@ -815,12 +815,12 @@ impl Lexer {
|
||||
// the smallest amount of whitespace in this case.
|
||||
loop {
|
||||
match (current_indentation_type, state.peek_buf()) {
|
||||
(DocStringIndentationType::Space, [b' ', ..]) => {
|
||||
(DocStringIndentationKind::Space, [b' ', ..]) => {
|
||||
leading_whitespace_buffer.push(b' ');
|
||||
current_indentation_amount += 1;
|
||||
state.next();
|
||||
}
|
||||
(DocStringIndentationType::Tab, [b'\t', ..]) => {
|
||||
(DocStringIndentationKind::Tab, [b'\t', ..]) => {
|
||||
leading_whitespace_buffer.push(b'\t');
|
||||
current_indentation_amount += 1;
|
||||
state.next();
|
||||
|
@ -12,12 +12,12 @@ pub enum OpenTagKind {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum DocStringIndentationType {
|
||||
pub enum DocStringIndentationKind {
|
||||
Space,
|
||||
Tab,
|
||||
}
|
||||
|
||||
impl From<u8> for DocStringIndentationType {
|
||||
impl From<u8> for DocStringIndentationKind {
|
||||
fn from(byte: u8) -> Self {
|
||||
match byte {
|
||||
b' ' => Self::Space,
|
||||
@ -27,11 +27,11 @@ impl From<u8> for DocStringIndentationType {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DocStringIndentationType> for u8 {
|
||||
fn from(kind: DocStringIndentationType) -> Self {
|
||||
impl From<DocStringIndentationKind> for u8 {
|
||||
fn from(kind: DocStringIndentationKind) -> Self {
|
||||
match kind {
|
||||
DocStringIndentationType::Space => b' ',
|
||||
DocStringIndentationType::Tab => b'\t',
|
||||
DocStringIndentationKind::Space => b' ',
|
||||
DocStringIndentationKind::Tab => b'\t',
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,7 @@ impl From<DocStringIndentationType> for u8 {
|
||||
#[derive(Debug, PartialEq, PartialOrd, Clone)]
|
||||
pub enum TokenKind {
|
||||
StartDocString(ByteString, DocStringKind),
|
||||
EndDocString(ByteString, Option<DocStringIndentationType>, usize),
|
||||
EndDocString(ByteString, Option<DocStringIndentationKind>, usize),
|
||||
From,
|
||||
Print,
|
||||
Dollar,
|
||||
|
Loading…
x
Reference in New Issue
Block a user