Module parser

Module parser 

Source
Expand description

Recursive descent parser for natural language to first-order logic.

This module implements a hand-written recursive descent parser that transforms natural language sentences into logical expressions. The parser operates in two modes: Declarative for natural language propositions (Logicaffeine mode) and Imperative for strict, deterministic scoping (LOGOS mode).

§Architecture

The parser is split into specialized submodules:

ModuleResponsibility
clauseSentence-level parsing: conditionals, conjunctions, relative clauses
nounNoun phrase parsing with determiners, adjectives, possessives
verbVerb phrase parsing, event semantics, thematic roles
modalModal verbs (can, must, might) with Kripke semantics
quantifierQuantifier scope: every, some, no, most
questionWh-movement and question formation
pragmaticsPragmatic inference during parsing
commonShared utilities (copula lists, etc.)

§Key Types

  • Parser: The main parser struct holding tokens, state, and arenas
  • ParserMode: Declarative (NL) vs Imperative (LOGOS) mode
  • ParserGuard: RAII guard for speculative parsing with automatic rollback
  • NegativeScopeMode: Wide vs narrow scope for lexically negative verbs
  • ModalPreference: Default, epistemic, or deontic readings for modals

§Example

use logicaffeine_language::parser::{Parser, ParserMode};

// Lexer produces tokens, then parser produces LogicExpr
let expr = parser.parse_sentence()?;

Structs§

EventTemplate
Template for constructing Neo-Davidsonian events.
Parser
Recursive descent parser for natural language to first-order logic.
ParserGuard
RAII guard for speculative parsing with automatic rollback.

Enums§

ModalPreference
Controls interpretation of polysemous modals (may, can, could). Used by compile_forest to generate multiple semantic readings.
NegativeScopeMode
Controls scope of negation for lexically negative verbs (lacks, miss). “user who lacks a key” can mean:
ParserMode
Determines how the parser interprets sentences.
ResolvedPronoun
Result of pronoun resolution during parsing.

Traits§

ClauseParsing
Trait for parsing clause-level structures.
ImperativeVerbParsing
Trait for parsing verb phrases in imperative (LOGOS) mode.
LogicVerbParsing
Trait for parsing verb phrases in declarative (logic) mode.
ModalParsing
Trait for parsing modal verbs and aspect chains.
NounParsing
Trait for parsing noun phrases.
PragmaticsParsing
Trait for parsing pragmatic and focus-sensitive constructions.
QuantifierParsing
Trait for parsing quantified expressions and managing scope.
QuestionParsing
Trait for parsing interrogative sentences.