Considering the number of changes since the last release, this version can contain breaking changes, so the version number becomes 0.4.0. A lot of new features and performance improvements!
- @frewsxcv for documentation fixes
- @ngrewe for his work on producers and consumers
- @meh for fixes on
chain!
and for therest
parser - @daboross for refactoring
many0!
andmany1!
- @aleksander for the
switch!
combinator idea - @TechnoMancer for his help with bit level parsing
- @sxeraverx for pointing out a bug in
is_a!
count_fixed!
must take an explicit type as argument to generate the fixed-size array- optional parsing behaviour in
chain!
count!
can take 0 elementsis_a!
andis_not!
can now consume the whole input
- it is now possible to seek to the end of a
MemProducer
opt!
returnsDone(input, None)
ifthe child parser returned
Incomplete`rest
will return the remaining input- consumers can now seek to and from the end of input
switch!
applies a first parser then matches on its result to choose the next parser- bit-level parsers
- character-level parsers
- regular expression parsers
- implementation of
take_till!
,take_while!
andtake_while1!
alt!
can returnIncomplete
- the error analysis functions will now take references to functions instead of moving them
- performance improvements on producers
- performance improvement for
filter!
- performance improvement for
count!
: aVec
of the right size is directly allocated
- @bluss for remarking that the crate included random junk lying non commited in my local repository
- cleanup of my local repository will ship less files in the crates, resulting in a smaller download
bits!
for bit level parsing. It indicates that all child parsers will take a(&[u8], usize)
as input, with the second parameter indicating the bit offset in the first byte. This allows viewing a byte slice as a bit stream. Most combinators can be used directly underbits!
take_bits!
takes an integer type and a number of bits, consumes that number of bits and updates the offset, possibly by crossing byte boundaries- bit level parsers are all written in
src/bits.rs
- Parsers that specifically handle bytes have been moved to src/bytes.rs
. This applies to
tag!,
is_not!,
is_a!,
filter!,
take!,
take_str!,
take_until_and_consume!,
take_until!,
take_until_either_and_consume!,
take_until_either!`
- @badboy for fixing
filter!
- @idmit for some documentation fixes
opt_res!
applies a parser and transform its result in a Result. This parser never failscond_reduce!
takes an expression as parameter, applies the parser if the expression is true, and returns an error if the expression is falsetap!
pass the result of a parser to a block to manipulate it, but do not affect the parser's resultAccReader
is a Read+BufRead that supports data accumulation and partial consumption. Theconsume
method must be called afterwardsto indicate how much was consumed- Arithmetic expression evaluation and parsing example
u16!
,u32!
,u64!
,i16!
,i32!
,i64!
take an expression as parameter, if the expression is true, apply the big endian integer parser, if false, the little endian version- type information for combinators. This will make the documentation a bit easier to navigate
map_opt!
andmap_res!
had issues with argument order due to bad macrosdelimited!
did not compile for certain combinations of argumentsfilter!
did not return a byte slice but a fixed array
- code coverage is now calculated automatically on Travis CI
Stepper
: wrap aProducer
, and call the methodstep
with a parser. This method will buffer data if there is not enough, apply the parser if there is, and keep the rest of the input in memory for the next callReadProducer
: takes something implementingRead
, and makes aProducer
out of it
- the combinators
separated_pair!
anddelimited!
did not work because an implementation macro was not exported - if a
MemProducer
reached its end, it should always returnEof
map!
had issues with argument matching
expr_res!
andexpr_opt!
evaluate an expression returning a Result or Opt and convert it to IResultAsBytes
is implemented for fixed size arrays. This allowstag!([41u8, 42u8])
count_fixed!
argument parsing works again
- documentation for a few functions
- the consumer trait now requires the
failed(&self, error_code)
method in case of parsing error named!
now handles thge alternativenamed!(pub fun_name<OutputType>, ...)
filter!
now returns the whole input if the filter function never returned falsetake!
casts its argument as usize, so it can accepts any integer type now
- @cmr for some documentation fixes
count_fixed!
returns a fixed array
count!
is back to the previous behaviour, returning aVec
for sizes known at runtime
- functions and traits exported from
nom::util
are now directly innom::
- @andrew-d for fixes on
cond!
- @keruspe for features in
chain!
chain!
can now have mutable fields
cond!
had an infinite macro recursion
chain!
generates less code now. No apprent compilation time improvement
- @andrew-d for the little endian signed integer parsers
- @keruspe for fixes on
count!
le_i8
,le_i16
,le_i32
,le_i64
: little endian signed integer parsers
- the
alt!
parser compiles much faster, even with more than 8 branches count!
can now return a fixed size array instead of a growable vector
- @keruspe for the
take_str
parser and the function application combinator
take_str!
: takes the specified number of bytes and return a UTF-8 stringapply!
: do partial application on the parameters of a function
Needed::Size
now contains ausize
instead of au32
- @divarvel for the big endian signed integer parsers
be_i8
,be_i16
,be_i32
,be_i64
: big endian signed integer parsers- the
core
feature can be passed to cargo to build withno_std
- colored hexdump can be generated from error chains
- @filipegoncalves for some documentation and the new eof parser
- @CrimsonVoid for putting fully qualified types in the macros
- @lu_zero for some documentation fixes
- new error types that can contain an error code, an input slice, and a list of following errors
error!
will cut backtracking and return directly from the parser, with a specified error codeeof
parser, successful if there is no more input- specific error codes for the parsers provided by nom
- fully qualified types in macros. A lot of imports are not needed anymore
FlatMap
,FlatpMapOpt
andFunctor
traits (replaced bymap!
,map_opt!
andmap_res!
)
- @filipegoncalves and @thehydroimpulse for debugging an infinite loop in many0 and many1
- @thehydroimpulse for suggesting public named parsers
- @skade for removing the dependency on the collections gate
named!
can now declare public functions like this:named!(pub tst, tag!("abcd"));
pair!(X,Y)
returns a tuple(x, y)
separated_pair!(X, sep, Y)
returns a tuple(x, y)
preceded!(opening, X)
returnsx
terminated!(X, closing)
returnsx
delimited(opening, X, closing)
returnsx
separated_list(sep, X)
returns aVec<X>
separated_nonempty_list(sep, X)
returns aVec<X>
of at list one element
many0!
andmany1!
forbid parsers that do not consume inputis_a!
,is_not!
,alpha
,digit
,space
,multispace
will now return an error if they do not consume at least one byte
- @mtsr for catching the remaining debug println!
- @jag426 who killed a lot of warnings
- @skade for removing the dependency on the core feature gate
- little endian unsigned int parsers le_u8, le_u16, le_u32, le_u64
count!
to apply a parser a specified number of timescond!
applies a parser if the condition is met- more parser development tools in
util::*
- in one case,
opt!
would not compile
- most of the feature gates are now removed. The only one still needed is
collections
works with rustc 1.0.0-dev (81e2396c7 2015-03-19) (built 2015-03-19)
- Ryman for the AsBytes implementation
- jag426 and jaredly for documentation fixes
- eternaleye on #rust IRC for his help on the new macro syntax
- the AsBytes trait improves readability, no more b"...", but "..." instead
- Incomplete will now hold either Needed;;Unknown, or Needed::Size(u32). Matching on Incomplete without caring for the value is done with
Incomplete(_)
, but if more granularity is mandatory,Needed
can be matched too alt!
can pass the result of the parser to a closure- the
take_*
macros changed behaviour, the default case is now not to consume the separator. The macros have been renamed as follows:take_until!
->take_until_and_consume!
,take_until_and_leave!
->take_until!
,take_until_either_and_leave!
->take_until_either!
,take_until_either!
->take_until_either_and_consume!
peek!
macro: matches the future input but does not consume itlength_value!
macro: the first argument is a parser returning an
that can cast to usize, then applies the second parsern
times. The macro has a variant with a third argument indicating the expected input size for the second parser- benchmarks are available at https://github.com/Geal/nom_benchmarks
- more documentation
- Unnamed parser syntax: warning, this is a breaking change. With this new syntax, the macro combinators do not generate functions anymore, they create blocks. That way, they can be nested, for better readability. The
named!
macro is provided to create functions from parsers. Please be aware that nesting parsers comes with a small cost of compilation time, negligible in most cases, but can quickly get to the minutes scale if not careful. If this happens, separate your parsers in multiple subfunctions. named!
,closure!
andcall!
macros used to support the unnamed syntaxmap!
,map_opt!
andmap_res!
to combine a parser with a normal function, transforming the input directly, or returning anOption
orResult
is_a!
is now working properly
- the
o!
macro does less thanchain!
, so it has been removed - the
fold0!
andfold1!
macros were too complex and awkward to use, themany*
combinators will be useful for most uses for now
- consumers must have an end method that will be called after parsing
- big endian unsigned int and float parsers: be_u8, be_u16, be_u32, be_u64, be_f32, be_f64
- producers can seek
- function and macros documentation
- README documentation
- lifetime declarations
- tag! can return Incomplete
- traits were renamed: FlatMapper -> FlatMap, Mapper -> FlatMapOpt, Mapper2 -> Functor
- woeks with rustc f1bb6c2f4
- the chaining macro can take optional arguments with '?'
- the chaining macro now takes the closure at the end of the argument list
- flat_map implementation for <&[u8], &[u8]>
- chaining macro
- partial MP4 parser example
- closure syntax change