Skip to content

Commit

Permalink
Merge branch 'Restioson-fix-nostd'
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Apr 8, 2018
2 parents 59a0534 + db7f902 commit 9b12a2d
Show file tree
Hide file tree
Showing 19 changed files with 429 additions and 307 deletions.
67 changes: 66 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ std = ["alloc", "memchr/use_std"]
default = ["std"]
regexp = ["regex"]
regexp_macros = ["regexp", "lazy_static"]
verbose-errors = []
verbose-errors = ["alloc"]

[dependencies.regex]
version = "^0.2"
Expand All @@ -45,5 +45,70 @@ default-features = false
#git = "https://github.com/carllerche/bytes"
#rev = "a7d38e29"

[[test]]
name = "arithmetic"

[[test]]
name = "arithmetic_ast"
required-features = ["alloc"]

[[test]]
name = "blockbuf-arithmetic"

[[test]]
name = "complete_arithmetic"

[[test]]
name = "complete_float"

[[test]]
name = "css"

[[test]]
name = "custom_errors"

[[test]]
name = "float"

[[test]]
name = "inference"

[[test]]
name = "ini"
required-features = ["alloc"]

[[test]]
name = "ini_str"
required-features = ["alloc"]

[[test]]
name = "issues"
required-features = ["alloc"]

[[test]]
name = "json"

[[test]]
name = "mp4"

[[test]]
name = "multiline"
required-features = ["alloc"]

[[test]]
name = "named_args"

[[test]]
name = "omnom"

[[test]]
name = "overflow"

[[test]]
name = "reborrow_fold"

[[test]]
name = "test1"

