Commit Graph

265 Commits

Author SHA1 Message Date
Geoffroy Couprie
19c4967ebb remove unused compilation tag 2018-10-06 15:38:07 +02:00
Geoffroy Couprie
277caa10a4 fix unused doc comment 2018-10-06 15:08:36 +02:00
Sven Marnach
2b21686bb3 Simplify is_hex_digit() in example. 2018-10-06 15:06:02 +02:00
Geoffroy Couprie
0009b6090a add tests from issues 2018-08-18 18:05:09 +02:00
François Laignel
cd1275054f Use a dedicate error kind for parse_to!
Upon failure, `parse_to!` returns an error with `ErrorKind::MapOpt`.
Return `ErrorKind::ParseTo` instead.

Reproduce with:
``` rust
use nom::{Context, Err, ErrorKind};

assert_eq!(
    Err::Error(Context::Code("ab", ErrorKind::MapOpt)),
    parse_to!("ab", usize).unwrap_err(),
)
```
2018-08-18 16:27:48 +02:00
Szabolcs Berecz
4e74e735c3 Fixes #780: "Use of undeclared type or module Needed" 2018-07-15 21:45:07 +02:00
Konrad Borowski
285d21cf43 Use match instead of comparisons in is_hex_digit example in README
This makes it more readable for programmers who don't remember the ASCII table.
2018-05-19 11:57:41 +02:00
Geoffroy Couprie
ed1abaf03c fix type inference in the value combinator 2018-05-19 11:53:08 +02:00
Geoffroy Couprie
a7aa0c6cd5 move the test for issue 759 to the tests/issues.rs file 2018-05-19 11:53:08 +02:00
Konrad Borowski
8be1b06d7f Allow using take_till1! macro without having ErrorKind imported
Fixes #759
2018-05-19 11:41:18 +02:00
Geoffroy Couprie
a2a66c84fe remove unused tests 2018-05-14 13:46:31 +02:00
Sharad Chand
1de2b6ff56 Demonstrate issue #741 2018-04-25 11:47:10 +02:00
Kamil Markiewicz
9d16b67790 Some tests are constrained just on alloc 2018-04-08 12:00:44 +02:00
Geoffroy Couprie
fb119849da fix unit tests 2018-03-28 10:56:16 +02:00
Geoffroy Couprie
77405b915a do not require PartialEq on results in permutation 2018-03-26 11:21:59 +02:00
Geoffroy Couprie
fd490f6c60 implement FindToken for arrays 2018-03-26 11:09:58 +02:00
Sebastian Zivota
662c872729 Fixed issue #721 2018-03-26 10:49:21 +02:00
Geoffroy Couprie
87eabf9049 always install rusfmt
run rustfmt on stable
2018-02-25 13:30:13 +01:00
Geoffroy Couprie
dbbd6c9c3b remove unused test 2018-02-25 12:22:53 +01:00
Geoffroy Couprie
d43027befb fix tests 2018-02-17 17:21:42 +01:00
Geoffroy Couprie
43ed4e99f3 Merge branch 'alloc-feature' of https://github.com/kamarkiewicz/nom into kamarkiewicz-alloc-feature 2018-02-17 16:07:16 +01:00
Geoffroy Couprie
55bac0bfa8 fmt 2018-02-17 15:06:43 +01:00
Geoffroy Couprie
cdbf0e0adf fix tests in no_std 2018-02-17 14:59:50 +01:00
Geoffroy Couprie
4db765ce40 more accurate json test 2018-02-12 17:12:22 +01:00
Geoffroy Couprie
81f19c160e simplify the ini test 2018-02-11 21:50:36 +01:00
Geoffroy Couprie
45c02814cd Fix examples 2018-02-11 21:50:04 +01:00
Kamil Markiewicz
791a53cf62
WIP tests behind alloc 2018-02-05 23:18:40 +01:00
Geoffroy Couprie
d6f35cc341 fix unit tests in no_std and verbose-errors 2018-01-24 17:40:52 +01:00
Geoffroy Couprie
62a0e75a70 add a test for issue 667 2018-01-24 17:16:07 +01:00
Geoffroy Couprie
dd4711a592 missing debug derive 2018-01-24 17:10:47 +01:00
Geoffroy Couprie
526299c2a6 support dbg_dmp for CompleteByteSlice 2018-01-24 16:36:34 +01:00
Geoffroy Couprie
9a4a7668b1 fmt 2018-01-18 15:32:53 +01:00
Geoffroy Couprie
4ad20460ca stricter behaviour for alpha and other basic parsers
for these parsers: alpha, digit, hex_digit, oct_digit, alphanumeric,
space and multispace:

