Commit Graph

2354 Commits

Author SHA1 Message Date
Geoffroy Couprie
2e58a2cc2c add SIP to the list of examples 2020-10-24 11:36:44 +02:00
Olivier
8688637631 Remove weird Pi char. 2020-10-24 11:29:01 +02:00
Olivier
a6f9f23b0f Remove duplicated words. 2020-10-24 11:29:01 +02:00
Geoffroy Couprie
56ed527658 fix compilation when not building docs 2020-10-17 17:10:36 +02:00
Geoffroy Couprie
b37013912a include the nom recipes document as a module 2020-10-17 16:52:03 +02:00
Geoffroy Couprie
032a097ecf document which cargo features are required for some combinators 2020-10-17 16:42:46 +02:00
Geoffroy Couprie
1dcf816ed5 v6.0.0-beta1 2020-10-17 16:03:58 +02:00
Geoffroy Couprie
8a4efe51e3 the regexp_macros is not used anymore
fix the issues related unit tests that were not compiled anymore
2020-10-11 16:12:42 +02:00
Geoffroy Couprie
8098465542 FromStr example 2020-10-11 16:12:42 +02:00
FallenWarrior2k
fcc169195c Make JSON test/bench handle surrogates
This correctly decodes Unicode escapes which resolve to surrogates into
the corresponding character instead of just failing when hitting a
surrogate.
2020-10-11 16:06:08 +02:00
FallenWarrior2k
075cba80d3 Fix UB in JSON test/bench
Use safe version of turning u32 into char because the input might
contain surrogates.
This only fixes a symptom and not the underlying issue that surrogates
are not handled at the moment.
2020-10-11 16:06:08 +02:00
Jamey Sharp
6c643a3932 Correct Incomplete errors from length_data/value
If they didn't have enough input data, these two functions were
returning a `Needed` value reflecting the entire expected length, not
the length remaining after the available input.

As a result, a caller that blocks until the specified number of bytes
are available could get stuck waiting forever.

