Is it possible to declare parser function like nom's named
macro?
#391
-
Greetings, I just start learning rust so maybe this is more of a rust question. Basically I want to do something like Then I saw nom's So I guess my question is, do people nowadays just accept to write all parsers like this:
instead of something like By the way thanks for the great tutorial, it's really helpful for a beginner like me. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
FYI the macro parsers, like If you want to use
The challenge with using it in a global scope is that parsers are inherently mutable. This works with Rust's type system in most cases but there are some exceptions and I'm assuming a global is one. For global parsers, is there a concern with putting it in a function? |
Beta Was this translation helpful? Give feedback.
FYI the macro parsers, like
named!
, aren't in nom anymore, not just one being preferred.If you want to use
let a_or_b
within a function, that should work. The following compilesThe challenge with using it in a global scope is that parsers are inherently mutable. This works with Rust's type system in most cases but there are some exceptions and I'm assuming a global is one.
For global parsers, is there a concern …