From 65dc362a1d2e76678f5bb4568d2606a563c497b5 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 2 Feb 2017 11:33:07 -0800 Subject: [PATCH] Killed some warnings, cleaned up some code --- src/language.rs | 1 - src/maaru_lang/mod.rs | 8 ++++---- src/main.rs | 18 +++++++++++------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/language.rs b/src/language.rs index 43aceaf..e5d7ec9 100644 --- a/src/language.rs +++ b/src/language.rs @@ -1,4 +1,3 @@ -use std::default::Default; use std::fmt::Debug; #[derive(Debug)] diff --git a/src/maaru_lang/mod.rs b/src/maaru_lang/mod.rs index cede430..e016e1a 100644 --- a/src/maaru_lang/mod.rs +++ b/src/maaru_lang/mod.rs @@ -28,17 +28,17 @@ impl ProgrammingLanguage for Maaru { "Maaru".to_string() } - fn tokenize(input: &str) -> Result, TokenError> { + fn tokenize(_input: &str) -> Result, TokenError> { Ok(vec![Token { }]) } - fn parse(input: Vec) -> Result { + fn parse(_input: Vec) -> Result { Ok(AST { }) } - fn evaluate(ast: Self::AST, evaluator: &mut Self::Evaluator) -> Vec { + fn evaluate(_ast: Self::AST, _evaluator: &mut Self::Evaluator) -> Vec { vec!["Unimplemented".to_string()] } - fn compile(ast: Self::AST) -> LLVMCodeString { + fn compile(_ast: Self::AST) -> LLVMCodeString { unimplemented!() } } diff --git a/src/main.rs b/src/main.rs index 9d38059..204e44c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,16 +41,20 @@ fn main() { } std::process::exit(1); } - let trace = option_matches.opt_present("t"); - let show_llvm = option_matches.opt_present("l"); + + let show_llvm_ir = option_matches.opt_present("l"); + let compile = !option_matches.opt_present("i"); + let trace_evaluation = option_matches.opt_present("t"); + match option_matches.free[..] { [] | [_] => { let mut repl = Repl::new(languages); + repl.show_llvm_ir = show_llvm_ir; repl.run(); } [_, ref filename, _..] => { let language = Schala::new(); - run_noninteractive(filename, !option_matches.opt_present("i"), trace, &language); + run_noninteractive(filename, &language, trace_evaluation, compile); } }; } @@ -72,7 +76,7 @@ fn program_options() -> getopts::Options { options } -fn run_noninteractive<'a, T: ProgrammingLanguage>(filename: &str, compile: bool, trace_evaluation: bool, language: &T) { +fn run_noninteractive<'a, T: ProgrammingLanguage>(filename: &str, _language: &T, trace_evaluation: bool, compile: bool) { let mut source_file = File::open(&Path::new(filename)).unwrap(); let mut buffer = String::new(); source_file.read_to_string(&mut buffer).unwrap(); @@ -110,9 +114,9 @@ fn run_noninteractive<'a, T: ProgrammingLanguage>(filename: &str, compile: bool, type LineReader = linefeed::Reader; struct Repl { - show_tokens: bool, - show_parse: bool, - show_llvm_ir: bool, + pub show_tokens: bool, + pub show_parse: bool, + pub show_llvm_ir: bool, languages: Vec>, current_language_index: usize, interpreter_directive_sigil: char,