[badges]
travis-ci = { repository = "Geal/nom" }
18 changes: 9 additions & 9 deletions src/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ macro_rules! bits (
macro_rules! bits_impl (
($i:expr, $submac:ident!( $($args:tt)* )) => (
{
use ::std::result::Result::*;
use $crate::lib::std::result::Result::*;
use $crate::{Context,Err,Needed};

let input = ($i, 0usize);
Expand Down Expand Up @@ -90,7 +90,7 @@ macro_rules! bits_impl (
macro_rules! bits_impl (
($i:expr, $submac:ident!( $($args:tt)* )) => (
{
use ::std::result::Result::*;
use $crate::lib::std::result::Result::*;
use $crate::{Err,Needed,Context};

let input = ($i, 0usize);
Expand Down Expand Up @@ -157,7 +157,7 @@ macro_rules! bytes (
macro_rules! bytes_impl (
($macro_i:expr, $submac:ident!( $($args:tt)* )) => (
{
use ::std::result::Result::*;
use $crate::lib::std::result::Result::*;
use $crate::{Err,Needed};

let inp;
Expand Down Expand Up @@ -217,7 +217,7 @@ macro_rules! bytes_impl (
macro_rules! bytes_impl (
($macro_i:expr, $submac:ident!( $($args:tt)* )) => (
{
use ::std::result::Result::*;
use $crate::lib::std::result::Result::*;
use $crate::{Err,Needed};

let inp;
Expand Down Expand Up @@ -271,11 +271,11 @@ macro_rules! bytes_impl (
macro_rules! take_bits (
($i:expr, $t:ty, $count:expr) => (
{
use ::std::result::Result::*;
use $crate::lib::std::result::Result::*;
use $crate::{Needed,IResult};

use std::ops::Div;
use std::convert::Into;
use $crate::lib::std::ops::Div;
use $crate::lib::std::convert::Into;
//println!("taking {} bits from {:?}", $count, $i);
let (input, bit_offset) = $i;
let res : IResult<(&[u8],usize), $t> = if $count == 0 {
Expand Down Expand Up @@ -341,7 +341,7 @@ macro_rules! take_bits (
macro_rules! tag_bits (
($i:expr, $t:ty, $count:expr, $p: pat) => (
{
use ::std::result::Result::*;
use $crate::lib::std::result::Result::*;
use $crate::{Err,IResult};

match take_bits!($i, $t, $count) {
Expand All @@ -366,7 +366,7 @@ macro_rules! tag_bits (

#[cfg(test)]
mod tests {
use std::ops::{AddAssign, Shl, Shr};
use lib::std::ops::{AddAssign, Shl, Shr};
use internal::{Err, Needed};
use util::ErrorKind;

Expand Down
76 changes: 38 additions & 38 deletions src/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ macro_rules! alt (

(__impl $i:expr, $subrule:ident!( $($args:tt)*) | $($rest:tt)*) => (
{
use ::std::result::Result::*;
use $crate::lib::std::result::Result::*;
use $crate::Err;

let i_ = $i.clone();
Expand All @@ -212,7 +212,7 @@ macro_rules! alt (

(__impl $i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr } | $($rest:tt)*) => (
{
use ::std::result::Result::*;
use $crate::lib::std::result::Result::*;
use $crate::Err;

let i_ = $i.clone();
Expand Down Expand Up @@ -286,7 +286,7 @@ macro_rules! alt_complete (

($i:expr, $subrule:ident!( $($args:tt)*) | $($rest:tt)*) => (
{
use ::std::result::Result::*;
use $crate::lib::std::result::Result::*;
use $crate::Err;

let i_ = $i.clone();
Expand All @@ -312,7 +312,7 @@ macro_rules! alt_complete (

($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr } | $($rest:tt)+) => (
{
use ::std::result::Result::*;
use $crate::lib::std::result::Result::*;
use $crate::Err;

let i_ = $i.clone();
Expand Down Expand Up @@ -438,8 +438,8 @@ macro_rules! alt_complete (
macro_rules! switch (
(__impl $i:expr, $submac:ident!( $($args:tt)* ), $( $($p:pat)|+ => $subrule:ident!( $($args2:tt)* ))|* ) => (
{
use ::std::result::Result::*;
use ::std::option::Option::*;
use $crate::lib::std::result::Result::*;
use $crate::lib::std::option::Option::*;
use $crate::{Err,Convert,ErrorKind};

let i_ = $i.clone();
Expand Down Expand Up @@ -562,8 +562,8 @@ macro_rules! switch (
macro_rules! permutation (
($i:expr, $($rest:tt)*) => (
{
use ::std::result::Result::*;
use ::std::option::Option::*;
use $crate::lib::std::result::Result::*;
use $crate::lib::std::option::Option::*;
use $crate::{Err,Convert,ErrorKind};

let mut res = permutation_init!((), $($rest)*);
Expand Down Expand Up @@ -604,45 +604,45 @@ macro_rules! permutation (
#[macro_export]
macro_rules! permutation_init (
((), $e:ident?, $($rest:tt)*) => (
permutation_init!((::std::option::Option::None), $($rest)*)
permutation_init!(($crate::lib::std::option::Option::None), $($rest)*)
);
((), $e:ident, $($rest:tt)*) => (
permutation_init!((::std::option::Option::None), $($rest)*)
permutation_init!(($crate::lib::std::option::Option::None), $($rest)*)
);

((), $submac:ident!( $($args:tt)* )?, $($rest:tt)*) => (
permutation_init!((::std::option::Option::None), $($rest)*)
permutation_init!(($crate::lib::std::option::Option::None), $($rest)*)
);
((), $submac:ident!( $($args:tt)* ), $($rest:tt)*) => (
permutation_init!((::std::option::Option::None), $($rest)*)
permutation_init!(($crate::lib::std::option::Option::None), $($rest)*)
);

(($($parsed:expr),*), $e:ident?, $($rest:tt)*) => (
permutation_init!(($($parsed),* , ::std::option::Option::None), $($rest)*);
permutation_init!(($($parsed),* , $crate::lib::std::option::Option::None), $($rest)*);
);
(($($parsed:expr),*), $e:ident, $($rest:tt)*) => (
permutation_init!(($($parsed),* , ::std::option::Option::None), $($rest)*);
permutation_init!(($($parsed),* , $crate::lib::std::option::Option::None), $($rest)*);
);

(($($parsed:expr),*), $submac:ident!( $($args:tt)* )?, $($rest:tt)*) => (
permutation_init!(($($parsed),* , ::std::option::Option::None), $($rest)*);
permutation_init!(($($parsed),* , $crate::lib::std::option::Option::None), $($rest)*);
);
(($($parsed:expr),*), $submac:ident!( $($args:tt)* ), $($rest:tt)*) => (
permutation_init!(($($parsed),* , ::std::option::Option::None), $($rest)*);
permutation_init!(($($parsed),* , $crate::lib::std::option::Option::None), $($rest)*);
);

(($($parsed:expr),*), $e:ident) => (
($($parsed),* , ::std::option::Option::None)
($($parsed),* , $crate::lib::std::option::Option::None)
);
(($($parsed:expr),*), $e:ident?) => (
($($parsed),* , ::std::option::Option::None)
($($parsed),* , $crate::lib::std::option::Option::None)
);

(($($parsed:expr),*), $submac:ident!( $($args:tt)* )?) => (
($($parsed),* , ::std::option::Option::None)
($($parsed),* , $crate::lib::std::option::Option::None)
);
(($($parsed:expr),*), $submac:ident!( $($args:tt)* )) => (
($($parsed),* , ::std::option::Option::None)
($($parsed),* , $crate::lib::std::option::Option::None)
);
(($($parsed:expr),*),) => (
($($parsed),*)
Expand Down Expand Up @@ -714,7 +714,7 @@ macro_rules! permutation_unwrap (
if res.is_some() {
succ!($it, permutation_unwrap!((res.unwrap()), $res, $($rest)*))
} else {
::std::option::Option::None
$crate::lib::std::option::Option::None
}
});

Expand All @@ -726,7 +726,7 @@ macro_rules! permutation_unwrap (
if res.is_some() {
succ!($it, permutation_unwrap!((res.unwrap()), $res, $($rest)*))
} else {
::std::option::Option::None
$crate::lib::std::option::Option::None
}
});

Expand All @@ -738,7 +738,7 @@ macro_rules! permutation_unwrap (
if res.is_some() {
succ!($it, permutation_unwrap!(($($parsed),* , res.unwrap()), $res, $($rest)*))
} else {
::std::option::Option::None
$crate::lib::std::option::Option::None
}
});

Expand All @@ -750,31 +750,31 @@ macro_rules! permutation_unwrap (
if res.is_some() {
succ!($it, permutation_unwrap!(($($parsed),* , res.unwrap()), $res, $($rest)*))
} else {
::std::option::Option::None
$crate::lib::std::option::Option::None
}
});

($it:tt, ($($parsed:expr),*), $res:ident?, $e:ident) => (
::std::option::Option::Some(($($parsed),* , { acc!($it, $res) }))
$crate::lib::std::option::Option::Some(($($parsed),* , { acc!($it, $res) }))
);
($it:tt, ($($parsed:expr),*), $res:ident, $e:ident) => ({
let res = acc!($it, $res);
if res.is_some() {
::std::option::Option::Some(($($parsed),* , res.unwrap() ))
$crate::lib::std::option::Option::Some(($($parsed),* , res.unwrap() ))
} else {
::std::option::Option::None
$crate::lib::std::option::Option::None
}
});

($it:tt, ($($parsed:expr),*), $res:ident, $submac:ident!( $($args:tt)* )?) => (
::std::option::Option::Some(($($parsed),* , { acc!($it, $res) }))
$crate::lib::std::option::Option::Some(($($parsed),* , { acc!($it, $res) }))
);
($it:tt, ($($parsed:expr),*), $res:ident, $submac:ident!( $($args:tt)* )) => ({
let res = acc!($it, $res);
if res.is_some() {
::std::option::Option::Some(($($parsed),* , res.unwrap() ))
$crate::lib::std::option::Option::Some(($($parsed),* , res.unwrap() ))
} else {
::std::option::Option::None
$crate::lib::std::option::Option::None
}
});
);
Expand All @@ -793,22 +793,22 @@ macro_rules! permutation_iterator (
permutation_iterator!($it, $i, $all_done, $needed, $res, $submac!($($args)*) , $($rest)*);
};
($it:tt, $i:expr, $all_done:expr, $needed:expr, $res:expr, $submac:ident!( $($args:tt)* ), $($rest:tt)*) => ({
use ::std::result::Result::*;
use ::std::option::Option::*;
use $crate::lib::std::result::Result::*;
use $crate::lib::std::option::Option::*;
use $crate::Err;

if acc!($it, $res).is_none() {
match $submac!($i, $($args)*) {
Ok((i,o)) => {
$i = i;
acc!($it, $res) = ::std::option::Option::Some(o);
acc!($it, $res) = $crate::lib::std::option::Option::Some(o);
continue;
},
Err(Err::Error(_)) => {
$all_done = false;
},
Err(e) => {
$needed = ::std::option::Option::Some(e);
$needed = $crate::lib::std::option::Option::Some(e);
break;
}
};
Expand All @@ -827,8 +827,8 @@ macro_rules! permutation_iterator (
permutation_iterator!($it, $i, $all_done, $needed, $res, $submac!($($args)*));
};
($it:tt, $i:expr, $all_done:expr, $needed:expr, $res:expr, $submac:ident!( $($args:tt)* )) => ({
use ::std::result::Result::*;
use ::std::option::Option::*;
use $crate::lib::std::result::Result::*;
use $crate::lib::std::option::Option::*;
use $crate::Err;

if acc!($it, $res).is_none() {
Expand All @@ -853,7 +853,7 @@ macro_rules! permutation_iterator (
#[cfg(test)]
mod tests {
#[cfg(feature = "alloc")]
use std::string::{String, ToString};
use lib::std::string::{String, ToString};
use internal::{Err, IResult, Needed};
use util::ErrorKind;

Expand All @@ -878,7 +878,7 @@ mod tests {
($i:expr, $bytes: expr) => (
{
use $crate::need_more;
use std::cmp::min;
use $crate::lib::std::cmp::min;

let len = $i.len();
let blen = $bytes.len();
Expand Down
Loading

0 comments on commit 9b12a2d

Please sign in to comment.