I've fixed the affected tests at the same time as fixing this bug. For
most of them I made sure the tests would detect this error. But for
`tests/overflow.rs`, I deleted the partial input after the length
instead (meaning the tests pass either way), because I don't think it
matters for the purposes of checking if the parsers have an unsigned
overflow.
2020-10-11 12:01:43 +02:00
Jamey Sharp
03bd957db6 Numbers that are ToUsize needn't be Copy
Because they're just converted to usize, and that is Copy.
2020-10-11 12:01:43 +02:00
Jamey Sharp
44dc361705 bytes::streaming::tag incomplete-match doctests
These tests demonstrate that for inputs that are shorter than the tag,
this parser reports failure as soon as possible.
2020-10-11 12:01:43 +02:00
Tony Finch
8717d521ff Clarify description of take_until
It consumes input until the first occurrence of the tag, not the
longest possible input until the last occurrence of the tag.
2020-10-11 11:54:06 +02:00
Jan Ruzicka
24f4b27734
Make map, map_res and map_opt accept FnMut instead of Fn (#1202)
* Make `map`, `map_res` and `map_opt` accept FnMut
2020-10-11 11:53:14 +02:00
Geoffroy Couprie
7d2addcd23 remove the deprecation notice on be_u8, be_i8, le_u8, le_i8
even if they do not make sense (there's no endianness to care for on a
single byte), importing the new functions is annoying (`use
nom::number::comlete::u8` conflicting, etc), and it will be consistent
with other byte sizes
2020-10-07 16:36:18 +02:00
Geoffroy Couprie
e7799fc195 switch to cargo-tarpaulin 2020-10-07 16:13:04 +02:00
Geoffroy Couprie
bcd337ef58 some regex parsers require the alloc feature 2020-10-07 15:58:34 +02:00
Geoffroy Couprie
a34ee445cd cargo-travis 0.0.10 and 0.0.11 do not build currently 2020-10-07 15:41:32 +02:00
Geoffroy Couprie
120c36e9f2 raise the minimum supported version
Bitvec works from Rust 1.44.0
2020-10-07 15:29:18 +02:00
Chip Senkbeil
3e19239def Add vimwiki parser and associated macro library 2020-10-07 14:48:11 +02:00
Geoffroy Couprie
eb0ccc9385 v6.0.0-alpha3 2020-10-04 18:13:56 +02:00
Geoffroy Couprie
c22d049bcd bitvec 0.19.3 has the offset functions now 2020-10-04 18:10:03 +02:00
Geoffroy Couprie
63f90d6968 make number parser with endianness generic over the input type 2020-09-27 18:26:42 +02:00
Geoffroy Couprie
3418541a30 streaming version of number parsers with configurable endianness 2020-09-27 17:04:47 +02:00
Geoffroy Couprie
c806cc85fa point to a bitvec branch for now
the currently published crate is missing the offset functions on
BitSlice
2020-09-27 16:15:31 +02:00
myrrlyn
5b427b2268 Add bitvec and implement support for it
The trait implementations permit `bitvec` types to be used directly
within the `bytes` parsers, as demonstrated by the `tests/bitstream`
module using `bytes::tag` to process a bitstream.

This unification allows the removal of the `bits` module in favor of
ordinary combinators written to be generic over a consumable input
type.
2020-09-26 14:51:00 +02:00
Geoffroy Couprie
f4e11bcf23 v6.0.0-alpha2 2020-09-26 14:48:52 +02:00
Geoffroy Couprie
2099a75d9f length_count requires the alloc feature 2020-08-30 15:22:14 +02:00
Geoffroy Couprie
015cc77560 fix doc tests for length_count 2020-08-30 15:20:11 +02:00
Geoffroy Couprie
ab9c7ff197 add link to a MySQL binary log format parser 2020-08-30 15:12:43 +02:00
Owen Anderson
21d1dffc75 Add a function version of length_count. 2020-08-30 15:08:47 +02:00
Nia Calia-Bogan
48c5a7cc3f
consumed (previously with_input) parser combinator (#1146)
* consumed parser

* Update

Add test and modify choosing a combinator
2020-08-30 15:05:38 +02:00
Geoffroy Couprie
4a30ddc88d Err::to_owned should be usable with the alloc feature 2020-08-30 14:56:27 +02:00
Geoffroy Couprie
b037e9c0b9 fix no_std and alloc compilation 2020-08-30 14:50:58 +02:00
Shea Newton
ea701873b6
eof function (#1112)
The changes in this PR set out to address issue #1061, and add a function
alternative to the `eof!` macro as well as its tests.
2020-08-30 14:31:31 +02:00
Geoffroy Couprie
11571df573 update the docs on char 2020-08-30 14:20:30 +02:00
Geoffroy Couprie
3dcddc9cc1 Fix Incomplete behaviour in character::streaming::char
we know the length of the expected char and of the input data, so we
know how many more bytes we need
2020-08-30 14:20:16 +02:00
Geoffroy Couprie
5108ed18d5 add the satisfy combinator, that checks a predicate on the next char 2020-08-30 14:16:12 +02:00
Geoffroy Couprie
b2ed755e27 convert_error should accept a type that derefs to &str
this will allow other input types like nom_locate
2020-08-30 11:26:36 +02:00
Tianyi Shi
42248ee1b5 Add PDB parser to README.md
I have just started making a parser for PDB (protein data bank format) files.
2020-08-30 11:05:15 +02:00
Geoffroy Couprie
af7d8feda4 Introduce the FromExternalError trait for map_res and verify
*breaking change*

this trait allows a custom error type to integrate errors from functions
like `FromStr::from_str`.
This is a breaking change because it modifies the API of `map_res` to
require this trait
2020-08-30 11:02:17 +02:00
Geoffroy Couprie
bf83d5d978 basic std::error::Error implementations for Error and VerboseError 2020-08-24 14:51:03 +02:00
Geoffroy Couprie
981d036ca8 replace the basic error tuple with a struct
this will allow implementing traits on the error type
2020-08-24 11:35:14 +02:00
Geoffroy Couprie
c5e0dc225d clean up the Incomplete behaviour
*breaking change*

At the beginnng, Needed was supposed to indicate the total number of
bytes needed in the input buffer, and this resulted in complicated
calculations as the parser result bubbled up through previous parsers.

This was changed to indicate only how many additional bytes were needed,
but most of th parsers did not really implement it properly, so this
commit fixes it.
Note: in some cases, like take(&str), where a char can span a varying number
of bytes, we cannot know in advance how many bytes are needed.
For take_until, we could detect that the last few bytes are a prefix of
the tag we are looking for, and indicate how many we need like for
`tag`, but I am not convinced yet that it is worth the effort (and
there's no guarantee that the prefix will be followed by the bytes we
want)
2020-08-23 18:54:32 +02:00
Tianyi Shi
e458dea6b3 New parser using nom to be shown in README.md
I've implemented a [FASTA parser](https://github.com/TianyiShi2001/nom-fasta) using nom.
2020-08-23 17:17:31 +02:00
Caleb Sander
3a61f2453f Simplify branching parsers 2020-08-23 17:11:14 +02:00
Caleb Sander
4d5e2484c2 Simplify and optimize trait implementations 2020-08-23 16:48:09 +02:00
Geoffroy Couprie
12c0e922ed
remove Mozilla IRC mentions 2020-08-23 11:52:17 +02:00