rezzaghi / onyx

The <onyx> Programming Language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

this is still in a REALLY REALLY Early stage, like not even usable

If ye like this concept then PLEASE Help Out!
I cant do it all by myself... :/

Check out TUTORIAL.md for a quick crash course

General

  • .ox file extension
  • asm but with high level features, like iterators and closures
  • very hands on and 'Do it Yourself'.
  • most things are represented as just series of bits making ye have to think bout how stuff maps in mem
  • Freedom of asm, anywhere-to-anywhere data flow and execution order
  • no bs oop, just code
  • Both Curly Brackets, and Significant whitespace
  • DENSE operator oriented syntax

Done

  • Comments //
  • Parsing Markers
  • Console Logger
  • Parsing Includes

Hello World

main {
    *stdout <= "Hello, World!\n"
}

or

@std prtl
main {
    prtl<"Hello, World!">
}

std subroutine examples

// `&*` means the subroutine takes any number of arguments of any "type"
@std cat fmt
prtl<&*> {
    // `$&*` means it'll take all of the args 
    *stdout <= cat<&, "\n"> <- fmt<$&*>
}

Fibonacci

// exit with code, `$0` specifies that we want a literal number `0`
main -> <$0> {
    ;n = 9
    print_fib
}

// all returns go to the stdout channel
print_fib -> *stdout {
    // `ret<>` returns
    (n < 1) => ret<"Invalid Number of Terms!\n">
    (n = 1) => ret<"0\n">
    (n = 2) => ret<"0 1\n">
    
    *stdout <= "0 1\n"

    // # means the var will be freed at the end of the scope
    ;#prev1 = 1
    ;#prev2 = 0

    @loop
    ;fn = (prev1 + prev2)

    prev2 <= prev1
    prev1 <= fn

    // `#` here explicitly frees the value after its use
    // `fmt<>` formats the integer into ascii, `cat<>` concatinates two strings
    *stdout <- cat<&, "\n"> <- fmt<#fn>

    // decrement by 1
    dec<n>

    // jump to `@loop`
    (n > 0) => jmp(loop)

    // return nothing, (unsafe!)
    ret<#>
}

About

The <onyx> Programming Language

License:MIT License


Languages

Language:Rust 99.4%Language:Shell 0.6%Language:Ox 0.0%