Skip to main content

Crate doge_compiler

Crate doge_compiler 

Source

Structs§

BuiltinFn
One builtin: its name, the doge-runtime function a call emits, the argument counts it accepts, its emission shape, and the call-shape hint for arity diagnostics.
ClassInfo
One class already defined in a REPL session: its name, the parent it inherits from (if any), and its method names.
Completion
One completion candidate: the text to insert and what kind of thing it is (so the editor can show the right icon).
Dependency
One [dependencies] entry: a local alias bound by so <alias> and where its package lives.
Diagnostic
A single compile error. The front end stops at the first one (docs/ERRORS.md: “one issue at a time”), so a failed compile yields exactly one Diagnostic.
Manifest
A parsed doge.toml.
Module
One importable module: its name, its function members, and its constant members (each a name paired with the Rust expression codegen emits inline).
ModuleFn
One callable member of a module: its arity, the runtime function a call emits, and the call-shape hint shown in arity diagnostics. arity is the required positional-argument count; optional == true allows exactly one extra trailing argument, so the accepted range is arity..=arity + 1 (an omitted trailing argument reaches the runtime function as Value::None).
Param
One formal parameter in a function header: its name and, optionally, a default value. A default is a literal (docs/SYNTAX.md §6), so it references no names and is safe to evaluate fresh at every call site.
Params
A function header’s parameters: the fixed/defaulted positional parameters in order, plus an optional trailing variadic parameter (many rest) that collects the surplus arguments into a List. Required parameters come first, then defaulted ones, then the variadic — the parser enforces that order.
Program
ProgramFile
One source file in the program, with its parsed script and resolved imports.
Script
A whole parsed script: a sequence of top-level statements (the terminating wow is consumed by the parser and not stored).
SessionScope
The accumulated top-level scope of a REPL session: every name in scope, the subset that are constants, and the object definitions (for inheritance and super checks). A snippet is checked as if these were already declared, so it can reference — and redefine — anything earlier snippets introduced. Built by the interpreter from its live session state, so the checker and the runtime always agree on what exists.
Span
A 1-based source position pointing at the first character of a token.

Enums§

BinOp
Binary operators, in the spelling they print with in the dump.
BuiltinShape
How a builtin call is emitted and dispatched.
CompletionKind
The category of a Completion, mapped to an editor icon by the language server.
DependencySource
Where a dependency’s package comes from.
Expr
One expression.
GitRev
Which git revision a git dependency resolves to.
InterpPart
One piece of a string-interpolation expression ("a {b} c"): literal text or an embedded expression whose display form is spliced in at runtime.
ReplParse
The outcome of parsing an interactive REPL snippet.
Stmt
One statement. Variants mirror the docs/GRAMMAR.md grammar.
UnOp
Unary operators: not (logical) and neg (numeric minus).

Constants§

BUILTINS
MANIFEST_NAME
The manifest file name discovered at a project root.
MODULES
PACK_ZOOM_RUNTIME_FN
The runtime function pack.zoom maps to. Both engines special-case it: the compiler hands it the pup trampoline plus a globals snapshot, and the interpreter routes it to its own thread-spawning path instead of the generic native dispatch. Kept in step with the pack module’s zoom entry below.

Functions§

builtin
The builtin named name, if there is one.
celled_locals
The subset of a scope’s own bound names that must be shared cells: every nested-function name, plus any local or parameter a nested closure captures.
check
Run the semantic checks over an already-parsed Script.
check_program
Run the semantic checks over every file in a loaded Program.
check_snippet
Check a REPL snippet against a session’s accumulated scope. Identical to [check] but with session’s names pre-declared: top-level references to earlier snippets resolve, and a snippet may redefine a name an earlier one introduced (only the current snippet is checked for duplicate definitions). Constant reassignment and undeclared-name use stay errors.
child_funcdefs
The nested functions defined directly in this scope — crossing if/for/ while/pls blocks (names leak, Python-style) but never another function’s body. Returns each (name, params, body, span).
complete
The completion candidates offered at (line, col) — both 1-based, matching the compiler’s Span convention — in source (named path for lexing).
discover_root
The nearest ancestor of start (inclusive) that holds a doge.toml, or None when start is not inside any project.
dump
Render a script as an indented tree (two spaces per level). Stable and language-agnostic — this is what doge check prints on success.
format
Format source (named path for diagnostics) to canonical Doge style, or a diagnostic if it does not parse. Comments are preserved; the token stream is never changed.
free_names
The names a function body references but does not bind — the names it needs from an enclosing scope (or that resolve to globals/builtins).
generate
Generate a complete Rust source file from a checked Script, or a diagnostic for a construct it cannot compile (a class used as a value).
generate_program
Generate one Rust source file wiring together every file in a Program.
hoisted_names
Every bound name in one scope — such/so declarations, for loop variables, oh no error names, and nested function definitions — in first-seen order, each once. These become the scope’s Env fields or hoisted locals. A nested function’s own body is not descended into: its inner names belong to its own scope.
is_builtin
Whether name is a builtin — always in scope, never redefinable.
load
Load the entry script and every .doge module it transitively imports.
load_program
Load the entry script and every module it imports into a Program, resolving so <name> against the stdlib and sibling files only (no project dependencies).
load_program_with_deps
Load a program, resolving bare imports against deps (a project’s resolved dependency graph) in addition to the stdlib and sibling files.
parse
Lex and parse source (named path for diagnostics) into a Script
parse_repl
Parse a REPL snippet. Unlike [parse], the top level does not require a closing wow, so a clean parse to end-of-input is ReplParse::Complete. A parse that fails at end-of-input — the snippet was cut off mid-construct — is ReplParse::Incomplete so the caller can read another line; any failure at a real token is ReplParse::Error. A leading top-level wow ends the snippet, so the statements before it parse as complete.
read_manifest
Read and parse the doge.toml at root.
resolve_project
Resolve root’s dependency graph into a DependencyMap. git_dir turns a git source into a local package directory (fetching or reading a cache); a path dependency is resolved relative to the package declaring it.
single_file_program
Build a one-file Program from an already-parsed script, resolving imports against the stdlib only. Used by the single-file generate/check APIs and the codegen unit tests, where no user modules are on disk to load.
stdlib_module
The module named name, if it exists.

Type Aliases§

DependencyMap
Every package in a resolved project: canonical package-root directory → the aliases that package declares → the canonical entry .doge file each binds. The loader finds a file’s owning package by walking its canonical ancestors to the nearest directory present as a key here.