mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Fix comments in str interpolations
This commit is contained in:
parent
e760db55f5
commit
887a43ff55
6 changed files with 40 additions and 4 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue