aa506fa5bd
Modify the lexer to keep track of opening `({[` and closing `]})` delimiters. When the lexer would emit an eol or indent outside of a recipe when there is at least one open delimiter, emit a whitespace token instead. This allows expressions to be split on multiple lines, like so: x := if 'a' == 'b' { 'x' } else { 'y' } This does not work inside of recipe body interpolations, although this restriction might relaxed in the future.
25 lines
414 B
Rust
25 lines
414 B
Rust
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
|
|
pub(crate) enum Delimiter {
|
|
Brace,
|
|
Bracket,
|
|
Paren,
|
|
}
|
|
|
|
impl Delimiter {
|
|
pub(crate) fn open(self) -> char {
|
|
match self {
|
|
Self::Brace => '{',
|
|
Self::Bracket => '[',
|
|
Self::Paren => '(',
|
|
}
|
|
}
|
|
|
|
pub(crate) fn close(self) -> char {
|
|
match self {
|
|
Self::Brace => '}',
|
|
Self::Bracket => ']',
|
|
Self::Paren => ')',
|
|
}
|
|
}
|
|
}
|