- handle end of file correctly
- introduce *0 and *1 versions of these parsers. The basic one maps to
the *1 version (input must return at least one char
2018-01-15 16:51:29 +01:00
Geoffroy Couprie
7bc5d426df Fix byte indexing in not_line_ending 2018-01-15 12:07:51 +01:00
Geoffroy Couprie
9608061d26 remove warnings 2018-01-13 17:03:41 +01:00
Geoffroy Couprie
6d5b23632d fix Incomplete usage in many* parsers
this is a breaking change in their behaviour:
- if they receive an empty input, they will return incomplete (if not at
eof)
- if they reach the end of input without the child parser returning an
error, they will return Incomplete

while this may break some parsers, this behaviour is more logical with
the rest of nom and much stricter
2018-01-13 16:44:21 +01:00
Geoffroy Couprie
47deaa1d03 many0 should not return until its child parser fails
if we reached the end of input, test with at_eof, to see if we should
return the whole input slice or not.
This will potentially break some existing parsers that rely on many0
trying to consume everything, but this behaviour is more correct and
aligned with the rest of nom
2018-01-11 19:29:46 +01:00
Geoffroy Couprie
484f6724ea rewrite the take_* combinators
- the combinators that do not expect a terminator (take_while, take_till) will return the whole input if input.at_eof() is true
- the combinators with the 1 suffix will return an error instead of an empty slice, even if we found the terminating tag
- combinators that expect a terminating tag but do not find it will return an error if input.at_eof() is true, incomplete if it is false
2018-01-11 15:36:51 +01:00
Geoffroy Couprie
a53febdfdf set the max line width at 140 2017-12-10 21:40:59 +01:00
Geoffroy Couprie
87d8370064 more rustfmt fixes 2017-12-10 21:05:22 +01:00
Geoffroy Couprie
e58efb7f93 start using rustfmt 2017-12-10 19:50:12 +01:00
Geoffroy Couprie
e9ffca6871 fix some clippy warnings 2017-12-10 15:53:50 +01:00
Roman Proskuryakov
1946fb0ddb Fix casting character literal to u8
Signed-off-by: Geoffroy Couprie <geo.couprie@gmail.com>
2017-12-10 00:20:00 +01:00
Roman Proskuryakov
30a63ca1f5 Fix trailing spaces
Signed-off-by: Geoffroy Couprie <geo.couprie@gmail.com>
2017-12-10 00:16:17 +01:00
Geoffroy Couprie
d7d91d2ede remove some warnings 2017-12-09 16:12:57 +01:00
Geoffroy Couprie
d9948588bf invert arguments order for error_position and error_node_position
making the input slice the first argument is more consistent with the
Context enum
2017-12-03 18:22:43 +01:00
Geoffroy Couprie
2ba0c1e515 fix build on stable 2017-11-30 09:28:53 +01:00
Geoffroy Couprie
005d390177 fix type inference issues with custom error types
the irevous solution was wrong because we only required that the input
type implement From<u32> and forced a conversion in every combinator.
But if you reused a parser that already provides the custom input type,
there was no possible conversion.

It is now made possible with a more generic conversion and removing
forced conversions. Now only the most basic parsers will force an error
type, and combinators that have their own error code will use the
unify_types trick to make sure they provide the same error code as the
underlying parsers.

It might still cause some type inference issues, but the code of
reported issues (#534, #561, #617) seems to work. We'll see during the
testing period if more of those appear.
2017-11-28 19:32:33 +01:00
Geoffroy Couprie
30e07f6217 add an example of parsing floats with CompleteStr 2017-11-26 12:06:13 +01:00
Geoffroy Couprie
2a37bb3ba7 eof should not be a Failure
instead, it lust be handled properly at the end of the parser. Making
Eof a failure would cause issues in parsers like float
2017-11-26 12:04:37 +01:00