Skip to content

tjysdsg/tan

Repository files navigation

tan programming language

codecov

Work In Progress

tan has been my hobby project for several years now. It helped me tremendously on understanding how compilers work, how large-scale software is structured (I read a lot of LLVM source code LOL), and how programming languages are designed. It will become a playground for me to work on interesting language designs. Needless to say, the design is never intended to be "better than xxx language".

I currently want it to:

  • Adapt some modern syntax
  • Support writing less painful and verbose OOP
  • Have strong and interesting meta-programming mechanism
  • Steal design from other languages such as Zig, Rust, Carbon, Python, C#, D, ...

Quickstart

A Quick Peek

See *.tan files under test/test_exec for some examples.

Prerequisites

  • Make sure to clone this repository using git clone --recursive, see submodules under dep/
  • CMake >=3.19
  • LLVM 15 tools and development libraries
  • See Dockerfile for a full list of dependencies

Building and Testing

tan uses CMake as its build system. Run the following command in project root directory to build and run all tests.

mkdir -p build
cd build
cmake ..
make tests

Platforms

Platform Status Note
Linux ✔️ Only tested on Ubuntu 20.04 for now
Windows Build successfully, but clang doesn't run correctly on my machine
Mac I don't have a mac. Mac is for superior people

CMake options

  • ENABLE_COVERAGE: bool, Enable test coverage, default OFF
  • BUILD_EXAMPLES: bool, Build tan examples, default OFF
  • ENABLE_CCACHE: bool, Enable ccache to speed up rebuilding, default ON
  • LLVM_ROOT_DIR: Custom LLVM location
  • CLANG_ROOT_DIR: Custom CLANG location
  • LLD_ROOT_DIR: Custom CLANG location

Documentation

Doxygen https://tjysdsg.github.io/tan/html/index.html
Some markdown files in the source code Search under src

Project Structure

  • dep: third-party dependencies
  • docs: documentations generated by Doxygen
  • examples: example programs written in tan and C
  • fuzzing: tools for fuzz testing, not updated for a long time
  • include: public headers
  • runtime: tan runtime source files (a mix of tan and C++)
  • scripts: utility scripts
  • src: source files
    • analysis: code analysis and type checking
    • ast: Abstract Syntax Tree
    • backtrace: wrapper around libbacktrace
    • base: should be named core loll
    • cli: commandline interface of tanc compiler
    • codegen: LLVM IR and binary object generation
    • compiler: compiler driver
    • lexer: lexer
    • linker: linker implemented using clang frontend
    • llvm_api: API wrappers for LLVM and clang
    • parser: A hand-written parser
    • source_file: Classes related to representing source files and text tokens
  • test: unittests and system tests (mostly system tests)
    • test_exec: executable compilation tests
    • test_lib: library compilation tests
    • Some other unittests