Allow using constants in data.8 and data.16

This commit is contained in:
Ry 2022-10-12 13:32:14 -07:00
parent 7d1f636239
commit cc4242b1fe

View File

@ -598,26 +598,18 @@ fn parse_data(pair: pest::iterators::Pair<Rule>) -> AstNode {
//println!("{:#?}", pair); //println!("{:#?}", pair);
match pair.as_rule() { match pair.as_rule() {
Rule::data_byte => { Rule::data_byte => {
let ast = parse_operand(pair.into_inner().next().unwrap(), false); match parse_operand(pair.into_inner().next().unwrap(), false) {
let byte = { AstNode::Immediate32(half) => AstNode::DataByte(half as u8),
if let AstNode::Immediate32(word) = ast { AstNode::LabelOperand {name, size, is_relative} => AstNode::LabelOperand {name, size, is_relative},
word as u8 _ => unreachable!(),
} else { }
unreachable!()
}
};
AstNode::DataByte(byte)
}, },
Rule::data_half => { Rule::data_half => {
let ast = parse_operand(pair.into_inner().next().unwrap(), false); match parse_operand(pair.into_inner().next().unwrap(), false) {
let word = { AstNode::Immediate32(half) => AstNode::DataHalf(half as u16),
if let AstNode::Immediate32(word) = ast { AstNode::LabelOperand {name, size, is_relative} => AstNode::LabelOperand {name, size, is_relative},
word as u16 _ => unreachable!(),
} else { }
unreachable!()
}
};
AstNode::DataHalf(word)
}, },
Rule::data_word => { Rule::data_word => {
match parse_operand(pair.into_inner().next().unwrap(), false) { match parse_operand(pair.into_inner().next().unwrap(), false) {