Skip to content
This repository was archived by the owner on Aug 6, 2024. It is now read-only.

itto-hiramoto/twinkle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

567 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Twinkle Programming Language

Getting Started | Language Reference | Examples

Features

  • Object-oriented programming
  • Generics
  • Safe memory management with smart pointers (unstable)
  • Tagged/Discriminated union (Like Rust's enum)
  • LLVM is adopted for backend
  • Variable shadowing
  • Elixir-like pipeline operator
  • Pascal-like pointer syntax

See the examples and test/cases folders for actual program examples.

Installation

Dependency List

  • LLVM (Confirmed to work with 13 and 14)
  • Boost
  • CMake
  • Make (Anything that is supported by CMake)
  • C++20 compiler
  • GCC

Install Dependencies (Debian, Ubuntu)

Here is how to install them in ubuntu.

$ sudo apt update -y

Install GCC, Make and CMake.

$ sudo apt install -y build-essential cmake

Install Boost 1.80.0.

$ sudo apt install -y g++ python-dev-is-python3 autotools-dev libicu-dev libbz2-dev wget
$ cd /tmp
$ wget https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2
$ tar jxvf boost_1_80_0.tar.bz2
$ cd boost_1_80_0/
$ ./bootstrap.sh --prefix=/usr/local/
$ sudo ./b2 install -j$(expr $(nproc) + 1)

Install LLVM 14. (https://apt.llvm.org/)
Versions other than 13 and 14 may not work.

$ sudo apt install lsb-release software-properties-common gnupg
$ cd /tmp
$ wget https://apt.llvm.org/llvm.sh
$ chmod +x llvm.sh
$ sudo ./llvm.sh 14

Installation

Clone this repository.

$ git clone https://github.com/yohashinoio/twinkle.git
$ cd twinkle

Create build directory.

$ mkdir build && cd $_

Build and install. (If llvm-config command name is llvm-config-14)

$ cmake .. -DCMAKE_BUILD_TYPE=Release -DLLVM_CONFIG_PATH="llvm-config-14"
$ cmake --build . -j
$ sudo cmake --install .

If you want to specify where to install.

$ cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="path/to/install"
$ cmake --build . -j
$ cmake --install .

If you want to specify the path to llvm-config.

$ cmake .. -DCMAKE_BUILD_TYPE=Release -DLLVM_CONFIG_PATH="path/to/llvm-config"
$ cmake --build . -j
$ sudo cmake --install .

Testing

Passing -DENABLE_TEST=1 to cmake and building will create an executable file for testing.

$ cmake .. -DENABLE_TEST=1
$ cmake --build . -j

Run the test with CTest.

$ ctest -V

Compiler Usage

If you want to compile and link main.twinkle and sub.twinkle.

$ twinkle main.twinkle sub.twinkle
$ ./a.out

If you want to do JIT compilation.

$ twinkle --JIT main.twinkle sub.twinkle

See help for more detailed description.

$ twinkle --help

References

  • X3 Documentation: Documentation for Boost.Spirit.X3.
  • Using X3 Slides: Slides for Boost.Spirit.X3.
  • LLVM Tutorial: Tutorials about using LLVM. Includes a tutorial about making a custom language with LLVM.
  • LLVM Reference: 'Doxygen generated documentation' and 'LLVM Language Reference Manual'
  • きつねさんでもわかる LLVM: あらゆる可能性を秘めたコンパイラ基盤として注目されている LLVM。本書はコンパイラを実際に作りながら LLVM のフロントエンドからバックエンドまでを幅広く解説した世界初(!?)の LLVM 解説本です。

License

This project is available under the MIT license.
See LICENSE for the full content of the license.

About

Twinkle Programming Language

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published