Skip to main content

Crate quarb_code

Crate quarb_code 

Source
Expand description

The code level for the Quarb query engine.

Cross-language code navigation above the syntax level (quarb-tree-sitter): function names are node names, not properties. /lexer/lex/is_name_char descends module, function, nested function — a filepath into the program — where the syntax level spells the same question //function_item[::name = "lex"].

  • Names. A declaration’s edge name is its declared identifier; every other construct in the vocabulary is named by its normalized keyword (if, switch, for, call); everything else dissolves — children hoist, as the text level dissolves markup soup. A nameless function-valued expression adopts the identifier of the binding receiving it (const lex = () => {} is a function named lex).
  • Traits classify: <function>, <type>, <module>, <loop>, <conditional>, <call>, <import>.
  • Properties are uniform: ::signature (the declaration head), ::doc (attached documentation), ::callee (on calls); bare :: is the node’s source text.
  • Annotations: ::::kind (the raw backend kind — the only place tree-sitter vocabulary survives), ::::construct, ::::start-line / ::::end-line, ::::lang, ::::n-children, ::::n-params — every one aliased to :: (the surface is closed; ruling #29).
  • Crosslinks: every call carries ->definition edges to the same-file declarations matching its callee; //lex<-definition is find-references.

The vocabulary and the per-grammar lowering tables are ruled in the spec (The Code Level, ruling #31) and doubled as conformance fixtures in this crate’s tests. Grammars: Rust, Python, JavaScript, C — the syntax level’s set, each nailed.

Structs§

CodeModel
A source file read at the code level.
Decl
One lowered construct — the code level’s producer seam, the parallel of quarb_text::Block. A producer emits Decls in pre-order (a parent precedes its children); CodeModel::build derives the arbor. The tree-sitter producer lives in this crate; another backend supplies the same stream and nothing above it moves.

Enums§

CodeError
An error reading a source file at the code level.
Lang
A grammar of the code level’s set.

Functions§

lang_for_ext
The grammar for a file extension (lowercased).
supported
Whether an extension has a code-level lowering (for dispatch and grafting). Agrees with quarb_tree_sitter::supported.