Assembler program
This commit is contained in:
parent
cbb0ac2abe
commit
0fd3aee6b5
|
@ -1,3 +1,4 @@
|
||||||
|
use std::fmt::{Display, Formatter};
|
||||||
use {
|
use {
|
||||||
logos::{Lexer, Logos, Span},
|
logos::{Lexer, Logos, Span},
|
||||||
std::{ops::Range, str::FromStr},
|
std::{ops::Range, str::FromStr},
|
||||||
|
@ -58,6 +59,14 @@ pub struct Error {
|
||||||
span: Span,
|
span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for Error {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "Error {:?} at {:?}", self.kind, self.span)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for Error {}
|
||||||
|
|
||||||
macro_rules! expect_matches {
|
macro_rules! expect_matches {
|
||||||
($self:expr, $($pat:pat),* $(,)?) => {$(
|
($self:expr, $($pat:pat),* $(,)?) => {$(
|
||||||
let $pat = $self.next()?
|
let $pat = $self.next()?
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
fn main() {
|
use std::{
|
||||||
// TODO
|
error::Error,
|
||||||
|
io::{stdin, stdout, Read, Write},
|
||||||
|
};
|
||||||
|
|
||||||
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
let mut code = String::new();
|
||||||
|
stdin().read_to_string(&mut code)?;
|
||||||
|
|
||||||
|
let mut buf = vec![];
|
||||||
|
hbasm::assembly(&code, &mut buf)?;
|
||||||
|
stdout().write_all(&buf)?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue