Community & Contributing

SUB is open source (MIT License) and welcomes contributions of all kinds — bug reports, documentation, new features, and new backends. This guide covers everything you need to get started.

How to Contribute

There are many ways to contribute, regardless of your experience level:

Building from Source

The build process is simple — one command, no dependencies beyond a C compiler.

# Clone the repository
git clone https://github.com/subhobhai943/sub-lang.git
cd sub-lang

# Build all three tools (subi, subc, sub)
make

# Run the test suite
make test

# Install locally
sudo make install

Requirements

That's it. No build system generators, no package managers, no configuration.

Tip: Set CC=clang or CC=gcc to choose your compiler. Set PREFIX to change the install location.

Running Tests

SUB ships with a comprehensive conformance test suite that verifies every backend produces identical output.

# Run all tests
make test

# Run only interpreter tests
make test-interp

# Run only transpiler tests
make test-transpile

How the conformance suite works

  1. Each test is a .sb program in the tests/ directory
  2. The program is run through subi (the interpreter) to capture reference output
  3. The same program is transpiled to each target language and run
  4. Outputs are diffed — any difference is a test failure

This ensures that all 13 backends agree with the interpreter on every program.

Note: When adding a new feature, always add a conformance test. This is how we guarantee cross-backend consistency.

Adding New Backends

Adding a new transpilation target is the most impactful contribution you can make. Here's the process:

1. Understand the AST

All backends walk the same AST. The node types are defined in src/ast.h. Each node has a type tag and type-specific fields. Your backend needs a walk function that handles every node type.

2. Create the backend file

Add a new file src/codegen_<target>.c following the pattern of existing backends. The key functions are:

3. Register the target

Add your target to the dispatch table in src/main.c so sub program.sb <your-target> works.

4. Add conformance tests

Add your backend to the CI test matrix. Every existing test program must pass through your backend.

5. Update documentation

Add your target to the transpilation docs and the type mapping table.

Project Structure

sub-lang/
├── src/               # C source code
│   ├── main.c         # Entry point, tool dispatch
│   ├── lexer.c/h      # Tokenizer
│   ├── parser.c/h     # AST builder
│   ├── interpreter.c  # subi — direct AST interpreter
│   ├── codegen_*.c    # One file per transpilation target
│   ├── codegen_infer.c # Type inference
│   ├── elf_emit.c     # ELF64 binary writer (subc)
│   └── stdlib_*.c     # Standard library runtime
├── stdlib/            # Standard library (.sb files)
│   ├── math.sb
│   ├── arrays.sb
│   ├── strings.sb
│   └── ...
├── tests/             # Conformance test suite
├── packaging/         # Platform packages (deb, rpm, arch, etc.)
├── installer/         # Universal install script
├── Makefile
└── README.md

Code of Conduct

We are committed to providing a friendly, safe, and welcoming environment for all, regardless of level of experience, gender identity, sexual orientation, disability, neurotype, ethnicity, religion, or similar personal characteristic.

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project maintainer at GitHub. All complaints will be reviewed and investigated.

Reporting Issues

Use GitHub Issues to report bugs, request features, or ask questions.

Before reporting

Writing a good bug report

Security issues: Do not report security vulnerabilities in public issues. See the Security Policy for the responsible disclosure process.

Getting Help