Skip to content

tush00nka/can

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

can is a stack-based programming language written in rust. It is currently at the earliest stages of its development and basically copies the syntax of Tsoding's Porth.

Features

  • arithmetic operations
  • bitwise logic operations
  • dump (print number from the top of the stack)
  • if-else statements
  • while loops
  • memory addressing
  • syscalls
  • C-style comments (//)
  • Turing complete

Basic program

While loop that prints numbers 1 to 10

10 0 while 2dup > do 
    1 +
    dup dump
end

Fibonacci sequence

// prints first 10 numbers of Fibonacci sequence

mem 1 + 0 . // first
mem 2 + 1 . // second
mem 3 + 0 . // temp

// breaks after number 255 because we're using bytes :)
10 0 while 2dup > do
    1 +
    mem 3 + mem 1 + , mem 2 + , + . // sum two numbers and put result in temp value
    mem 1 + mem 2 + , . // put second number in place of first
    mem 2 + mem 3 + , . // put temp value in place of second
    mem 3 + , dump // print
end

Quick start

cargo run build examples/test.can && ./out
cargo run emulate examples/test.can

About

Stack-based programming language

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages