A programming language written in Rust using LLVM.
This project depends on the following external tools:
cargo run -- example.etc --run
cargo install etcetera-compiler
Then use using the etc
command.
- Ahead-of-Time (AOT) Compilation: Code is fully compiled and optimized before execution, not interpreted on the fly. The compiler toolchain (
llc
,clang
) assembles a standalone binary. - Variable Declaration: Loosely typed with optional type anotation (
my_var: int = 5
). - Data Types:
int
,float
,char
,string
,bool
- Automatic Type Coersion: Allows for arithmetic operations on mixed (compatible) data types like
int
andfloat
. - Safe String operations: Supports memory safe string concatenation.
- Rich set of operators:
- Arithmetic:
+
,-
,*
,/
,//
(floor division),%
(modulo). - Comparison:
==
,!=
,>
,>=
,<
,<=
. - Floating point arithmetic also supported.
- Arithmetic:
- Control Flow:
if then else
statements andloop from to
loops. - Input/Output: Writing to the shell with
print
. - Comments: Single-line
!
and multi-line!! ... !!
comments. - Flexible Syntax: Newlines and indentation are not syntactically significant.
example.etc
file:
! Single line comment
!! Multiline comment
like this !!
! Variables can be initialised with a type
a: int = 5
! Or auto inferred based on expression
b = 10.5
! Re-assignment also possible
b = 1.5
! Use variables in expressions with $
sum = $a + $b
! Print doesn't require $
! Use + for string concat
print "Sum: " + sum
!! Newlines and tabs are completely optional
but may be used for style !!
if a > b then
print a + " is bigger than " + b
else
print b + " is bigger than " + a
end if
! Loops are inclusive and auto-initialise the loop variable
loop from 1 to 5 in i
print $i
end loop
More programs are available in /programs
.