The project

Architecture

Zy is a tree-walk interpreter written in Go. Its module is zy and declares Go 1.22. The local interpreter uses the standard library; HTTP serve mode also uses the official MongoDB Go driver.

.zy source -> Lexer -> Tokens -> Parser -> AST -> Interpreter -> Output or ZyError
FileResponsibility
main.goProcess entry point, interrupt handling, release version and exit status
internal/cli/cli.goCommand routing, script pipeline, CLI options and help
internal/cli/format.goCLI formatting modes and prepared file replacement
internal/cli/diagnostics.goVersioned JSON check output
core/lexer.goRecognize literals, keywords, operators, source positions
core/ast.goDefine syntax-tree nodes
core/parser.goRecursive-descent statement/expression parsing
core/interpreter.goHost options, runtime lifecycle, statement/control-flow evaluation
core/runtime_values.goValues, ordered maps, display, kinds and cycle handling
core/environment.goLexical environments and assignment
core/evaluate.goExpression evaluation, operators, calls and closures
core/members.goCollection/network/agent member dispatch and indexing
core/builtins.goGlobal built-in functions
core/numeric.goChecked integers, finite floats, mixed comparison
core/bounded.goCounted IPv4 splitting and overflow-safe ranges
core/methods.goMethod arity guards
core/stdlib.goLocal I/O, JSON, paths, environment, network allocation
core/modules.goModule declarations, bounded dependency graph, isolated scopes and cache
core/check.goNon-executing frontend checks with canonical in-memory source overlays
internal/lsp/Stdio protocol, snapshots, UTF-16 diagnostics, formatting, lexical symbols and editor requests
internal/server/HTTP hosting, MongoDB adapter, configuration, middleware, and graceful shutdown
core/host.goHost-provided namespaces, handler invocation, and bounded JSON conversion
core/prepared.goImmutable parsed entry/import snapshots and portable source digests
core/format.go / core/source_layout.goLossless layout, indentation, token and structural preservation
core/errors.goRepresent and render located errors
core/diagnostics.goStable diagnostic categories and interchange representation
core/interpreter_test.goExecution and diagnostic tests

Functions capture environments for closures. Member access dispatches collection and networking methods. Built-ins and library namespaces are registered in the global environment. Options inject I/O, script arguments, and cancellation context. Agent methods return simulations and do not invoke providers.

Before evaluation, the module loader reads and parses the complete local dependency graph. CheckProgram stops after that validation. Execution uses the loaded snapshots and caches module instances per run. Each module has its own environment; functions capture both that environment and their source origin. The interpreter shares I/O, arguments, and cancellation across modules. See the module decision.

HTTP hosting prepares the graph once and clones only module runtime state for each request. Host libraries supply MongoDB, sessions, roles, jobs, cache, logging, and metrics; persistent coordination lives in MongoDB. See backend services.

Repository conventions

  • docs/: user documentation and proposed design; archive/ preserves drafts.
  • examples/: runnable programs; tutorials/ holds teaching snippets.
  • assets/branding/: temporary identity and original reference asset.
  • bin/: ignored local outputs, including preserved legacy executables.
  • .github/workflows/: automation.
  • editors/vscode/: syntax extension, opt-in language client, tokenizer and client tests.
  • tools/: Python archive builder, integrity/smoke checks, and packaging tests.
  • dist/: ignored local archive outputs; no published release is implied.

The root retains main.go, preserving go run . and go build .. CLI implementation and its tests live together in internal/cli/; the root entry point only wires process I/O, cancellation, and the release version. CLI documentation tests run against repository-relative examples.

Add syntax only when a function/library API cannot express the use case clearly. Test boundaries before splitting the large interpreter by responsibility. Decide whether zy/core is a supported embedding API before moving it into internal/.

Found something to improve?Edit this page on GitHub ↗
Search guides, language features, and APIs ↵ to open first result