Skip to content

jck-bit/ExpressL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExpressL custom scripting Language

I made this compiler in typescript, i imagine building it in Rust or C, right now am learning Rust, I might consider remaking the compiler in it maybe in the future.

Hello World Example

To print "hello world" in ExpressL, use the print() function:

print("hello world")

Variable Declaration

Variables in ExpressL are declared using the let and const keyword followed by the variable name and its initial value: Variables declared with const cannot be redefined:

let foo = 45;
const bar = 56;
let foobar = foo + bar;
print(foobar)

Function Definition and Invocation

Functions in ExpressL are defined using the @fn keyword followed by the function name and its body enclosed in curly braces {}. You can call the function by using its name followed by parentheses ().

@fn hello() {
    print("my new function")
}

hello()

Error Handling

Error handling in ExpressL uses attempt...rescue syntax. You can wrap code in an attempt block and catch errors with a rescue block.

@fn try(x, y) {
   attempt {
        let result = x + y;
        print(result)
   } rescue {
        print(error)
   }
}

print(try(10, 5))

conditional statements

Conditions in ExpressL use when...otherwise syntax. provide conditions using when keyword and provide an alternative using the otherwise keyword. In this example, the nested when...otherwise block acts as an else if structure

when (x > 10) {
    print("x is greater than 10")
} otherwise {
    when (x < 10) {
        print("x is less than 10")
    } otherwise {
        print("x is equal to 10")
    }
}

About

This is a custom programming language

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published