diff options
author | Ben Bridle <bridle.benjamin@gmail.com> | 2023-05-08 12:05:57 +1200 |
---|---|---|
committer | Ben Bridle <bridle.benjamin@gmail.com> | 2023-05-08 12:05:57 +1200 |
commit | afa81e9ae6a56efe2eae2990e09c672b74328715 (patch) | |
tree | e13ceca3104a8f4bded3668f8efd743bcfbe4e35 /src/tokenizer.rs | |
parent | e38f108921c61e1e66d65a368f2a67a763d61e69 (diff) | |
download | bedrock-asm-afa81e9ae6a56efe2eae2990e09c672b74328715.zip |
Added detection of cyclic macro references, and made assembler binary usable
Diffstat (limited to 'src/tokenizer.rs')
-rw-r--r-- | src/tokenizer.rs | 12 |
1 files changed, 6 insertions, 6 deletions
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()) } } |