Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
fix: merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Apr 21, 2024
1 parent 16dacc4 commit 273dbed
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
42 changes: 26 additions & 16 deletions huff_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Parser {
)),
spans: AstSpan(self.spans.clone()),
cursor: self.cursor,
})
});
}
}

Expand All @@ -161,7 +161,7 @@ impl Parser {
hint: Some(format!("Expected import string. Got: \"{tok}\"")),
spans: AstSpan(new_spans),
cursor: self.cursor,
})
});
}
};

Expand Down Expand Up @@ -202,6 +202,7 @@ impl Parser {
kind: ParserErrorKind::DuplicateMacro(m.name.to_owned()),
hint: Some("MACRO names should be unique".to_string()),
spans: AstSpan(vec![m.span[2].clone()]),
cursor: self.cursor,
})
} else {
Ok(())
Expand Down Expand Up @@ -262,7 +263,7 @@ impl Parser {
hint: Some(format!("Expected function name, found: \"{tok}\"")),
spans: AstSpan(self.spans.clone()),
cursor: self.cursor,
})
});
}
};

Expand Down Expand Up @@ -326,7 +327,7 @@ impl Parser {
hint: Some(format!("Expected event name, found: \"{tok}\"")),
spans: AstSpan(self.spans.clone()),
cursor: self.cursor,
})
});
}
};

Expand Down Expand Up @@ -358,7 +359,7 @@ impl Parser {
hint: Some("Expected constant name.".to_string()),
spans: AstSpan(self.spans.clone()),
cursor: self.cursor,
})
});
}
};

Expand All @@ -384,8 +385,11 @@ impl Parser {
),
spans: AstSpan(vec![self.current_token.span.clone()]),
cursor: self.cursor,
})
});
}
};

// Clone spans and set to nothing
let new_spans = self.spans.clone();
self.spans = vec![];

Expand All @@ -410,7 +414,7 @@ impl Parser {
hint: Some("Expected error name.".to_string()),
spans: AstSpan(self.spans.clone()),
cursor: self.cursor,
})
});
}
};

Expand Down Expand Up @@ -458,7 +462,7 @@ impl Parser {
hint: Some(format!("Expected string for decorator flag: {s}")),
spans: AstSpan(vec![self.current_token.span.clone()]),
cursor: self.cursor,
})
});
}
}
// The value flag accepts a single literal as an argument
Expand All @@ -475,7 +479,7 @@ impl Parser {
hint: Some(format!("Expected literal for decorator flag: {s}")),
spans: AstSpan(vec![self.current_token.span.clone()]),
cursor: self.cursor,
})
});
}
}
Err(_) => {
Expand All @@ -485,8 +489,11 @@ impl Parser {
hint: Some(format!("Unknown decorator flag: {s}")),
spans: AstSpan(self.spans.clone()),
cursor: self.cursor,
})
});
}
}

// Consume the closing parenthesis
self.match_kind(TokenKind::CloseParen)?;

// Multiple flags are possible
Expand All @@ -501,7 +508,7 @@ impl Parser {
hint: Some(String::from("Unknown decorator flag")),
spans: AstSpan(self.spans.clone()),
cursor: self.cursor,
})
});
}
}

Expand Down Expand Up @@ -715,7 +722,7 @@ impl Parser {
hint: None,
spans: AstSpan(vec![self.current_token.span.clone()]),
cursor: self.cursor,
})
});
}
};
}
Expand Down Expand Up @@ -829,7 +836,7 @@ impl Parser {
hint: None,
spans: AstSpan(vec![self.current_token.span.clone()]),
cursor: self.cursor,
})
});
}
};
}
Expand Down Expand Up @@ -961,7 +968,7 @@ impl Parser {
)),
spans: AstSpan(vec![self.current_token.span.clone()]),
cursor: self.cursor,
})
});
}
}
TokenKind::PrimitiveType(ty) => {
Expand Down Expand Up @@ -996,7 +1003,7 @@ impl Parser {
hint: None,
spans: AstSpan(vec![self.current_token.span.clone()]),
cursor: self.cursor,
})
});
}

arg.span = AstSpan(arg_spans);
Expand Down Expand Up @@ -1076,7 +1083,7 @@ impl Parser {
),
spans: AstSpan(new_spans),
cursor: self.cursor,
})
});
}
}
if self.check(TokenKind::Comma) {
Expand Down Expand Up @@ -1303,6 +1310,9 @@ impl Parser {
cursor: self.cursor,
})
}
Ok(self.match_kind(self.current_token.kind.clone())?)
}
PrimitiveEVMType::Bool => Ok(self.match_kind(self.current_token.kind.clone())?),
PrimitiveEVMType::Address => Ok(self.match_kind(self.current_token.kind.clone())?),
PrimitiveEVMType::String => Ok(self.match_kind(self.current_token.kind.clone())?),
PrimitiveEVMType::DynBytes => Ok(self.match_kind(self.current_token.kind.clone())?),
Expand Down
1 change: 1 addition & 0 deletions huff_parser/tests/macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,7 @@ fn test_duplicate_macro_error() {
end: occurrences[1].1,
file: None
}]),
cursor: 58,
}
)
}
Expand Down

0 comments on commit 273dbed

Please sign in to comment.