mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
Revert "Attempt to genericize number_literal"
This reverts commit cafc0dd4e8
.
This commit is contained in:
parent
cafc0dd4e8
commit
0062e83d03
1 changed files with 6 additions and 6 deletions
12
src/parse.rs
12
src/parse.rs
|
@ -132,7 +132,7 @@ parser! {
|
||||||
parenthetical_expr(min_indent),
|
parenthetical_expr(min_indent),
|
||||||
string("{}").with(value(Expr::EmptyRecord)),
|
string("{}").with(value(Expr::EmptyRecord)),
|
||||||
string_literal(),
|
string_literal(),
|
||||||
number_literal(Expr::Int, Expr::Frac),
|
number_literal(),
|
||||||
char_literal(),
|
char_literal(),
|
||||||
if_expr(min_indent),
|
if_expr(min_indent),
|
||||||
case_expr(min_indent),
|
case_expr(min_indent),
|
||||||
|
@ -654,7 +654,7 @@ where
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn number_literal<I, T: Clone>(wrap_int: impl FnOnce(i64) -> T, wrap_frac: impl FnOnce(i64, u64) -> T) -> impl Parser<Input = I, Output = T>
|
pub fn number_literal<I>() -> impl Parser<Input = I, Output = Expr>
|
||||||
where I: Stream<Item = char, Position = IndentablePosition>,
|
where I: Stream<Item = char, Position = IndentablePosition>,
|
||||||
I::Error: ParseError<I::Item, I::Range, I::Position>
|
I::Error: ParseError<I::Item, I::Range, I::Position>
|
||||||
{
|
{
|
||||||
|
@ -695,9 +695,9 @@ where I: Stream<Item = char, Position = IndentablePosition>,
|
||||||
match ( int_str.parse::<i64>(), decimals ) {
|
match ( int_str.parse::<i64>(), decimals ) {
|
||||||
(Ok(int_val), None) => {
|
(Ok(int_val), None) => {
|
||||||
if is_positive {
|
if is_positive {
|
||||||
value(wrap_int(int_val as i64)).right()
|
value(Expr::Int(int_val as i64)).right()
|
||||||
} else {
|
} else {
|
||||||
value(wrap_int(-int_val as i64)).right()
|
value(Expr::Int(-int_val as i64)).right()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(Ok(int_val), Some(nums)) => {
|
(Ok(int_val), Some(nums)) => {
|
||||||
|
@ -711,9 +711,9 @@ where I: Stream<Item = char, Position = IndentablePosition>,
|
||||||
let numerator = (int_val * denom) + (decimal as i64);
|
let numerator = (int_val * denom) + (decimal as i64);
|
||||||
|
|
||||||
if is_positive {
|
if is_positive {
|
||||||
value(wrap_frac(numerator, denom as u64)).right()
|
value(Expr::Frac(numerator, denom as u64)).right()
|
||||||
} else {
|
} else {
|
||||||
value(wrap_frac(-numerator, denom as u64)).right()
|
value(Expr::Frac(-numerator, denom as u64)).right()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue