summaryrefslogtreecommitdiff
path: root/src/stages/syntactic.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/stages/syntactic.rs')
-rw-r--r--src/stages/syntactic.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/stages/syntactic.rs b/src/stages/syntactic.rs
index a65faf9..9635c83 100644
--- a/src/stages/syntactic.rs
+++ b/src/stages/syntactic.rs
@@ -250,17 +250,17 @@ fn parse_word_template(mut t: Tokeniser) -> Result<WordTemplate, Vec<Tracked<Syn
let mut value_width = 0; // Bit width of the whole word template.
let mut field_width = 0; // Width of the current bit field.
let mut field_name = '\0'; // Name of the current bit field.
- let mut fields: Vec<Tracked<BitField>> = Vec::new();
+ let mut fields: Vec<BitField> = Vec::new();
let mut errors: Vec<Tracked<SyntacticError>> = Vec::new();
macro_rules! push_field {
() => {
- if fields.iter().any(|f| f.name == field_name) {
- let error = SyntacticError::DuplicateFieldNameInWord(field_name);
- errors.push(Tracked::from(error, t.get_source()));
+ let range = BitRange { width: field_width, shift: 0 };
+ let tracked = Tracked::from(range, t.get_source());
+ if let Some(field) = fields.iter_mut().find(|f| f.name == field_name) {
+ field.ranges.push(tracked);
} else {
- let field = BitField { name: field_name, width: field_width, shift: 0};
- fields.push(Tracked::from(field, t.get_source()));
+ fields.push(BitField { name: field_name, ranges: vec![tracked]});
}
};
}
@@ -276,7 +276,9 @@ fn parse_word_template(mut t: Tokeniser) -> Result<WordTemplate, Vec<Tracked<Syn
value <<= 1;
value_width += 1;
for field in &mut fields {
- field.shift += 1;
+ for range in &mut field.ranges {
+ range.shift += 1;
+ }
}
// Extend the current field.
@@ -316,7 +318,9 @@ fn parse_word_template(mut t: Tokeniser) -> Result<WordTemplate, Vec<Tracked<Syn
// Commit the final field.
for field in &mut fields {
- field.shift += 1;
+ for range in &mut field.ranges {
+ range.shift += 1;
+ }
}
if field_width > 0 {
t.mark_end();