MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / parse_multiplicative

Method parse_multiplicative

crates/hll-to-ir/src/parser.rs:887–938  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

885 } else {
886 ops.push(AsmOp::Raw(line.clone()));
887 }
888 }
889 ("la", [reg, operand]) if operand.starts_with('$') => {
890 let Some(place) = Self::parse_asm_place(operand) else {
891 return Err(self.error("invalid inline-asm `$place` operand"));
892 };
893 ops.push(AsmOp::Addr {
894 reg: (*reg).to_owned(),
895 place,
896 });
897 }
898 _ => ops.push(AsmOp::Raw(line)),
899 }
900 }
901 Ok(ops)
902 }
903
904 fn parse_asm_place(operand: &str) -> Option<crate::ast::AsmPlace> {
905 let path = operand.strip_prefix('$')?;
906 let mut segments = path.split('.');
907 let base = segments.next()?;
908 if !Self::valid_asm_place_segment(base) {
909 return None;
910 }
911 let fields = segments.map(str::to_owned).collect::<Vec<_>>();
912 if fields
913 .iter()
914 .any(|field| !Self::valid_asm_place_segment(field))
915 {
916 return None;
917 }
918 Some(crate::ast::AsmPlace {
919 base: base.to_owned(),
920 fields,
921 })
922 }
923
924 fn valid_asm_place_segment(segment: &str) -> bool {
925 let mut chars = segment.chars();
926 chars
927 .next()
928 .is_some_and(|ch| ch == '_' || ch.is_ascii_alphabetic())
929 && chars.all(|ch| ch == '_' || ch.is_ascii_alphanumeric())
930 }
931
932 fn parse_assignment(&mut self) -> Result<Expression, ParserError> {
933 if matches!(self.peek(), Some(Token::LBrace)) {
934 let saved_pos = self.pos;
935 let mut trial = self.clone();
936
937 if let Ok(target) = trial.parse_struct_destructure_target()
938 && trial.match_assign()
939 {
940 *self = trial;
941 let rvalue = self.parse_assignment()?;

Callers 1

parse_additiveMethod · 0.80

Calls 12

parse_prefixMethod · 0.80
consume_terminatorsMethod · 0.80
peekMethod · 0.80
peek_nMethod · 0.80
parse_postfixMethod · 0.80
match_starMethod · 0.80
match_slashMethod · 0.80
match_percentMethod · 0.80
advanceMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected