Assembler program

pull/1/head
ondra05 2023-06-07 15:17:45 +02:00
parent c40b10d26c
commit 16d9becbe2
No known key found for this signature in database
GPG Key ID: 0DA6D2BB2285E881
2 changed files with 22 additions and 2 deletions

View File

@ -1,3 +1,4 @@
use std::fmt::{Display, Formatter};
use {
logos::{Lexer, Logos, Span},
std::{ops::Range, str::FromStr},
@ -58,6 +59,14 @@ pub struct Error {
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 {
($self:expr, $($pat:pat),* $(,)?) => {$(
let $pat = $self.next()?

View File

@ -1,3 +1,14 @@
fn main() {
// TODO
use std::{
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(())
}