Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/razshare/olang-old

Experimental frontend for WASI and other targets (mainly PHP).
https://github.com/razshare/olang-old

ast frontend parser php webassembly

Last synced: about 1 month ago
JSON representation

Experimental frontend for WASI and other targets (mainly PHP).

Awesome Lists containing this project

README

        

Syntax showcase

```olang

// this is a struct
struct user {
username: string = "test"
email: string = "asd"
phone: string = "awerqw"

// this is a struct callable (function), it returns bool
is_admin => bool {
// logic goes here
}
}

// this is a callable, it takes 2 strings and returns a bool
validate => bool {
email: string = "[email protected]"
phone: string = "111111"

// validation logic

}

// calling a callable, parameters must always be named
validate(email: "[email protected]", phone: "22222")

// this is an if expression
if 1 > 2 {
// some comment
return 1
}

// if else expression
if 2 > 1 {
// then
} else {
// else
}

// and nested
if 2 > 1 {
// then
} else {
// else
if 3 === 3 {
}
}

if 2 > 1 {
// then
} else if 3 === 3 {
// else if
}

// due to how the parser works, this is also allowed
if 2 > 1 {
// then
} else => if 3 === 3 {
// else if
}

// a few more interesting examples

if 1 > 2 => validate(email: "[email protected]", phone: "33333333")
else if 1 > 2 => false

// this looks weird, don't think many would use it, but it's allowed
if 1 > 2 => validate(email: "[email protected]", phone: "44444444")
else => if 1 > 2 => false
```