forked from MightyPork/crsn
generalize parsing to allow extensions to add arbitrary syntax; add 'proc' keyword to introduce a routine.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crsn::asm::error::CrsnError;
|
||||
use crsn::asm::instr::Op;
|
||||
use crsn::asm::parse::arg_parser::ArgParser;
|
||||
use crsn::module::{CrsnExtension, ParseOpRes};
|
||||
use crsn::asm::parse::arg_parser::TokenParser;
|
||||
use crsn::module::{CrsnExtension, ParseRes};
|
||||
|
||||
mod defs;
|
||||
mod parse;
|
||||
@@ -21,7 +21,7 @@ impl CrsnExtension for ArithOps {
|
||||
"arith"
|
||||
}
|
||||
|
||||
fn parse_op(&self, keyword: &str, args: ArgParser) -> Result<ParseOpRes<Op>, CrsnError> {
|
||||
fn parse_op(&self, keyword: &str, args: TokenParser) -> Result<ParseRes<Op>, CrsnError> {
|
||||
parse::parse(keyword, args)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use crsn::asm::data::{Rd, Wr};
|
||||
use crsn::asm::error::CrsnError;
|
||||
use crsn::asm::instr::Op;
|
||||
use crsn::asm::parse::arg_parser::ArgParser;
|
||||
use crsn::module::ParseOpRes;
|
||||
use crsn::asm::parse::arg_parser::TokenParser;
|
||||
use crsn::module::ParseRes;
|
||||
|
||||
use crate::defs::ArithOp;
|
||||
|
||||
pub(crate) fn parse(keyword: &str, mut args: ArgParser) -> Result<ParseOpRes<Op>, CrsnError> {
|
||||
Ok(ParseOpRes::ext(match keyword {
|
||||
pub(crate) fn parse(keyword: &str, mut args: TokenParser) -> Result<ParseRes<Op>, CrsnError> {
|
||||
Ok(ParseRes::ext(match keyword {
|
||||
"cmp" => {
|
||||
ArithOp::Compare {
|
||||
a: args.next_rd()?,
|
||||
@@ -430,7 +430,7 @@ pub(crate) fn parse(keyword: &str, mut args: ArgParser) -> Result<ParseOpRes<Op>
|
||||
}
|
||||
|
||||
_other => {
|
||||
return Ok(ParseOpRes::Unknown(args));
|
||||
return Ok(ParseRes::Unknown(args));
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user