etcetera-compiler

Crates.ioetcetera-compiler
lib.rsetcetera-compiler
version0.1.3
created_at2025-07-22 11:38:17.308585+00
updated_at2025-08-26 07:19:39.273276+00
descriptionA Rust-based compiler project.
homepage
repositoryhttps://github.com/nomander17/etcetera-compiler
max_upload_size
id1763440
size117,853
(nomander17)

documentation

README

Etcetera

A programming language written in Rust using LLVM.

System Requirements

This project depends on the following external tools:

  • llc — part of the LLVM toolchain
  • clang — a C language family frontend for LLVM

Run

Build yourself and run

cargo run -- example.etc --run

Or get it from Cargo

cargo install etcetera-compiler

Then use using the etc command.

Features

  • 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 and float.
  • Safe String operations: Supports memory safe string concatenation.
  • Rich set of operators:
    • Arithmetic: +, -, *, /, // (floor division), % (modulo).
    • Comparison: ==, !=, >, >=, <, <=.
    • Floating point arithmetic also supported.
  • Control Flow: if then else statements and loop 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.

Syntax

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.

Commit count: 26

cargo fmt