Skip to content

Commit

Permalink
Add comments to parser.rs (#15)
Browse files Browse the repository at this point in the history
Comment Scratch, ensure_items(), add_unique()
  • Loading branch information
v-jkegler authored Sep 20, 2024
1 parent e9bac67 commit e07510f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions parser/src/earley/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ impl Item {
}
}

// This structure implements the Earley table.
#[derive(Clone)]
struct Scratch {
grammar: Arc<CGrammar>,
Expand Down Expand Up @@ -256,6 +257,8 @@ impl Scratch {
}
}

// Make sure there is enough space in the Earley table,
// usually in preparation for adding Earley items.
#[inline(always)]
fn ensure_items(&mut self, n: usize) {
if self.items.len() < n {
Expand Down Expand Up @@ -320,6 +323,9 @@ impl Scratch {
);
}

// Ensure that Earley table 'self' contains
// Earley item 'item'. That is, look for 'item' in 'self',
// and add 'item' to 'self' if it is not there already.
#[inline(always)]
fn add_unique(&mut self, item: Item, origin_item_idx: usize, info: &str) {
if let Some(idx) = self.find_item(item) {
Expand Down

0 comments on commit e07510f

Please sign in to comment.