add better string and number parsing to sexp. cleaning, more tests

This commit is contained in:
2020-10-09 00:41:09 +02:00
parent 548addc78c
commit 1f2dbaa81d
22 changed files with 612 additions and 424 deletions
+16 -8
View File
@@ -33,7 +33,7 @@ struct Config {
#[serde(skip)]
program_file: String,
#[serde(skip)]
asm_only: bool,
assemble_only: bool,
#[serde(with = "serde_duration_millis")]
cycle_time: Duration,
}
@@ -42,11 +42,11 @@ impl Default for Config {
fn default() -> Self {
Self {
log: LogConfig {
level: "info".to_string(),
level: "warn".to_string(),
modules: Default::default(),
},
program_file: "".to_string(),
asm_only: false,
assemble_only: false,
cycle_time: Duration::default(),
}
}
@@ -63,6 +63,14 @@ impl AppConfig for Config {
Some(&self.log.modules)
}
fn pre_log_println(_message: String) {
// shut up
}
fn print_banner(_name: &str, _version: &str) {
// No banner
}
/// Add args to later use in the `configure` method.
fn add_args<'a: 'b, 'b>(clap: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
// Default impl
@@ -106,7 +114,7 @@ impl AppConfig for Config {
fn configure(mut self, clap: &ArgMatches) -> anyhow::Result<Self> {
self.program_file = clap.value_of("input").unwrap().to_string();
self.asm_only = clap.is_present("asm-only");
self.assemble_only = clap.is_present("asm-only");
if let Some(c) = clap.value_of("cycle") {
self.cycle_time = Duration::from_millis(c.parse().unwrap());
}
@@ -118,7 +126,7 @@ impl AppConfig for Config {
fn main() -> anyhow::Result<()> {
let config = Config::init("crsn", "crsn.json5", env!("CARGO_PKG_VERSION"))?;
info!("Loading {}", config.program_file);
debug!("Loading {}", config.program_file);
let source = read_file::read_file(&config.program_file)?;
@@ -131,7 +139,7 @@ fn main() -> anyhow::Result<()> {
StdioOps::new(),
])?;
if config.asm_only {
if config.assemble_only {
for (n, op) in parsed.ops.iter().enumerate() {
println!("{:04} : {}", n, op.to_sexp());
}
@@ -144,7 +152,7 @@ fn main() -> anyhow::Result<()> {
trace!("------------------------");
}
info!("Start runtime");
debug!("Start runtime");
let args = &[];
let thread = RunThread::new(ThreadParams {
@@ -159,7 +167,7 @@ fn main() -> anyhow::Result<()> {
// run without spawning, so it is on the main thread - required by some extensions
thread.run();
info!("Runtime shut down.");
debug!("Runtime shut down.");
Ok(())
}