o
odin.langpkg.dev
packages / library / staga

staga

v0.0.2library

an interpreted stack based programming language

MIT · updated 1 year ago

Staga

a stack-based programming language i am working on

Plans:

"Features":

printing

"Hello, World" .           // string printing
69             .           // int printing
0xFF           .           // hex printing (also supports binary and octal)
-69            .           // int printing
-0.69          .           // float printing
1 2 3 stack    pop pop pop // prints the stack

arithmetics

 -5 5 + .
 6 1  - .
 2 10 * .
 10 5 / .

Conditions

 5 10 < .
 5 10 > .
 5 5 =  .

Control Flow

 1 0 > if "yes"   else "no"         done . // if 1 > 0
 69 if "non zero" else "it is zero" done . // if 69 != 0

 0 while dup < 100 do dup . 1 + end

 int3 "waited for you" .                   // halt program execution until user presseed enter

stack manipulation

69 dup . .
1 2 3 2 swap . . // this swaps the top element with the 2th one aka 3 and 2 respectively in this case
1 pop            // deleted the top of the stack aka the 1 in this example

memory

 10 2 mems // stores 10 in memory no 2
 2 meml .  // loads the value in memory no 2 and prints it

macros

 fn test1_ // start of a macro names test1_
  69 dup . 
  351 + .
 fend // end of the macro
 jmp test1_ // calling the macro

file loading

foo.stg
 fn something
  "foo" .
 fend

main.stg
 load "foo"
 jmp something

How To Build:

first install odin

then

 ./build.sh debug
 ./build.sh release

 build.bat debug
 build.bat release

How to Use

Note:

run:

 // linux
 ./build/staga_debug examples/showcase.stg
 ./build/staga examples/showcase.stg

 // windows
 .\build\staga_debug examples/showcase.stg
 .\build\staga examples/showcase.stg