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

Function push_directive

crates/asm-to-binary/src/assembler/parser.rs:128–144  ·  view source on GitHub ↗
(dir: Directive, out: &mut Vec<AsmToken>)

Source from the content-addressed store, hash-verified

126fn is_string_directive(raw: &str) -> bool {
127 let head = raw.trim_start();
128 [".asciz ", ".string ", ".asciz\t", ".string\t"]
129 .iter()
130 .any(|d| head.starts_with(d))
131}
132
133fn parse_directive_or_instruction(
134 raw: &str,
135 constants: &HashMap<String, i64>,
136 out: &mut Vec<AsmToken>,
137) -> Result<(), String> {
138 // Strip trailing inline `;` or `#` comments before any classification.
139 // String directives keep theirs: the directive parser stops at the quote.
140 let raw = if is_string_directive(raw) {
141 raw
142 } else {
143 match raw.find([';', '#']) {
144 Some(i) => raw[..i].trim_end(),
145 None => raw,
146 }
147 };

Callers 1

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected