mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
Add some comments to number_literal
This commit is contained in:
parent
3db0e9e5c6
commit
95b43d5554
1 changed files with 7 additions and 0 deletions
|
@ -11,6 +11,7 @@ pub fn number_literal<'a>() -> impl Parser<'a, Expr<'a>> {
|
||||||
|
|
||||||
match chars.next() {
|
match chars.next() {
|
||||||
Some(first_ch) => {
|
Some(first_ch) => {
|
||||||
|
// Number literals must start with either an '-' or a digit.
|
||||||
if first_ch == '-' || first_ch.is_ascii_digit() {
|
if first_ch == '-' || first_ch.is_ascii_digit() {
|
||||||
parse_number_literal(first_ch, &mut chars, arena, state)
|
parse_number_literal(first_ch, &mut chars, arena, state)
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,6 +43,12 @@ where
|
||||||
let mut has_decimal_point = false;
|
let mut has_decimal_point = false;
|
||||||
let mut chars_skipped = 0;
|
let mut chars_skipped = 0;
|
||||||
|
|
||||||
|
// Put the first character into the buffer, even if all we've parsed so
|
||||||
|
// far is a minus sign.
|
||||||
|
//
|
||||||
|
// We have to let i64::parse handle the minus sign (if it's there), because
|
||||||
|
// otherwise if we ask it to parse i64::MIN.to_string() as a positive i64,
|
||||||
|
// it errors because that positive number doesn't fit in an i64!
|
||||||
before_decimal.push(first_ch);
|
before_decimal.push(first_ch);
|
||||||
|
|
||||||
while let Some(next_ch) = chars.next() {
|
while let Some(next_ch) = chars.next() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue