Skip to content

evanlin96069/ika

Repository files navigation

🦑 ika

A simple programming language that compiles into x86 assembly.

Build

Prerequisites

  • CMake (>= 3.15)
  • GCC

Linux

# From the project root:
mkdir -p build/debug && cd build/debug
cmake -DCMAKE_BUILD_TYPE=Debug ../..
cmake --build .

# For release build:
cd ../..
mkdir -p build/release && cd build/release
cmake -DCMAKE_BUILD_TYPE=Release ../..
cmake --build .

The compiler executable (ikac) will be placed in build/<cfg>/bin/.

Windows

The project currently supports Windows builds using the MinGW toolchain. You need a 32-bit MinGW gcc.

REM From the project root:
mkdir build\debug
cd build\debug
cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug ../..
cmake --build .

REM For release build:
cd ..\..
mkdir build\release
cd build\release
cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release ../..
cmake --build .

The compiler executable (ikac.exe) will be placed in build/<cfg>/bin/.


Testing

Run all tests

# From any build directory:
ctest --output-on-failure

Filter by group label

# Run only the 'basic' tests:
ctest -L basic

Usage

Usage: ikac [options] file
Options:
  -E               Preprocess only; do not compile, assemble or link.
  -S               Compile only; do not assemble or link.
  -o <file>        Place the output into <file>.
  -e <entry>       Specify the program entry point.
  -D <macro>       Define a <macro>.
  -I <dir>         Add <dir> to the end of the main include path.
  -?               Display this information.

Examples

Hello world

"Hello world!\n";

Fibonacci

// Fibonacci sequence using recursion

fn fib(n: i32) i32 {
    if (n <= 1) {
        return n;
    }
    return fib(n - 1) + fib(n - 2);
}

fn main() void {
    var i: i32 = 0;
    while (i < 10) : (i += 1) {
        "%d\n", fib(i);
    }
}

See more examples in the examples and tests folder.


Documentation

See the ika Language Documentation

About

A simple programming language

Topics

Resources

License

Stars

Watchers

Forks