Skip to content

Commit

Permalink
Update nom to version 6
Browse files Browse the repository at this point in the history
  • Loading branch information
bikeshedder committed Nov 26, 2020
1 parent f5167b4 commit 347c5f8
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 100 deletions.
169 changes: 102 additions & 67 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.1.0"

[dependencies]
clap = "2.33"
nom = "5.0"
nom_locate = "2.0"
nom = "6.0"
nom_locate = "3.0"
proc-macro2 = "1.0"
quote = "1.0"
17 changes: 10 additions & 7 deletions src/idl/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use nom::{
bytes::complete::{take_while, take_while1},
character::complete::char,
combinator::{cut, map, opt},
multi::separated_list,
multi::separated_list0,
sequence::{pair, preceded, terminated},
IResult,
};
Expand Down Expand Up @@ -40,7 +40,7 @@ fn parse_generics(input: Span) -> IResult<Span, Vec<String>> {
opt(preceded(
preceded(ws, char('<')),
cut(terminated(
separated_list(parse_field_separator, preceded(ws, parse_identifier)),
separated_list0(parse_field_separator, preceded(ws, parse_identifier)),
preceded(trailing_comma, preceded(ws, char('>'))),
)),
)),
Expand Down Expand Up @@ -80,14 +80,17 @@ fn test_parse_identifier_invalid() {
use nom::error::ErrorKind;
assert_eq!(
parse_identifier(Span::new("123test")),
Err(nom::Err::Error((
Span::new("123test"),
ErrorKind::TakeWhile1
)))
Err(nom::Err::Error(nom::error::Error {
input: Span::new("123test"),
code: ErrorKind::TakeWhile1
}))
);
assert_eq!(
parse_identifier(Span::new("_test")),
Err(nom::Err::Error((Span::new("_test"), ErrorKind::TakeWhile1)))
Err(nom::Err::Error(nom::error::Error {
input: Span::new("_test"),
code: ErrorKind::TakeWhile1
}))
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/idl/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use nom::{
character::complete::char,
combinator::{cut, map, opt},
error::context,
multi::separated_list,
multi::separated_list0,
sequence::{pair, preceded, terminated, tuple},
IResult,
};
Expand Down Expand Up @@ -66,7 +66,7 @@ fn parse_enum_variants(input: Span) -> IResult<Span, Vec<EnumVariant>> {
preceded(
preceded(ws, char('{')),
cut(terminated(
separated_list(parse_field_separator, preceded(ws, parse_enum_variant)),
separated_list0(parse_field_separator, preceded(ws, parse_enum_variant)),
preceded(trailing_comma, preceded(ws, char('}'))),
)),
),
Expand Down
2 changes: 1 addition & 1 deletion src/idl/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::idl::common::Span;

#[derive(Debug, PartialEq)]
pub enum ParseError<'a> {
Nom(nom::Err<(Span<'a>, nom::error::ErrorKind)>),
Nom(nom::Err<nom::error::Error<Span<'a>>>),
TrailingGarbage(Span<'a>),
}

Expand Down

0 comments on commit 347c5f8

Please sign in to comment.