/val

The val compiler

Primary LanguageSwiftApache License 2.0Apache-2.0

Val

Val is a research programming language to explore the concepts of mutable value semantics and generic programming for high-level systems programming.

This repository contains the sources of the reference implementation of Val. Please visit our website to get more information about the language itself.

Supported platforms

The compiler is currently developed on Unix-like operating systems. While Windows is currently not supported, we would enthusiastically receive any contributions along these lines. See #45 if you'd like to pitch in.

Installation

This project is written in Swift and distributed in the form of a package, built with Swift Package Manager. You will need Swift 5.6 or higher to build the compiler from sources.

You may compile Val's compiler with the following commands:

swift build -c release

That command will create an executable named valc in .build/release. That's Val compiler!

Implementation status

This project is under active development; expect things to break and APIs to change.

The compiler pipeline is organized as below. Incidentally, early stages of this pipeline are more stable than later ones. (Note: completion percentages are very rough estimations.)

  1. Parsing (100%)
  2. Type checking (50%)
  3. IR lowering (30%)
  4. IR analysis and transformations (30%)
  5. Machine code generation (20%)

You can select how deep the compiler should go through the pipeline with the following options:

  • --emit raw-ast: Only parse the input files and output an untyped AST as a JSON file.
  • --typecheck: Run the type checker on the input.
  • --emit raw-ir: Lower the typed AST into Val IR and output the result in a file.
  • --emit ir: Run mandatory IR passes and output the result in a file.
  • --emit cpp: Produce a C++ source file.
  • --emit binary (default): Produce an executable.

For example, valc --emit raw-ast -o main.json main.val will parse main.val, write the untyped AST in main.json, and exit the pipeline.

A more detailed description of the current implementation status is available on our roadmap page.

Contributing

We welcome contributions to Val. Please read through CONTRIBUTING.md for details on how to get started.

License

Val is distributed under the terms of the Apache-2.0 license. See LICENSE for details.