diff --git a/nom-language/src/lib.rs b/nom-language/src/lib.rs index 01b2862e..c018f319 100644 --- a/nom-language/src/lib.rs +++ b/nom-language/src/lib.rs @@ -6,3 +6,4 @@ //! at language parsing. pub mod error; +pub mod precedence; diff --git a/src/precedence/mod.rs b/nom-language/src/precedence/mod.rs similarity index 97% rename from src/precedence/mod.rs rename to nom-language/src/precedence/mod.rs index 22c9cc1e..d3f37798 100644 --- a/src/precedence/mod.rs +++ b/nom-language/src/precedence/mod.rs @@ -1,13 +1,10 @@ //! Combinators to parse expressions with operator precedence. -#![cfg(feature = "alloc")] -#![cfg_attr(feature = "docsrs", doc(cfg(feature = "alloc")))] #[cfg(test)] mod tests; -use crate::error::{ErrorKind, FromExternalError, ParseError}; -use crate::lib::std::vec::Vec; -use crate::{Err, IResult, Parser}; +use nom::error::{ErrorKind, FromExternalError, ParseError}; +use nom::{Err, IResult, Parser}; /// An unary operator. pub struct Unary { @@ -203,7 +200,6 @@ where /// * It then reads the remaining input and evaluates the increment next in order to preserve its /// position in the expression \ /// `((-a)++)**b`. -#[cfg_attr(feature = "docsrs", doc(cfg(feature = "alloc")))] pub fn precedence( mut prefix: H1, mut postfix: H2, diff --git a/src/precedence/tests.rs b/nom-language/src/precedence/tests.rs similarity index 95% rename from src/precedence/tests.rs rename to nom-language/src/precedence/tests.rs index 04a86be0..a7237abc 100644 --- a/src/precedence/tests.rs +++ b/nom-language/src/precedence/tests.rs @@ -1,5 +1,5 @@ use crate::precedence::{binary_op, unary_op, Assoc, Operation}; -use crate::{ +use nom::{ branch::alt, bytes::complete::tag, character::complete::digit1, @@ -9,10 +9,8 @@ use crate::{ sequence::delimited, }; -#[cfg(feature = "alloc")] use crate::precedence::precedence; -#[cfg(feature = "alloc")] fn parser(i: &str) -> IResult<&str, i64> { precedence( unary_op(1, tag("-")), @@ -42,7 +40,6 @@ fn parser(i: &str) -> IResult<&str, i64> { } #[test] -#[cfg(feature = "alloc")] fn precedence_test() { assert_eq!(parser("3"), Ok(("", 3))); assert_eq!(parser("-3"), Ok(("", -3))); diff --git a/src/lib.rs b/src/lib.rs index db4c8703..c82715a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -451,8 +451,6 @@ pub mod bytes; pub mod character; -pub mod precedence; - mod str; pub mod number; diff --git a/tests/expression_ast.rs b/tests/expression_ast.rs index 0e4fbd98..0d04c9bb 100644 --- a/tests/expression_ast.rs +++ b/tests/expression_ast.rs @@ -4,10 +4,10 @@ use nom::{ character::complete::{alphanumeric1 as alphanumeric, digit1 as digit}, combinator::{map, map_res}, multi::separated_list0, - precedence::{binary_op, precedence, unary_op, Assoc, Operation}, sequence::delimited, IResult, Parser, }; +use nom_language::precedence::{binary_op, precedence, unary_op, Assoc, Operation}; // Elements of the abstract syntax tree (ast) that represents an expression. #[derive(Debug)] @@ -119,7 +119,7 @@ fn expression(i: &str) -> IResult<&str, Expr> { delimited(tag("("), expression, tag(")")), )), |op: Operation| -> Result { - use nom::precedence::Operation::*; + use nom_language::precedence::Operation::*; use BinaryOp::*; use PostfixOp::*; use PrefixOp::*;