- Rust 99.1%
- Nix 0.9%
| crates | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE-APACHE | ||
| LICENSE-MIT | ||
| README.md | ||
lojban-rs
A Rust library suite for Lojban, the logical language. It covers morphology, word lists, zbalermorna conversion, and the CLL machine grammar.
This vendored copy is used in a std LSP environment.
Crates
lojban-rs: facade crate.lojban-core: shared letters, selma'o, word classes, spans, diagnostics, and token IDs.lojban-morphology: word classification, tokenization, source token tables, and lujvo decomposition.lojban-words: embedded dictionary, rafsi, definitions, glosses, prefix search, and normalized lookup.lojban-zbalermorna: Latin/zbalermorna conversion with mapped spans.lojban-grammar: CLL chapter 21 parser, magic-word preprocessing, parser diagnostics, and recovered CST output.
Example
use lojban_rs::grammar::{parse, Rule};
use lojban_rs::morphology::{classify, WordClass};
use lojban_rs::zbalermorna::to_zbalermorna;
let tree = parse("mi klama le zarci")?;
let selbri = tree.find(Rule::Selbri).unwrap();
assert_eq!(selbri.words().next().unwrap().text, "klama");
assert_eq!(classify("lobypli"), Ok(WordClass::Lujvo));
let script = to_zbalermorna("coi rodo")?;
# Ok::<(), Box<dyn std::error::Error>>(())
Try the tree printer:
$ cargo run -p lojban-rs --example parse -- "mi klama le zarci"
Parse failures render as source-annotated reports via ariadne.
Sources and fidelity
The language data comes from two sources:
- The Complete Lojban Language, 1.1 - the EBNF grammar of chapter 21, the morphology rules of chapters 3-4, and the dictionary shipped with the book's sources.
- The zbalermorna repository - codepoint assignments are recorded from the fonts themselves, which are the ground truth for the script.
The language data lives in each crate's data/ directory as checked-in TSV
files, so builds do not need local source checkouts or extraction scripts.
The grammar follows the book's LALR-oriented EBNF. PEG-specific adaptations are
documented in lojban-grammar/src/parser.rs. This is not the community camxes
PEG grammar.
Minimum supported Rust version
1.81.
License
The code is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
The embedded language data (data/*.tsv in the crates) is derived from
The Complete Lojban Language, (c) the Logical Language Group, licensed
CC-BY-SA 4.0. The
zbalermorna sources are public domain.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.