noirc_abi
Link the file being parsed to the parser. So if the user chooses a Toml Parser, it will choose the Toml file and extension
@@ -19,13 +19,28 @@ pub enum Format {
Toml,
}
+impl Format {
+ /// The name of the file that this Formatter can parse
+ /// Eg. The Toml parser will look for an `input.toml`
+ /// file in the directory.
+ pub fn file_name(&self) -> &'static str {
+ match self {
+ Format::Toml => "input.toml",
+ }
+ }
+}
+
impl Format {
pub fn parse<P: AsRef<Path>>(
&self,
path: P,
) -> (BTreeMap<String, FieldElement>, Vec<(String, usize)>) {
match self {
- Format::Toml => toml::parse(path),
+ Format::Toml => {
+ let mut dir_path = path.as_ref().to_path_buf();
+ dir_path.push(self.file_name());
+ toml::parse(dir_path)
+ }
}
}
}
