From afa81e9ae6a56efe2eae2990e09c672b74328715 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Mon, 8 May 2023 12:05:57 +1200 Subject: Added detection of cyclic macro references, and made assembler binary usable --- src/tokenizer.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/tokenizer.rs') diff --git a/src/tokenizer.rs b/src/tokenizer.rs index b68cc14..508daee 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -106,9 +106,9 @@ impl Iterator for TokenIterator { let full = take(&mut self.source); let suffix = take(&mut self.suffix); let mut error = None; - let mut parse_hex_lit = |v| { + let mut parse_padding_value = |v| { parse_short(v).or_else(|| { - error = Some(Error::InvalidHexadecimalLiteral); Some(0) + error = Some(Error::InvalidPaddingValue); Some(0) }).unwrap() }; @@ -116,13 +116,13 @@ impl Iterator for TokenIterator { '(' => { SyntacticTokenType::Comment } '@' => { SyntacticTokenType::LabelDefinition({self.label=suffix.clone(); suffix}) } '&' => { SyntacticTokenType::LabelDefinition(format!("{}/{}", self.label, suffix)) } - '$' => { SyntacticTokenType::Pad(parse_hex_lit(&suffix)) } + '$' => { SyntacticTokenType::Padding(parse_padding_value(&suffix)) } '~' => { SyntacticTokenType::Reference(format!("{}/{}", self.label, suffix)) } '%' => { SyntacticTokenType::MacroDefinition(suffix) } _ => { - if ";" == &full { SyntacticTokenType::MacroTerminator } - else if let Some(value) = parse_byte_lit(&full) { SyntacticTokenType::Byte(value) } - else if let Some(value) = parse_short_lit(&full) { SyntacticTokenType::Short(value) } + if ";" == &full { SyntacticTokenType::MacroDefinitionTerminator } + else if let Some(value) = parse_byte_lit(&full) { SyntacticTokenType::ByteLiteral(value) } + else if let Some(value) = parse_short_lit(&full) { SyntacticTokenType::ShortLiteral(value) } else if let Some(value) = parse_instruction(&full) { SyntacticTokenType::Instruction(value) } else { SyntacticTokenType::Reference(full.clone()) } } -- cgit v1.2.3-70-g09d2