Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
Separate macro replacement from macro parsing
Browse files Browse the repository at this point in the history
- Return Vec of replaced tokens
- Add Peekable trait to allow using any `std::iter::Peekable` iterator
- Split up file handling and preprocessing
- Make `impl Debug for InternedStr` actually useful

I was staring at a lot of debugged identifiers while working on this;
I figured they should at least be useful.

- Only perform replacement _after_ processing `defined`
- Document edge cases
- Export `replace`
- Add doc-comments about architecture
  • Loading branch information
jyn514 committed May 20, 2020
1 parent 24eaa84 commit 356fc1f
Show file tree
Hide file tree
Showing 6 changed files with 734 additions and 326 deletions.
8 changes: 7 additions & 1 deletion src/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ use std::sync::RwLock;
use lasso::{Rodeo, Spur};
use lazy_static::lazy_static;

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct InternedStr(pub Spur);

impl fmt::Debug for InternedStr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self)
}
}

lazy_static! {
pub static ref STRINGS: RwLock<Rodeo<Spur>> = RwLock::new(Rodeo::default());
static ref EMPTY_STRING: InternedStr = InternedStr::get_or_intern("");
Expand Down
Loading

0 comments on commit 356fc1f

Please sign in to comment.