diff --git a/src/parser.rs b/src/parser.rs index 87ff8b7..c31b926 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -2,7 +2,7 @@ use nom::{ branch::alt, bytes::complete::tag, character::complete::{alpha1, alphanumeric1, char, multispace0, multispace1, u64 as decimal}, - combinator::{map, opt, recognize, consumed}, + combinator::{consumed, map, opt, recognize}, error::{context, ParseError, VerboseError}, multi::{many0, many1, separated_list0}, sequence::{delimited, pair, preceded, separated_pair, terminated, tuple}, @@ -117,16 +117,18 @@ fn declaration(i: Span) -> IResult { fn port_decl(i: Span) -> IResult { map( - consumed( - tuple(( - alt(( - map(tag("input"), |_| PortDirection::Input), - map(tag("output"), |_| PortDirection::Output), - )), - declaration, - )) - ), - |(pos, (direction, net))| PortDecl { pos, direction, net }, + consumed(tuple(( + alt(( + map(tag("input"), |_| PortDirection::Input), + map(tag("output"), |_| PortDirection::Output), + )), + declaration, + ))), + |(pos, (direction, net))| PortDecl { + pos, + direction, + net, + }, )(i) } @@ -139,11 +141,17 @@ fn operation(input: Span) -> IResult { alt(( map( separated_pair(ws0(identifier), char('&'), ws0(expression)), - |(a, b)| Operation::And { a: (*a.fragment()).into(), b }, + |(a, b)| Operation::And { + a: (*a.fragment()).into(), + b, + }, ), map( separated_pair(ws0(identifier), char('|'), ws0(expression)), - |(a, b)| Operation::Or { a: (*a.fragment()).into(), b }, + |(a, b)| Operation::Or { + a: (*a.fragment()).into(), + b, + }, ), ))(input) } @@ -169,7 +177,9 @@ fn expression(input: Span) -> IResult { alt(( map(ws0(operation), |op| Expression::Operation(Box::new(op))), map(ws0(call_item), |call| Expression::Call(Box::new(call))), - map(ws0(identifier), |ident| Expression::Ident((*ident.fragment()).into())), + map(ws0(identifier), |ident| { + Expression::Ident((*ident.fragment()).into()) + }), ))(input) }