Fix comments in str interpolations

This commit is contained in:
Joshua Warner 2024-12-16 17:23:48 -08:00
parent e760db55f5
commit 887a43ff55
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
6 changed files with 40 additions and 4 deletions

View file

@ -1,8 +1,9 @@
use crate::ast::{EscapedChar, SingleQuoteLiteral, StrLiteral, StrSegment};
use crate::ast::{EscapedChar, SingleQuoteLiteral, Spaceable, StrLiteral, StrSegment};
use crate::blankspace::space0_e;
use crate::expr;
use crate::parser::Progress::{self, *};
use crate::parser::{
allocated, between, byte, loc, reset_min_indent, skip_second, specialize_err_ref, then,
allocated, and, between, byte, loc, reset_min_indent, skip_second, specialize_err_ref, then,
BadInputError, ESingleQuote, EString, Parser,
};
use crate::state::State;
@ -457,16 +458,20 @@ pub fn parse_str_like_literal<'a>() -> impl Parser<'a, StrLikeLiteral<'a>, EStri
let original_byte_count = state.bytes().len();
// Parse an arbitrary expression, followed by ')'
let (_progress, loc_expr, new_state) = skip_second(
let (_progress, (mut loc_expr, sp), new_state) = and(
specialize_err_ref(
EString::Format,
loc(allocated(reset_min_indent(expr::expr_help())))
.trace("str_interpolation"),
),
byte(b')', EString::FormatEnd),
skip_second(space0_e(EString::FormatEnd), byte(b')', EString::FormatEnd)),
)
.parse(arena, state, min_indent)?;
if !sp.is_empty() {
loc_expr.value = arena.alloc(loc_expr.value.after(sp));
}
// Advance the iterator past the expr we just parsed.
for _ in 0..(original_byte_count - new_state.bytes().len()) {
bytes.next();