Tighten names in Language trait

This commit is contained in:
Greg Shuflin 2021-10-13 01:09:24 -07:00
parent 7b7e20859f
commit 7e0acb7d87
4 changed files with 11 additions and 6 deletions

View File

@ -251,8 +251,13 @@ fn stage_names() -> Vec<&'static str> {
impl ProgrammingLanguageInterface for Schala { impl ProgrammingLanguageInterface for Schala {
fn get_language_name(&self) -> String { format!("Schala") } fn language_name(&self) -> String {
fn get_source_file_suffix(&self) -> String { format!("schala") } "Schala".to_owned()
}
fn source_file_suffix(&self) -> String {
"schala".to_owned()
}
fn run_computation(&mut self, request: ComputationRequest) -> ComputationResponse { fn run_computation(&mut self, request: ComputationRequest) -> ComputationResponse {
struct PassToken<'a> { struct PassToken<'a> {

View File

@ -2,8 +2,8 @@ use std::collections::HashSet;
use std::time; use std::time;
pub trait ProgrammingLanguageInterface { pub trait ProgrammingLanguageInterface {
fn get_language_name(&self) -> String; fn language_name(&self) -> String;
fn get_source_file_suffix(&self) -> String; fn source_file_suffix(&self) -> String;
fn run_computation(&mut self, _request: ComputationRequest) -> ComputationResponse { fn run_computation(&mut self, _request: ComputationRequest) -> ComputationResponse {
ComputationResponse { ComputationResponse {

View File

@ -44,7 +44,7 @@ pub fn run_noninteractive(filenames: Vec<PathBuf>, languages: Vec<Box<dyn Progra
let mut language = Box::new( let mut language = Box::new(
languages languages
.into_iter() .into_iter()
.find(|lang| lang.get_source_file_suffix() == ext) .find(|lang| lang.source_file_suffix() == ext)
.unwrap_or_else(|| { .unwrap_or_else(|| {
println!("Extension .{} not recognized", ext); println!("Extension .{} not recognized", ext);
exit(1); exit(1);

View File

@ -75,7 +75,7 @@ fn global_help(repl: &mut Repl) -> InterpreterDirectiveOutput {
writeln!( writeln!(
buf, buf,
"Language-specific help for {}", "Language-specific help for {}",
lang.get_language_name() lang.language_name()
) )
.unwrap(); .unwrap();
writeln!(buf, "-----------------------").unwrap(); writeln!(buf, "-----------------------").unwrap();