(&mut self)
| 837 | }) |
| 838 | } |
| 839 | |
| 840 | // Strip the wrapper carried by opening and one-line asm source lines. |
| 841 | fn normalize_asm_line(line: &str) -> String { |
| 842 | let mut s = line; |
| 843 | if let Some(idx) = s.find('{') { |
| 844 | s = &s[idx + 1..]; |
| 845 | } |
| 846 | if let Some(idx) = s.rfind('}') { |
| 847 | s = &s[..idx]; |
| 848 | } |
| 849 | s.trim().to_owned() |
| 850 | } |
| 851 | |
| 852 | // Parse the three typed bridge forms; keep every other line raw. |
| 853 | fn parse_asm_ops(&mut self, lines: Vec<String>) -> Result<Vec<crate::ast::AsmOp>, ParserError> { |
| 854 | use crate::ast::AsmOp; |
| 855 | let mut ops = Vec::with_capacity(lines.len()); |
| 856 | for line in lines { |
| 857 | let code = line |
| 858 | .split_once(';') |
| 859 | .map_or(line.as_str(), |(code, _)| code) |
| 860 | .trim(); |
| 861 | let (opcode, operands) = code |
| 862 | .split_once(char::is_whitespace) |
| 863 | .map_or((code, ""), |(opcode, operands)| (opcode, operands.trim())); |
| 864 | let operands = operands.split(',').map(str::trim).collect::<Vec<_>>(); |
no test coverage detected