forked from rust-bakery/nom
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use local_inner_macros annotation to support rust 2018
since macro import is now done through `use nom::the_macro` instead of `#[macro_use]`, macros using other internal macros result in the compiler complaining about missing imports. One of the solutions would be to use them through `$crate::internal_macro`, but it does not work for the comon case of `call!`: A lot of nom parsers use this pattern: ``` macro_rules! my_parser ( ($i:expr, $submac:ident!( $($args:tt)* )) => ({ //stuff }); ($i:expr, $f:expr) => ( my_parser!($i, call!($f)) ) ); ``` if I replace `call!` with `$crate::call!` rustc complains about infinite recursion because `$crate::call!($f)` is an expression. `$f` has to be an expr, because it could be a variable name, or a closure that’s written right there. And I cannot adapt `$submac:ident!` to take a path instead, because somehow module path matching does not accept a `!` right after. The other solution uses `#[macro_export(local_inner_macros)]` ( https://rust-lang-nursery.github.io/edition-guide/rust-2018/macros/macro-changes.html?highlight=macros#macros-using-local_inner_macros) to indicate some macros use other macros from the same crate, but it requires local wrappers to libstd's macros (mainly for the `dbg` and `dbg_dmp` combinators
- Loading branch information
Showing
16 changed files
with
188 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.