1 home
liquibyte edited this page 2026-11-19 16:23:29 -06:00

Kami API reference

Kami is a C library that reads source code and says what it means. It has no display and no toolkit: it needs only libc. An editor, a command-line checker or a language server can use it. Unryu, the source code editor, is built on it.

The manual

The guides explain each part of Kami from a programmer's side: what it does, which calls to make, and what the results mean.

  • Overview - what Kami is, its layers, building and installing, and the rules every call follows
  • Language Files - the format of a language file and every key it can have
  • Grammars - the [grammar] section of a language file, and its layout keys
  • The Lexer and Highlighting - tokens, lexing any language, styles and folds
  • The Preprocessor - what the compiler sees: macros, #if, headers and where each token comes from
  • The Parser and the Semantic Model - declarations, scopes, how names and members are resolved
  • Braces - which brace goes with which, how sure that is, and why
  • The Brace Session - brace answers kept right while a text is edited, and the compiler check
  • An Example Program - a short, complete program that uses every layer

The API reference

Each header has a page below, made from the comments in Kami's headers (src/*.h): its types, constants and functions, with what each parameter and return value means.

Version 1.5.

The whole library

  • kami.h - Kami, What Source Code Means

Reading C and C++

  • lexer.h - The C and C++ Lexer (layer 0)
  • preprocessor.h - The C Preprocessor, with Every Token Mapped Back to the File
  • parser.h - The C Grammar Check, and the C++ Reader
  • semantic.h - What the Code Means: the Semantic Model

Braces

  • brace.h - Which Brace Goes with Which: Answers and Matchers
  • brace_session.h - A Text Being Edited, and Its Brace Answers (layer 3)

Any language

  • language.h - Languages Described in Files, and Their Highlighting