Assembler program

This commit is contained in:
Erin 2023-06-07 15:17:45 +02:00 committed by ondra05
parent cbb0ac2abe
commit 0fd3aee6b5
2 changed files with 22 additions and 2 deletions

View file

@ -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()?

View file

@ -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(())
} }