Skip to main content

Crate nibli_kr

Crate nibli_kr 

Source
Expand description

nibli KR (nibli KR) — the surface-syntax front-end for nibli.

nibli KR is a predicate-call language (goes(me, some market).) that compiles to the same nibli_types::ast::AstBuffer the Lojban parser produces, reusing nibli-semantics/nibli-reason and every soundness gate unchanged. The language is specified in repo-root NIBLI_KR.md; the implementation program is tracked in repo-root TODO.md.

PARSER TECHNOLOGY (user decision, 2026-07-12): pest. src/nibli_kr.pest is the EXECUTABLE grammar — the normative form of NIBLI_KR §15 — so the grammar and the parser cannot drift by construction.

Pipeline: parser (pest walker → tree ast, §6/§7 errata as targeted errors) → emit — THE single validating walk (single-resolution merge, 2026-07-17): every dictionary-driven fail-closed check (name resolution → COMPILE ERROR on unknown words, place checks, linked-args rules, it/slot position rules, Name↔pronoun collisions) runs at the site that lowers the construct into the AstBuffer ($vars preserved verbatim, corpus entries to their canonical base with Converted swaps). resolve is the lookup module both emit and lint share. parse_checked is the engine’s fail-closed text→AST seam.

Modules§

ast
nibli KR tree AST — the parser’s output, lowered to nibli_types::ast::AstBuffer by the emitter (emit.rs).
complete
Shared nibli KR autocomplete — one engine for console and UI.
emit
The nibli KR emitter: tree AST → nibli_types::ast::AstBuffer — the sole producer of the flat buffer nibli_semantics::compile_from_ast (and everything below it: nibli-reason, the oracles, the Lean-bridged conformance surface) consumes. Flattener discipline: child indices come from push-return values, never from length arithmetic.
highlight
Lightweight nibli KR lexer for syntax highlighting.
lint
The nibli KR lint catalog (NIBLI_KR §12 + the 2026-07-12 review’s L8/L9) — NON-BLOCKING compile notes. “The linter is part of the design, not an afterthought”: the grammar is deterministic, but a handful of hazards are semantic, and each lint makes one of them visible instead of silent.
parser
nibli KR parser: pest-generated from src/nibli_kr.pest (THE executable grammar — NIBLI_KR §15, full v0.1 surface), plus the walker that builds the tree AST (crate::ast) and enforces the §6/§7 errata as targeted, positioned errors.
render
The nibli KR renderer: nibli_types::ast::AstBuffer → nibli KR text — the inverse of crate::emit, and PARITY LAYER 1 of the 100%-sync guarantee: every match in this module is wildcard-free over the nibli_types::ast enums (see [__ast_parity_guard]), so ADDING AN AST VARIANT BREAKS THIS CRATE’S BUILD until nibli KR decides how to spell it (or rejects it by name).
resolve
The nibli KR lookup module — the single vocabulary seam between the surface syntax and the committed English corpus (nibli-lexicon).

Constants§

GRAMMAR
The pest PEG grammar source — the normative form of NIBLI_KR §15, embedded so downstream tooling (e.g. the nibli-formalize LLM prompt) can ground on the EXACT accepted syntax, in-sync BY CONSTRUCTION: this is the same file the #[grammar = "nibli_kr.pest"] derive consumes, so it can never drift from the parser.

Functions§

parse_checked
FAIL CLOSED: parse + the validating emit walk, or the first (source-order) error. Feed the result to nibli_semantics::compile_from_ast.
parse_text
Per-statement recovery variant (the ParseResult contract): every statement that parses AND emits lands in the buffer (a failing statement’s partial nodes roll back); every failure is reported, first error per statement. errors non-empty ⇒ the buffer is PARTIAL — callers wanting fail-closed behavior use parse_checked.