Skip to content

Bqrry4/cyqra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cyqra

Cyqra [/ˈsiːkrə/] - is an experimental shell language that aims to seamlessly unify shell scripting and functional programming into a single coherent syntax.

Features

Warning

Cyqra is still in early development. Its syntax and features are subject to change.

The following are the core features established so far:

Variables

let x = 4
# shadowing - x is rebound, not reassigned
let x = "hello"       # x is now a string, the int is gone
echo $x               # "hello"

String interpolation

let name = "world"
echo "Hello ${name}"        # ${ } for expressions
echo "hello $name"           # $ident shorthand
echo "result: ${1 + 2 * 3}"  # arbitrary expressions inside

Functions

fn greet(name) {
   return "hello, ${name}!"
}
# last expression is the implicit return value
fn add(a, b) { a + b }

Hybrid syntax

greet("World")    #a function style call
greet World        # a shell style call
greet ("World")   # a shell style call with first arg as an expression
# same applies to external commands
echo("World")
echo World
echo ("World")

Cyqra disambiguates shell calls from expressions based on whether the name has been declared. If unknown, the name is treated as a shell command and everything after it becomes arguments. Consider the following:

echo - echo # echo is unknown -> shell call -> passes "- echo" as args
let echo = 366
echo - echo # echo is a variable -> arithmetic -> 366 - 366 = 0

Note

Grab the latest nightly build from Releases to try it out.

About

An experimental functional shell language (WIP)

Resources

License

Stars

Watchers

Forks

Contributors