intscript
intscript copied to clipboard
A tiny language that compiles to intcode
intscript
Compiles programs which run on the intcode computer used by Advent of Code.
Install requirements using:
pip install -r requirements.txt
To compile a program:
python intscript.py samples/fibonacci.is > samples/fibonacci.ic
To run a program pass the intcode program followed by the inputs:
python intcode.py samples/fibonacci.ic 15
It will print the outputs generated by the program:
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]
Basic syntax:
# Read an input into variable `n`
input n;
# Output the value of variable `n`
output n;
# Basic expressions
a = 1;
b = 2;
c = a + b;
# `if` statements
if(6 < 7)
{
output c:
}
# `while` loops
i = 0;
n = 10;
while(i < n)
{
i += 1;
}
# Arrays
array a[3];
a[0] = 1;
a[1] = 2;
a[2] = a[0] + a[1];