axon-examples
Axon Examples
Section titled “Axon Examples”Showcase programs demonstrating the Axon programming language. Currently 28 examples across 6 categories.
Examples
Section titled “Examples”Algorithms & Data Structures (12 examples)
Section titled “Algorithms & Data Structures (12 examples)”| Example | Description | Status |
|---|---|---|
fibonacci.axs | Recursive and iterative Fibonacci | CI |
collatz.axs | Collatz conjecture sequence | CI |
fizzbuzz.axs | Classic FizzBuzz | CI |
gcd.axs | Greatest common divisor (Euclidean) | CI |
sieve.axs | Sieve of Eratosthenes | CI |
binary_search.axs | Binary search on sorted arrays | CI |
bubble_sort.axs | Bubble sort implementation | CI |
linked_list.axs | Pointer-based linked list | SKIP (requires std lib) |
stack_machine.axs | Stack-based expression evaluator | CI |
matrix.axs | Matrix operations (multiply, transpose) | CI |
graph_bfs.axs | BFS + Kahn’s topological sort over a directed graph | CI |
async_pipeline.axs | async fn and await — batch processing pipeline | SKIP (requires std lib) |
System Tools (4 examples)
Section titled “System Tools (4 examples)”| Example | Description | Status |
|---|---|---|
wc.axs | Unix wc clone — word/line/byte counter | CI |
cat.axs | Unix cat clone — file concatenation | CI |
uniq.axs | Unix uniq clone — adjacent duplicate counter | CI |
line_count.axs | Line counting utility | CI |
rot13.axs | ROT13 cipher encoder/decoder | CI |
Language Features (2 examples)
Section titled “Language Features (2 examples)”| Example | Description | Status |
|---|---|---|
option_types.axs | Option<T> — Some, None, pattern matching | CI |
math_demo.axs | Numeric types and arithmetic | SKIP (requires std lib) |
Networking (10 examples — requires std library)
Section titled “Networking (10 examples — requires std library)”| Example | Description | Status |
|---|---|---|
echo_server.axs | TCP echo server | SKIP (requires std lib) |
http_server.axs | HTTP/1.1 web server | SKIP (requires std lib) |
routing_server.axs | HTTP server with URL routing | SKIP (requires std lib) |
rest_api.axs | REST API with JSON responses | SKIP (requires std lib) |
rest_api/server.axs | REST API server (multi-module) | SKIP (requires std lib) |
rest_api/models.axs | Data models + JSON serialization | SKIP (requires std lib) |
rest_api/handlers.axs | Route handlers + HTTP responses | SKIP (requires std lib) |
chat/server.axs | WebSocket chat server | SKIP (requires std lib) |
chat/client.axs | CLI chat client | SKIP (requires std lib) |
chat/protocol.axs | Shared chat protocol (JSON) | SKIP (requires std lib) |
GUI (1 example)
Section titled “GUI (1 example)”| Example | Description | Status |
|---|---|---|
gui_calculator.axs | Calculator application | SKIP (requires raylib) |
Tooling (1 example)
Section titled “Tooling (1 example)”| Example | Description | Status |
|---|---|---|
lsp_demo/ | LSP editor integration — VS Code + Neovim config + smoke test | CI |
Status key:
- CI — built, tested, and metrics-collected in CI
- SKIP (requires std lib) — skipped in CI (depends on axon-std modules not available in CI)
- SKIP (requires raylib) — skipped in CI (depends on libraylib not installed in CI runners)
Building & Running
Section titled “Building & Running”# Compile and run an exampleaxonc examples/fibonacci.axs -o fibonacci./fibonacci
# Or use the QBE backend explicitlyaxonc --emit-qbe examples/fibonacci.axs -o fibonacci.ssaqbe -o fibonacci.s fibonacci.ssacc -o fibonacci fibonacci.s -laxon_rt./fibonacciCI Status
Section titled “CI Status”This repo uses a shared CI template from axon-ci. See docs/ci-pipeline.md for full pipeline documentation.
Performance regression policy
Section titled “Performance regression policy”As of axon-ci#18, this repo uses the perf-thresholds template to detect performance regressions:
- Binary size: ≥ 20% increase fails (lenient — examples are tiny)
- Compile time: ≥ 30% increase fails (lenient — shared CI runners have high variance)
- MR comment: Auto-posted on every pipeline run showing baseline vs current
- Baseline: Fetched from
mainvia GitLab API (falls back to git if token missing)
The performance:regression-check job is allow_failure: true during initial rollout. After a stable baseline is established, tighten thresholds by overriding the job:
performance:regression-check: allow_failure: falseSee templates/perf-thresholds.yml in axon-ci for full configuration options.
Contributing
Section titled “Contributing”See CONTRIBUTING.md for a complete guide to adding a new example.
License
Section titled “License”MIT