Parsing successfully
This commit is contained in:
parent
397a95f2dc
commit
6f1199f3d2
|
@ -3,7 +3,7 @@ use std::collections::HashMap;
|
|||
extern crate nom;
|
||||
use nom::{
|
||||
branch::alt,
|
||||
bytes::complete::{tag, take_while},
|
||||
bytes::complete::{tag, take_until, take_while},
|
||||
character::complete::{line_ending, newline, space1},
|
||||
combinator::{map_res, value},
|
||||
multi::separated_list0,
|
||||
|
@ -80,11 +80,10 @@ fn mapping(input: &str) -> IResult<&str, Mapping> {
|
|||
}
|
||||
|
||||
fn mapping_entry(input: &str) -> IResult<&str, (LayerDir, Vec<Mapping>)> {
|
||||
// TODO: this is probably confusing my parser since the newline separator would need to lookahead?
|
||||
let (input, (from, _, to, _)) = tuple((layer, tag("-to-"), layer, tag(" map:\n")))(input)?;
|
||||
// take while here
|
||||
let (rest, input) = take_until("\n\n")(input)?;
|
||||
let (input, mappings) = separated_list0(newline, mapping)(input)?;
|
||||
Ok((input, (LayerDir { from, to }, mappings)))
|
||||
Ok((rest, (LayerDir { from, to }, mappings)))
|
||||
}
|
||||
|
||||
fn almanac(input: &str) -> IResult<&str, Almanac> {
|
||||
|
|
Loading…
Reference in a new issue