diff --git a/src/protocol/parser/mod.rs b/src/protocol/parser/mod.rs index 39de7073241552963fc106ab248880774a9e45fa..6d2a3281c144df2d3547c8bf2622498bdb2dd6a0 100644 --- a/src/protocol/parser/mod.rs +++ b/src/protocol/parser/mod.rs @@ -204,12 +204,6 @@ impl Parser { arch: &self.arch, }; - if let Some(filename) = &self.write_tokens_to { - let mut writer = TokenWriter::new(); - let mut file = std::fs::File::create(std::path::Path::new(filename)).unwrap(); - writer.write(&mut file, &self.modules); - } - // Advance all modules to the phase where all symbols are scanned for module_idx in 0..self.modules.len() { self.pass_symbols.parse(&mut self.modules, module_idx, &mut pass_ctx)?; @@ -222,6 +216,12 @@ impl Parser { self.pass_definitions.parse(&mut self.modules, module_idx, &mut pass_ctx)?; } + if let Some(filename) = &self.write_tokens_to { + let mut writer = TokenWriter::new(); + let mut file = std::fs::File::create(std::path::Path::new(filename)).unwrap(); + writer.write(&mut file, &self.modules); + } + // Add every known type to the type table self.type_table.build_base_types(&mut self.modules, &mut pass_ctx)?;