You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to feature gate some rules in grammar, so tried to place #[cfg(feature = "...")] on it, but grammar! does not accept that. It would be nice if I could do that:
peg::parser! {/// Contains generated parser for Kaitai Struct expression language.
grammar parser()forstr{/// Entry point for parsing enum values (keys of `number: enum_variant_name`).// TODO: It is better to use integer() rule to parse that// See https://github.com/kaitai-io/kaitai_struct/issues/1132
#[cfg(feature = "compatible")]//<<<<<<<<<<<<<<<<<<<<<< impossiblepub rule parse_enum_value() -> BigInt
= "0x" n:$(hex()+){? to_int(n,16)}
/ n:$(['0'..='9' | '_']+){? to_int(n,10)};
#[cfg(not(feature = "compatible"))]//<<<<<<<<<<<<<<<<<<<<<< impossiblepub rule parse_enum_value() -> BigInt
= "-" n:integer(){ -n }
/ integer();}}
The text was updated successfully, but these errors were encountered:
cfg could definitely be propagated to the pub and internal functions that implement the rule plus things like the struct field used for #[cache]. For arbitrary attributes, it's not clear where they should be applied in the generated code, and are probably too much of a forwards-compatibility hazard, though.
I want to feature gate some rules in grammar, so tried to place
#[cfg(feature = "...")]
on it, butgrammar!
does not accept that. It would be nice if I could do that:The text was updated successfully, but these errors were encountered: