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.
|
|
|
|
|
|
|
use crsn::asm::error::CrsnError;
|
|
|
|
use crsn::asm::instr::Op;
|
|
|
|
use crsn::asm::parse::arg_parser::ArgParser;
|
|
|
|
use crsn::module::{ParseOpRes};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use crate::defs::StackOp;
|
|
|
|
|
|
|
|
pub(crate) fn parse(keyword: &str, mut args: ArgParser) -> Result<ParseOpRes<Op>, CrsnError> {
|
|
|
|
Ok(ParseOpRes::ext(match keyword {
|
|
|
|
"stack" => {
|
|
|
|
StackOp::NewStack {
|
|
|
|
dst: args.next_wr()?,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"push" => {
|
|
|
|
StackOp::Push {
|
|
|
|
obj: args.next_rdobj()?,
|
|
|
|
src: args.next_rd()?,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"pop" => {
|
|
|
|
StackOp::Pop {
|
|
|
|
dst: args.next_wr()?,
|
|
|
|
obj: args.next_rdobj()?,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_other => {
|
|
|
|
return Ok(ParseOpRes::Unknown(args));
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
}
|