Crates.io | finn-assembler |
lib.rs | finn-assembler |
version | 0.2.2 |
source | src |
created_at | 2019-03-18 05:50:22.875262 |
updated_at | 2019-04-05 15:19:49.140524 |
description | The Finn IR Assembler |
homepage | |
repository | https://github.com/adam-mcdaniel/finn-assembler |
max_upload_size | |
id | 121918 |
size | 2,440,353 |
The assembler for the Finn IR implemented using HLVM v0.9.0
Finn IR is a minimal language that is meant to be targetted by other languages.
It compiles to Rust, which is then compiled to a binary.
@
operator after an identifier.:
, >
, and <
operators allow for simple object oriented programming.Calculates n factorial.
./fn examples/factorial.fn
{
n=
1 total=
{
total n* total=
1 n- n=
} {1 n greater!} &
total
} factorial=
1500 factorial! println!
Demonstrates use of Lambda Calculus in Finn IR.
./fn examples/lambda.fn
{a= {b= a}} True =
{a= {b= b}} False =
{p= {q= p q p!!}} And=
{ "is false!" println! } { "is true!" println! } True True And!!!!!
Gets user input from the command line, and prints out the result.
./fn examples/input.fn --crates include/input
">> " input@! user_input=
"You said: \"" print! user_input print! "\"" println!
Automates a lot of the syntax required to define a constructor function. It also demonstrates how you can use a Rust FFI to simulate 'macros' (they're not really macros).
./fn examples/struct.fn --crates include/structs
[
0 "x"
{
self=
self x: > 1 + self x: < self =
"im a method!" println!
self
} "method"
{
"im a static method!" println!
} "static_method"
] strukt@! s=
s x: > println!
s s method: > ! s=
s x: > println!
s static_method: > !
Calculates the fibonacci sequence.
./fn examples/fibonacci.fn
{
n=
1 a=
0 b=
0 c=
{
a b+ c=
b a=
c b=
"iteration " print! n print! " " print! c println!
1 n-n=
} {0 n greater!} &
c
} fib=
29404 fib!
Demonstrates Object Oriented Programming in Finn IR.
./fn examples/object.fn
{
$ self=
x= y=
x self x: < self=
y self y: < self=
{
self= dx= dy=
self x: > dx + self x: < self=
self y: > dy + self y: < self=
self
} self move: < self=
{
self=
"self:x " print! self x: > println!
"self:y " print! self y: > println!
self
} self println: < self=
self
} Sprite=
0 20.5 Sprite ! s=
s s println: > !
1 5 0- s s move: > ! s=
s s println: > !
To install the Finn-assembler
, clone the Finn-assembler
repo, and run the install.sh
file.