mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
fmt
This commit is contained in:
parent
70156b0a90
commit
cb8cf44596
12 changed files with 336 additions and 272 deletions
|
@ -193,13 +193,11 @@ where
|
|||
move |arena, state: State<'a>| {
|
||||
let comments_and_newlines = Vec::new_in(arena);
|
||||
match eat_spaces(state.clone(), false, comments_and_newlines) {
|
||||
HasTab(state) => {
|
||||
Err((
|
||||
MadeProgress,
|
||||
space_problem(BadInputError::HasTab, state.pos()),
|
||||
state,
|
||||
))
|
||||
}
|
||||
HasTab(state) => Err((
|
||||
MadeProgress,
|
||||
space_problem(BadInputError::HasTab, state.pos()),
|
||||
state,
|
||||
)),
|
||||
Good {
|
||||
state: mut new_state,
|
||||
multiline,
|
||||
|
@ -213,12 +211,20 @@ where
|
|||
new_state.indent_column = new_state.column();
|
||||
|
||||
if new_state.column() >= min_indent {
|
||||
Ok((MadeProgress, comments_and_newlines.into_bump_slice(), new_state))
|
||||
Ok((
|
||||
MadeProgress,
|
||||
comments_and_newlines.into_bump_slice(),
|
||||
new_state,
|
||||
))
|
||||
} else {
|
||||
Err((MadeProgress, indent_problem(state.pos()), state))
|
||||
}
|
||||
} else {
|
||||
Ok((MadeProgress, comments_and_newlines.into_bump_slice(), new_state))
|
||||
Ok((
|
||||
MadeProgress,
|
||||
comments_and_newlines.into_bump_slice(),
|
||||
new_state,
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -512,10 +512,7 @@ fn numeric_negate_expression<'a, T>(
|
|||
debug_assert_eq!(state.bytes().get(0), Some(&b'-'));
|
||||
// for overflow reasons, we must make the unary minus part of the number literal.
|
||||
let start = state.pos();
|
||||
let region = Region::new(
|
||||
start,
|
||||
expr.region.end(),
|
||||
);
|
||||
let region = Region::new(start, expr.region.end());
|
||||
|
||||
let new_expr = match &expr.value {
|
||||
Expr::Num(string) => {
|
||||
|
@ -1272,7 +1269,13 @@ fn parse_expr_end<'a>(
|
|||
expr_state.consume_spaces(arena);
|
||||
expr_state.initial = before_op;
|
||||
parse_expr_operator(
|
||||
min_indent, options, start_column, expr_state, loc_op, arena, state,
|
||||
min_indent,
|
||||
options,
|
||||
start_column,
|
||||
expr_state,
|
||||
loc_op,
|
||||
arena,
|
||||
state,
|
||||
)
|
||||
}
|
||||
Err((NoProgress, _, mut state)) => {
|
||||
|
|
|
@ -100,8 +100,7 @@ fn chomp_number_dec<'a>(
|
|||
let string =
|
||||
unsafe { std::str::from_utf8_unchecked(&state.bytes()[0..chomped + is_negative as usize]) };
|
||||
|
||||
let new = state
|
||||
.advance(chomped + is_negative as usize);
|
||||
let new = state.advance(chomped + is_negative as usize);
|
||||
|
||||
Ok((
|
||||
Progress::MadeProgress,
|
||||
|
|
|
@ -70,10 +70,7 @@ impl<'a> State<'a> {
|
|||
/// useful when parsing something "manually" (using input.chars())
|
||||
/// and thus wanting a Region while not having access to loc().
|
||||
pub fn len_region(&self, length: u32) -> Region {
|
||||
Region::new(
|
||||
self.pos(),
|
||||
self.pos().bump_column(length),
|
||||
)
|
||||
Region::new(self.pos(), self.pos().bump_column(length))
|
||||
}
|
||||
|
||||
/// Return a failing ParseResult for the given FailReason
|
||||
|
@ -96,11 +93,7 @@ impl<'a> fmt::Debug for State<'a> {
|
|||
Err(_) => write!(f, "\n\tbytes: [invalid utf8] {:?}", self.bytes)?,
|
||||
}
|
||||
|
||||
write!(
|
||||
f,
|
||||
"\n\t(offset): {:?},",
|
||||
self.pos()
|
||||
)?;
|
||||
write!(f, "\n\t(offset): {:?},", self.pos())?;
|
||||
write!(f, "\n\tindent_column: {}", self.indent_column)?;
|
||||
write!(f, "\n}}")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue