Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ on:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
test:
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y clang cmake
run: sudo apt-get update && sudo apt-get install -y cmake g++ gcc python3-pytest
- name: Configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
- name: Build
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
- name: Unit tests
run: ./build/unit_tests
run: cmake --build build --parallel 2
- name: Test C++ compiler and Python reference
run: ctest --test-dir build --output-on-failure
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,6 @@ compare
function
hello
input

# CMake build outputs
/build/
26 changes: 11 additions & 15 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
# AGENTS.md

Guidance for AI coding agents working in **numlang**.
Guidance for coding agents working in Numlang.

## Project overview



- Language: C++
- Default branch: main
- Primary executable: C++20 compiler `numlangc`, emitting C source.
- `numlang/` is the retained Python reference compiler, not the C++ implementation.
- The C++ port currently supports a limited core subset; see `docs/cpp-compiler-status.md`.
- Default branch: `main`.

## Working rules

- Inspect the README, manifests, CI workflows, and nearby code before editing.
- Preserve existing architecture, naming, formatting, and error-handling conventions.
- Use project scripts for validation; never claim checks you did not run.
- Keep changes scoped and update tests or documentation when behavior changes.
- Use feature branches and pull requests.
- Treat generated files, credentials, deployment configuration, and release metadata as sensitive.

## Recent history

Sync AGENTS.md from zincfox; Sync AGENTS.md from zincfox; Sync CONTRIBUTING.md from zincfox; Sync CONTRIBUTING.md from zincfox; Update issue template config
- Inspect README.md, CMakeLists.txt, tests, and CI before editing.
- Keep C++ feature claims, tests, and capabilities.json synchronized.
- Fail closed for unsupported opcodes and source syntax.
- Do not claim the C++ port is feature-complete because the Python reference supports a feature.
- Keep build outputs and temporary compiler artifacts out of version control.
- Use feature branches and pull requests; never claim checks that were not run.
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.16)
project(numlang LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

add_executable(numlangc src/main.cpp)
target_compile_options(numlangc PRIVATE -Wall -Wextra -Wpedantic)

find_package(Python3 REQUIRED COMPONENTS Interpreter)
enable_testing()
add_test(NAME compiler_smoke COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/smoke_cpp.py $<TARGET_FILE:numlangc> ${CMAKE_C_COMPILER})
add_test(NAME legacy_reference_tests COMMAND ${Python3_EXECUTABLE} -m pytest -q tests/test_compiler.py)
add_test(NAME capability_matrix COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/check_capabilities.py)
set_tests_properties(compiler_smoke legacy_reference_tests capability_matrix PROPERTIES WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
30 changes: 17 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# Contributing to numlang
# Contributing to Numlang

Numlang is migrating from a feature-complete Python reference compiler to a C++20 compiler that emits C. The C++ port is intentionally incomplete; keep its supported subset explicit and fail clearly for unsupported operations.

## Development setup

## Project context
A C++20 compiler, CMake, a host C compiler, Python 3, and pytest are required. The Python package is retained as a compatibility reference while the C++ port expands.

- Primary language: Python
- Default branch: main
```sh
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j2
ctest --test-dir build --output-on-failure
```

## Before submitting changes
## Working rules

- Read the README, manifests, and CI workflows before choosing commands.
- Run the documented formatter, linter, build, and test checks relevant to your change.
- Keep commits focused and explain compatibility or operational impact.
- Open changes through a pull request with verification results.

## Recent direction

Recent commits: Sync AGENTS.md from zincfox; Sync AGENTS.md from zincfox; Sync CONTRIBUTING.md from zincfox; Sync CONTRIBUTING.md from zincfox; Update issue template config
- Read README.md, AGENTS.md, CMakeLists.txt, CI, and the C++ compiler-status document before changing behavior.
- Do not advertise a feature as implemented in C++ until the C++ compiler and a regression test cover it.
- Unsupported numeric opcodes and symbols must produce diagnostics, never silently compile as literals or no-ops.
- Keep the legacy Python tests passing when changing shared language semantics.
- Update the capability matrix to describe the C++ port, not only the legacy reference compiler.
- Add C++ end-to-end smoke coverage for new syntax and runtime behavior.
- Use a feature branch and pull request; report exact checks and results.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Numlang compiler

Numlang is an esoteric stack-based language that compiles to C via a Python compiler.
Numlang is an esoteric stack-based language with an in-progress C++20 compiler that emits C. The historical Python compiler is retained as a reference implementation while C++ feature parity is rebuilt.
The character set is `0-9 ^ & * + - / . | ; % # ~ \" !`.

> 🧶 Also available on [Tangled](https://tangled.org/ewancroft.uk/numlang)
Expand All @@ -14,7 +14,7 @@ cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
```

The binary is `build/numlangc`.
The binary is `build/numlangc`. The current C++ implementation supports a tested core subset: numeric, string and character literals; stack operations; arithmetic; comparisons; selected math and bitwise opcodes; numbered variables; and basic console I/O. It rejects recognized but unsupported structural opcodes rather than treating them as ordinary numbers. The full language reference below describes the intended language and retained Python reference compiler, not complete C++ parity. See [the C++ compiler status](docs/cpp-compiler-status.md).

---

Expand All @@ -33,11 +33,7 @@ numlangc hello.num --run --cc clang
# Increase the runtime stack depth (default 1000)
numlangc hello.num --run --stack-size 4096

# Debug: dump the token stream
numlangc hello.num --emit-tokens

# Debug: dump the parsed AST
numlangc hello.num --emit-ast
```

---
Expand All @@ -46,6 +42,9 @@ numlangc hello.num --emit-ast

### Data model

**C++ port status:** this reference describes the full intended language. Only the core subset described above is implemented by the current C++ executable; advanced control flow, declarations, aggregates, FFI, arrays, and other features remain deferred in the C++ port. The historical Python compiler remains available as a reference implementation.


- All values are 64-bit IEEE 754 doubles.
- The runtime has a stack (depth configurable, default 1000) and **100 named variables** `vars[0]`–`vars[99]`, all initialised to `0`.

Expand Down
Loading
Loading