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:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user