All Projects → leek-wars → Leekscript V2

leek-wars / Leekscript V2

Licence: gpl-3.0
A dynamically typed, compiled just-in-time programming language used in Leek Wars' AIs

Programming Languages

cpp
1120 projects

Projects that are alternatives of or similar to Leekscript V2

Jitfromscratch
Example project from my talks in the LLVM Social Berlin and C++ User Group
Stars: ✭ 158 (+243.48%)
Mutual labels:  compiler, llvm, jit
Llvm Tutorial Standalone
DEPRECATED (Use: https://github.com/llvm-hs/llvm-hs-kaleidoscope )
Stars: ✭ 38 (-17.39%)
Mutual labels:  compiler, llvm, jit
Gocaml
🐫 Practical statically typed functional programming language implementation with Go and LLVM
Stars: ✭ 653 (+1319.57%)
Mutual labels:  compiler, llvm
Rustc codegen cranelift
Cranelift based backend for rustc
Stars: ✭ 675 (+1367.39%)
Mutual labels:  compiler, jit
Tinycc
Unofficial mirror of mob development branch
Stars: ✭ 784 (+1604.35%)
Mutual labels:  compiler, jit
Rhine Ml
🏞 an OCaml compiler for an untyped lisp
Stars: ✭ 621 (+1250%)
Mutual labels:  compiler, llvm
Llvmswift
A Swift wrapper for the LLVM C API (version 9.0.1)
Stars: ✭ 641 (+1293.48%)
Mutual labels:  compiler, llvm
Numba
NumPy aware dynamic Python compiler using LLVM
Stars: ✭ 7,090 (+15313.04%)
Mutual labels:  compiler, llvm
Enzyme
High-performance automatic differentiation of LLVM.
Stars: ✭ 418 (+808.7%)
Mutual labels:  compiler, llvm
Cfl
a Compileable statically typed Functional programming Language
Stars: ✭ 7 (-84.78%)
Mutual labels:  compiler, llvm
Ldc
The LLVM-based D Compiler.
Stars: ✭ 937 (+1936.96%)
Mutual labels:  compiler, llvm
Lyca
programming language compiler w/ llvm
Stars: ✭ 9 (-80.43%)
Mutual labels:  compiler, llvm
Mull
Practical mutation testing tool for C and C++
Stars: ✭ 536 (+1065.22%)
Mutual labels:  llvm, jit
Langcraft
Compiler from LLVM IR to Minecraft datapacks.
Stars: ✭ 495 (+976.09%)
Mutual labels:  compiler, llvm
Dynarmic
An ARM dynamic recompiler.
Stars: ✭ 475 (+932.61%)
Mutual labels:  compiler, jit
Inkwell
It's a New Kind of Wrapper for Exposing LLVM (Safely)
Stars: ✭ 732 (+1491.3%)
Mutual labels:  llvm, jit
Unlisp Llvm
Compiler for a toy Lisp language
Stars: ✭ 33 (-28.26%)
Mutual labels:  compiler, llvm
Enso
Hybrid visual and textual functional programming.
Stars: ✭ 5,238 (+11286.96%)
Mutual labels:  compiler, jit
Scala Native
Your favorite language gets closer to bare metal.
Stars: ✭ 4,053 (+8710.87%)
Mutual labels:  compiler, llvm
Grin
GRIN is a compiler back-end for lazy and strict functional languages with whole program optimization support.
Stars: ✭ 834 (+1713.04%)
Mutual labels:  compiler, llvm

CI Coverage Status GPL Licence

LeekScript is a dynamically typed, compiled just-in-time programming language initially designed for Leek Wars AIs, and for games in general. Design to be simple to use for beginners, but with rich syntax and functionnalities, and a good speed thanks to an optimized compiler.

Contents

  1. Demonstration - try it online
  2. Building - build instructions
    2.1 Shared library - build and use
    2.2 WebAssembly - build analyzer for the web
  3. Usage - usage
    3.1 Command-line options - CLI options description
  4. Tests - run tests, coverage, benchmark and more
  5. Troubleshooting - common pitfalls and useful tools
  6. Projects using LeekScript - discover projects using LeekScript language
  7. Libraries - check library dependencies
  8. License - license information

Demonstration

Play with online editor at https://leekscript.com/editor including syntax highlighting, smart completion and execution.


Building

make

The executable leekscript is in the build/ folder.

Shared library

Use make lib to build libleekscript.so in build/ folder. You can use sudo make install to copy it in /usr/lib/ and make it available everywhere.

WebAssembly analyzer

Run make analyzer-web to build the analyzer to target browsers in WebAssembly. Try it by running a small web server with python tool/wasm_server.py and browsing the link. Then check the console for the output result.


Usage

After building, enter a LeekScript top-level (REPL):

leekscript

Execute a file or a code snippet:

leekscript my_file.leek
leekscript "[5, 6, 7] ~~ x -> x ** 2"

Command-line options

The following command-line options are available when calling leekscript command. You can use multiple option by combining them (example: leekscript -dijt).

Option Description
-b | --bitcode Output the program's bitcode file (LLVM's .bc file).
-c | --execute_bitcode Execute input as a bitcode file (LLVM's .bc file).
-d | --debug Print debug information : types.
-e | --example Output a simple one-liner example code.
-f | --format Output the program nicely-formatted.
-s | --sections Display program sections.
-h | --help Display help.
-i | --intermediate Output the program's intermediate representation (LLVM's .ll file).
-j | --json Get all the results in JSON format.
-l | --legacy Use legacy mode (LeekScript 1.0): enable old functions, arrays and other behaviors.
-o | --operations Enable operations counter and limit to 20 millions.
-O<level> Optimization level.
-r | --execute_ir Execute input as an IR file (LLVM's .ll file).
-t | --time Print compilation and execution time and operations (if enabled).
-v | --version Print the current version.

Tests

LeekScript has a large set of tests to validate parsing, compilation and execution. They are located in the test/ folder. They can run on multiple threads to speed-up testing process. Simply use the following command to run all the tests on your machine:

make test

Coverage

You can also get a test coverage report, using gcov + lcov tools. This build will be unoptimized (-O0) to be able to get line coverage properly. Use the following command then browse build/html/index.html to inspect the HTML test coverage report:

make coverage

Benchmark

Build and run the benchmark comparing the performance of LeekScript against C, Java and Python for several algorithms:

make benchmark

Troubleshooting

Valgrind

To help debugging, you can use valgrind with the following commands:

make valgrind  # valgrind default tool
make callgrind # valgrind callgrind tool

Clang C++ IR output

https://godbolt.org/ is a great tool to explore C/C++ generated assembly. Using -S -emit-llvm -g0 -O1 options, you can discover LLVM IR for given C++ code.

For a detailed and more technical list of troubleshooting entries, read document/troubleshooting.md.

If you don't find any answer in these documents, check issues page on GitHub and feel free to post a new one.


Projects using LeekScript

Libraries used

  • LLVM Version 8.0.0
  • GNU MP, by Torbjörn Granlund, under GPL license
  • JSON for modern C++, by Niels Lohmann, under MIT license
  • CLI11, by Henry Schreinern under NSF AWARD 1414736

License

Distributed under the GPL3 license. Copyright (c) 2016-2019, Pierre Lauprêtre

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].