Q+ 文档

Q+ Language

Q+ is a statically typed systems and application programming language. It comes with a self-hosted compiler (qboot), a bytecode virtual machine (bqvm), a standard library, and a language specification.

This repository contains the language only. The a separate product line (另一产品线) kernel and OS services are a separate closed-source product line and are not part of this repository.

Quick start · Language guide · Building from source · Contributing · FAQ · Specification

Highlights

Quick start

Requirements: Linux x86-64 with gcc and bash.

tools/build.sh
build/bqvm --timeout-ms 0 build/qboot.qbc src/examples/arith_sum.q -o <tmp>/arith_sum.qbc
build/bqvm <tmp>/arith_sum.qbc

The last command prints 5050. The build produces two artifacts:

For a guided first program, see QUICKSTART.en.md. For exact build hashes and test commands, see BUILDING.en.md.

Repository layout

PathContents
bootstrap/qboot.qbcBootstrap compiler bytecode used to self-host the compiler
src/compiler/qboot/Self-hosted Q+ compiler source
src/compiler/qplusc/AOT backend sources (not built by tools/build.sh in this release)
src/runtime/bootstrap_qvm/bqvm bytecode virtual machine
src/runtime/mini_kernel/Minimal C runtime used by bqvm (HAL, libc, syscall shims)
src/examples/193 runnable example programs
src/tests/Language fixtures: features/, semantics/, typecheck/, robustness/
stdlib/std/Standard library, 942 modules, imported with use std.<module>
docs/qplus_language_spec.mdQ+ Language Specification v4.52
docs/OS_SDK_PROTO.mdOS SDK 0.1 prototype report (external prototype, not in the release package)
docs/OS_SDK_DESIGN.mdOS SDK design overview (planning)
tools/build.shStandalone build (VM + self-hosted compiler)
tools/test.shLanguage regression suite
editors/vscode/VS Code extension sources (syntax, formatter, offline LSP; release component 0.6.0, optional/dev 0.12.0 (0.9.0/0.10.0/0.11.0 earlier))
LICENSE, NOTICEApache License 2.0 and attribution notices

Build and test

tools/build.sh   # build/bqvm and build/qboot.qbc
tools/test.sh    # compile examples and language fixtures, run a runtime smoke test

A passing run ends with QPLUS_LANGUAGE_TESTS_PASS. See BUILDING.en.md for expected hashes, a detailed description of what each script does, and troubleshooting.

Editor support

The release package's supported VS Code extension is 0.6.0 (190 checks ALL PASS; the release tree also contains the extension sources): syntax highlighting and snippets, a zero-dependency formatter (Q+: Format Document), build / run / test / ELF AOT commands, and an offline language server (qplus-lsp, stdio JSON-RPC, no network or third-party dependencies).

The language server implements an LSP v1.0 subset plus the 0.6 editing features: document/workspace symbols, go-to-definition, references, rename (workspace edits with prepare-rename), signature help, semantic tokens, hover/completion, code actions, inlay hints, document links, code lenses, workspace folders, workspace/executeCommand, and real compiler, runtime (Runtime error / Traceback) and ELF AOT (AOT_UNSUPPORTED_*) diagnostics.

Two optional/dev LSP lines exist outside the release tar: 0.7.0/0.8.0 are earlier dev components, and 0.12.0 is the latest optional/dev .vsix (0.9.0/0.10.0/0.11.0/0.12.0 are earlier dev lines). None is a supported release component, shipped in the language tar, or Marketplace published; their features are not a released capability until a future release explicitly includes them. The release tree's VS Code sources are 0.6.0.

.vsix packages are built on demand from the extension sources (scripts/package.sh, requires Node.js/npm) and are not committed to this repository; see the extension README for install and packaging instructions.

Community, governance and releases

Status: v1.21.0-dev is a release candidate, NOT PUBLISHED. OS SDK 1.18.0 is an external prototype (API-freeze candidate; 27/27 tests, 13 PASS/3 PARTIAL/4 BLOCKED (api_stability 128/0, examples 5/5); net BLOCKED; not part of the release package); LSP/VS Code 0.6.0 is the supported component, while 0.9.0/0.10.0/0.11.0 are optional/dev .vsix builds (not in the tar and not Marketplace-published).

Status

ItemValue
ReleaseQ+ 1.30.0-dev (release candidate)
Language specificationv4.52
Compilerqboot, self-hosting, deterministic output
VMbqvm with a minimal C runtime
Validated platformLinux x86-64 with gcc
LicenseApache License 2.0

The language has known, documented boundaries: if/match are statements rather than expressions, u64 is full 64-bit, and a few conversion opcodes are not yet implemented by the AOT backend (they fail loudly). See specification §7.4/§7.5.

What's new in v1.30.0-dev

Docs

← Q+ Hub