1pub mod ampl;
14pub mod gmpl;
15pub mod mps;
16
17use cnvx_core::Model;
18
19pub use ampl::AMPLLanguage;
20pub use gmpl::GMPLLanguage;
21pub use mps::MPSLanguage;
22
23pub trait LanguageParser {
25 fn parse(&self, src: &str) -> Result<Model, String>;
26}
27
28pub fn parse(contents: &str, file_type: &str) -> Result<Model, String> {
29 let model = match file_type {
30 "ampl" => AMPLLanguage::new().parse(contents)?,
31 "gmpl" => GMPLLanguage::new().parse(contents)?,
32 "mps" => MPSLanguage::new().parse(contents)?,
33 _ => return Err(format!("unsupported file type: {}", file_type)),
34 };
35
36 Ok(model)
37}