Skip to content

Commit

Permalink
Remove optional commas
Browse files Browse the repository at this point in the history
  • Loading branch information
vinc committed Jan 27, 2025
1 parent 48f65bb commit c3183a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/usr/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn parse_term(input: &str) -> IResult<&str, Exp> {
let (input, num1) = parse_factor(input)?;
let (input, exps) = many0((
alt((char('%'), char('/'), char('*'))),
parse_factor,
parse_factor
)).parse(input)?;
Ok((input, parse_exp(num1, exps)))
}
Expand Down
16 changes: 8 additions & 8 deletions src/usr/lisp/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ fn hexadecimal(input: &str) -> IResult<&str, &str> {
tag("0x"),
recognize(many1(terminated(
one_of("0123456789abcdefABCDEF"),
many0(char('_')),
))),
many0(char('_'))
)))
).parse(input)
}

Expand Down Expand Up @@ -61,7 +61,7 @@ fn float(input: &str) -> IResult<&str, &str> {
char('.'),
decimal,
opt((one_of("eE"), opt(one_of("+-")), decimal))
),
)
),
recognize(
// 42e42 and 42.42e42
Expand All @@ -71,12 +71,12 @@ fn float(input: &str) -> IResult<&str, &str> {
one_of("eE"),
opt(one_of("+-")),
decimal
),
)
),
recognize(
// 42. and 42.42
(decimal, char('.'), opt(decimal))
),
)
)).parse(input)
}

Expand All @@ -98,9 +98,9 @@ fn parse_str(input: &str) -> IResult<&str, Exp> {
value("\t", tag("t")),
value("\x08", tag("b")),
value("\x1B", tag("e"))
)),
))
)),
|inner| inner.unwrap_or("".to_string()),
|inner| inner.unwrap_or("".to_string())
);
let (input, s) = delimited(char('"'), escaped, char('"')).parse(input)?;
Ok((input, Exp::Str(s)))
Expand All @@ -114,7 +114,7 @@ fn parse_sym(input: &str) -> IResult<&str, Exp> {
fn parse_num(input: &str) -> IResult<&str, Exp> {
let (input, num) = recognize((
opt(alt((char('+'), char('-')))),
alt((float, hexadecimal, binary, decimal)),
alt((float, hexadecimal, binary, decimal))
)).parse(input)?;
Ok((input, Exp::Num(Number::from(num))))
}
Expand Down

0 comments on commit c3183a4

Please sign in to comment.