pub struct ParserGuard<'p, 'a, 'ctx, 'int> { /* private fields */ }Expand description
RAII guard for speculative parsing with automatic rollback.
Created by Parser::guard(), this guard saves the parser state
on creation and automatically restores it if the guard is dropped
without being committed.
§Usage
let guard = parser.guard();
if let Ok(result) = try_parse(&mut *guard) {
guard.commit(); // Success - keep changes
return Ok(result);
}
// guard dropped here - parser state restoredImplementations§
Source§impl<'p, 'a, 'ctx, 'int> ParserGuard<'p, 'a, 'ctx, 'int>
impl<'p, 'a, 'ctx, 'int> ParserGuard<'p, 'a, 'ctx, 'int>
Methods from Deref<Target = Parser<'a, 'ctx, 'int>>§
pub fn set_discourse_event_var(&mut self, var: Symbol)
Sourcepub fn drs_mut(&mut self) -> &mut Drs
pub fn drs_mut(&mut self) -> &mut Drs
Get mutable reference to the active DRS (from WorldState).
Sourcepub fn swap_drs_with_world_state(&mut self)
pub fn swap_drs_with_world_state(&mut self)
Swap DRS between Parser and WorldState. Call at start of parsing to get the accumulated DRS from WorldState. Call at end of parsing to save the updated DRS back to WorldState.
Sourcepub fn has_world_state(&self) -> bool
pub fn has_world_state(&self) -> bool
WorldState is always present (no “single sentence mode”)
pub fn mode(&self) -> ParserMode
Sourcepub fn is_known_type(&self, sym: Symbol) -> bool
pub fn is_known_type(&self, sym: Symbol) -> bool
Check if a symbol is a known type in the registry. Used to disambiguate “Stack of Integers” (generic type) vs “Owner of House” (possessive).
Sourcepub fn is_generic_type(&self, sym: Symbol) -> bool
pub fn is_generic_type(&self, sym: Symbol) -> bool
Check if a symbol is a known generic type (takes type parameters). Used to parse “Stack of Integers” as generic instantiation.
pub fn process_block_headers(&mut self)
pub fn get_event_var(&mut self) -> Symbol
pub fn capture_event_template( &mut self, verb: Symbol, roles: &[(ThematicRole, Term<'a>)], modifiers: &[Symbol], )
pub fn set_pp_attachment_mode(&mut self, attach_to_noun: bool)
pub fn set_noun_priority_mode(&mut self, mode: bool)
pub fn set_collective_mode(&mut self, mode: bool)
pub fn set_event_reading_mode(&mut self, mode: bool)
pub fn set_negative_scope_mode(&mut self, mode: NegativeScopeMode)
pub fn set_modal_preference(&mut self, pref: ModalPreference)
pub fn guard(&mut self) -> ParserGuard<'_, 'a, 'ctx, 'int>
Sourcepub fn parse(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>
pub fn parse(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>
Parses the token stream into a logical expression.
This is the main entry point for declarative/FOL parsing. It handles multi-sentence inputs by conjoining them with logical AND, and processes various sentence types including declaratives, questions, and imperatives.
§Returns
An arena-allocated LogicExpr representing the parsed input, or
a ParseError with source location and Socratic explanation.
§Discourse State
The parser maintains discourse state across sentences, enabling anaphora resolution (“he”, “she”, “they” refer to prior entities) and temporal coherence (tense interpretation relative to reference time).
Sourcepub fn parse_program(&mut self) -> Result<Vec<Stmt<'a>>, ParseError>
pub fn parse_program(&mut self) -> Result<Vec<Stmt<'a>>, ParseError>
Parses a LOGOS program into a list of statements.
This is the main entry point for imperative/executable LOGOS code. It handles block structures (Definition, Policy, Procedure, Theorem), function definitions, type definitions, and executable statements.
§Returns
A vector of arena-allocated Stmt representing the program, or
a ParseError with source location and Socratic explanation.
§Block Types
- Definition: Type definitions (structs, enums, generics)
- Policy: Security predicates and capability rules
- Procedure: Executable code blocks
- Theorem: Logical propositions with proof strategies