18 lines
352 B
Rust
18 lines
352 B
Rust
use nom::{branch::alt, bytes::complete::tag, combinator::map, IResult};
|
|
|
|
use crate::prob7::Instructions::{Cd, Dir, Ls};
|
|
|
|
enum Instructions {
|
|
Ls,
|
|
Cd,
|
|
Dir,
|
|
}
|
|
|
|
fn parse_instruction(i: &str) -> IResult<&str, Instructions> {
|
|
alt((
|
|
map(tag("ls"), |_| Ls),
|
|
map(tag("cd"), |_| Cd),
|
|
map(tag("dir"), |_| Dir),
|
|
))(i)
|
|
}
|