Add settings and isa command-line options to cton-util wasm. (#158)

* Add settings and isa command-line options to cton-util wasm.

* Use map_err to simplify error handling.

* Use `&*` instead of `.borrow()`.
This commit is contained in:
Dan Gohman
2017-09-14 17:41:43 -07:00
committed by GitHub
parent 0737aa48f2
commit 9e77af25a3
4 changed files with 47 additions and 21 deletions

View File

@@ -8,7 +8,8 @@ use std::result;
/// The location of a `Token` or `Error`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct Location {
/// Line number, starting from 1.
/// Line number. Command-line arguments are line 0 and source file
/// lines start from 1.
pub line_number: usize,
}
@@ -23,7 +24,11 @@ pub struct Error {
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}: {}", self.location.line_number, self.message)
if self.location.line_number == 0 {
write!(f, "command-line arguments: {}", self.message)
} else {
write!(f, "{}: {}", self.location.line_number, self.message)
}
}
}

View File

@@ -11,7 +11,7 @@ pub use error::{Location, Result, Error};
pub use parser::{parse_functions, parse_test};
pub use testcommand::{TestCommand, TestOption};
pub use testfile::{TestFile, Details, Comment};
pub use isaspec::IsaSpec;
pub use isaspec::{IsaSpec, parse_options};
pub use sourcemap::SourceMap;
mod error;