comparison formats/src/th06/ecl.rs @ 776:94033091458b

formats: Update to ${concat(…)} to build on current nightly ${concat(…)} replaces the removed concat_idents!() macro, but doesn’t support being used in nested repetitions for now. We can remove the gen_match!() macro once this is supported again.
author Link Mauve <linkmauve@linkmauve.fr>
date Tue, 14 Oct 2025 12:41:29 +0000
parents d08eb4c9fce3
children 11249e4b4e03
comparison
equal deleted inserted replaced
775:28d8b892fd06 776:94033091458b
115 pub fn from_slice(data: &[u8]) -> IResult<&[u8], Ecl> { 115 pub fn from_slice(data: &[u8]) -> IResult<&[u8], Ecl> {
116 parse_ecl(data) 116 parse_ecl(data)
117 } 117 }
118 } 118 }
119 119
120 macro_rules! gen_match {
121 ($arg_type:ident) => {
122 ${concat(le_, $arg_type)}
123 };
124 }
125
120 macro_rules! declare_main_instructions { 126 macro_rules! declare_main_instructions {
121 ($($opcode:tt => fn $name:ident($($arg:ident: $arg_type:ident),*)),*,) => { 127 ($($opcode:tt => fn $name:ident($($arg:ident: $arg_type:ident),*)),*,) => {
122 /// Available instructions in an `Ecl`. 128 /// Available instructions in an `Ecl`.
123 #[allow(missing_docs)] 129 #[allow(missing_docs)]
124 #[derive(Debug, Clone, Copy)] 130 #[derive(Debug, Clone, Copy)]
132 let mut i = &input[..]; 138 let mut i = &input[..];
133 let instr = match opcode { 139 let instr = match opcode {
134 $( 140 $(
135 $opcode => { 141 $opcode => {
136 $( 142 $(
137 let (i2, $arg) = concat_idents!(le_, $arg_type)(i)?; 143 let (i2, $arg) = gen_match!($arg_type)(i)?;
138 i = i2; 144 i = i2;
139 )* 145 )*
140 MainInstruction::$name($($arg),*) 146 MainInstruction::$name($($arg),*)
141 } 147 }
142 )* 148 )*
170 let mut i = &input[..]; 176 let mut i = &input[..];
171 let instr = match opcode { 177 let instr = match opcode {
172 $( 178 $(
173 $opcode => { 179 $opcode => {
174 $( 180 $(
175 let (i2, $arg) = concat_idents!(le_, $arg_type)(i)?; 181 let (i2, $arg) = gen_match!($arg_type)(i)?;
176 i = i2; 182 i = i2;
177 )* 183 )*
178 SubInstruction::$name($($arg),*) 184 SubInstruction::$name($($arg),*)
179 } 185 }
180 )* 186 )*