Croissant Runtime
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
crsn/crsn_screen/src/parse.rs

48 lines
1.1 KiB

use crsn::asm::data::Rd;
use crsn::asm::error::CrsnError;
use crsn::asm::instr::Op;
use crsn::asm::parse::arg_parser::TokenParser;
use crsn::module::ParseRes;
use crate::defs::ScreenOp;
pub(crate) fn parse(keyword: &str, mut args: TokenParser) -> Result<ParseRes<Op>, CrsnError> {
Ok(ParseRes::ext(match keyword {
"sc-init" => {
ScreenOp::ScreenInit {
width: args.next_rd()?,
height: args.next_rd()?,
}
}
"sc-px" => {
ScreenOp::SetPixel {
x: args.next_rd()?,
y: args.next_rd()?,
color: args.next_rd()?,
}
}
"sc-opt" => {
ScreenOp::SetOpt {
opt: args.next_rd()?,
val: args.next_rd()?,
}
}
"sc-blit" => {
ScreenOp::Blit {
force: if args.have_more() {
args.next_rd()?
} else {
Rd::immediate(1)
},
}
}
_other => {
return Ok(ParseRes::Unknown(args));
}
}))
}