MCPcopy Create free account
hub / github.com/chc4/lineiform / parse_num

Function parse_num

src/parser.rs:188–192  ·  view source on GitHub ↗

Next up is number parsing. We're keeping it simple here by accepting any number (> 1) of digits but ending the program if it doesn't fit into an i32.

(i: &'a str)

Source from the content-addressed store, hash-verified

186/// Next up is number parsing. We're keeping it simple here by accepting any number (> 1)
187/// of digits but ending the program if it doesn't fit into an i32.
188fn parse_num<'a>(i: &'a str) -> IResult<&'a str, Atom, VerboseError<&'a str>> {
189 map_res(digit1, |digit_str: &str| {
190 digit_str.parse::<usize>().map(Wrapping).map(Atom::Num)
191 })(i)
192}
193
194/// Now we take all these simple parsers and connect them.
195/// We can now parse half of our language!

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected