forked from AbleOS/holey-bytes
replaced in main
This commit is contained in:
parent
b0b4022a85
commit
cf05464c14
|
@ -1,3 +1,5 @@
|
||||||
|
use hbasm::Assembler;
|
||||||
|
|
||||||
use {
|
use {
|
||||||
ariadne::{ColorGenerator, Label, Report, ReportKind, Source},
|
ariadne::{ColorGenerator, Label, Report, ReportKind, Source},
|
||||||
std::{
|
std::{
|
||||||
|
@ -10,22 +12,21 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
let mut code = String::new();
|
let mut code = String::new();
|
||||||
stdin().read_to_string(&mut code)?;
|
stdin().read_to_string(&mut code)?;
|
||||||
|
|
||||||
let mut buf = vec![];
|
let mut assembler = Assembler::default();
|
||||||
|
if let Err(e) = hbasm::text::assemble(&mut assembler, &code) {
|
||||||
if let Err(e) = hbasm::text_r::assembly(&code, &mut buf) {
|
|
||||||
let mut colors = ColorGenerator::new();
|
let mut colors = ColorGenerator::new();
|
||||||
|
|
||||||
let e_code = match e.kind {
|
let e_code = match e.kind {
|
||||||
hbasm::text_r::ErrorKind::UnexpectedToken => 1,
|
hbasm::text::ErrorKind::UnexpectedToken => 1,
|
||||||
hbasm::text_r::ErrorKind::InvalidToken => 2,
|
hbasm::text::ErrorKind::InvalidToken => 2,
|
||||||
hbasm::text_r::ErrorKind::UnexpectedEnd => 3,
|
hbasm::text::ErrorKind::UnexpectedEnd => 3,
|
||||||
hbasm::text_r::ErrorKind::InvalidSymbol => 4,
|
hbasm::text::ErrorKind::InvalidSymbol => 4,
|
||||||
};
|
};
|
||||||
let message = match e.kind {
|
let message = match e.kind {
|
||||||
hbasm::text_r::ErrorKind::UnexpectedToken => "This token is not expected!",
|
hbasm::text::ErrorKind::UnexpectedToken => "This token is not expected!",
|
||||||
hbasm::text_r::ErrorKind::InvalidToken => "The token is not valid!",
|
hbasm::text::ErrorKind::InvalidToken => "The token is not valid!",
|
||||||
hbasm::text_r::ErrorKind::UnexpectedEnd => "The assembler reached the end of input unexpectedly!",
|
hbasm::text::ErrorKind::UnexpectedEnd => "The assembler reached the end of input unexpectedly!",
|
||||||
hbasm::text_r::ErrorKind::InvalidSymbol => "This referenced symbol doesn't have a corresponding label!",
|
hbasm::text::ErrorKind::InvalidSymbol => "This referenced symbol doesn't have a corresponding label!",
|
||||||
};
|
};
|
||||||
let a = colors.next();
|
let a = colors.next();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue