Skip to content

Commit

Permalink
handle null captures
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Jun 17, 2024
1 parent b223077 commit 8244fa0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions controllers/llguidance_ctrl/src/earley/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,11 +1055,18 @@ impl Parser {
if sym_data.is_nullable {
self.scratch
.add_unique(item.advance_dot(), item_idx, "null");
if self.scratch.definitive && sym_data.props.capture_name.is_some() {
// nullable capture
let var_name = sym_data.props.capture_name.as_ref().unwrap();
debug!(" capture: {} NULL", var_name);
self.captures.push((var_name.clone(), vec![]));
}
}
for rule in &sym_data.rules {
let new_item = Item::new(*rule, curr_idx);
self.scratch.add_unique(new_item, item_idx, "predict");
}
// TODO the hidden stuff is no longer used
if self.scratch.definitive && sym_data.props.hidden {
for rule in &sym_data.rules {
let new_item = Item::new(*rule, curr_idx);
Expand Down

0 comments on commit 8244fa0

Please sign in to comment.