8000 GitHub - zakuro9715/cotowali: A statically typed script language that transpile into POSIX sh
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

zakuro9715/cotowali

 
 

Repository files navigation

Cotowali

A statically typed scripting language that transpile into POSIX sh

License: MPL 2.0

This project is Work in Progress. First release is planned for later 2021.

Concepts of Cotowali

  • Outputs shell script that is fully compliant with POSIX standards.
  • Simple syntax.
  • Simple static type system.
  • Syntax for shell specific feature like pipe and redirection.

Example

fn fib(n: int): int {
  if n < 2 {
    return n
  }
  return fib(n - 1) + fib(n - 2)
}

fn int |> twice() |> int {
   var n = 0
   read(&n)
   return n * 2
}

assert(fib(6) == 8)
assert((fib(6) |> twice()) == 16)

fn ...int |> sum() |> int {
  var v: int
  var res = 0
  while read(&v) {
    res += v
  }
  return res
}

fn ...int |> twice_each() |> ...int {
  var n: int
  while read(&n) {
    yield n * 2
  }
}

assert((seq(3) |> sum()) == 6)
assert((seq(3) |> twice_each() |> sum()) == 12)

// Call command by `@command` syntax with pipeline operator
assert(((1, 2) |> @awk('{print $1 + $2}')) == '3')

There is more examples

Installation

Use Konryu (official installer)

WIP

Build from source

  1. Install required tools

  2. Build

    z build
    
  3. Install

    sudo z symlink
    # or
    sudo z install
    

How to use

# compile
lic examples/add.li

# execution
lic examples/add.li | sh
# or
lic run examples/add.li

Development

See docs/development.md

Docker

docker compose run dev

Author

zakuro <z@kuro.red>

Acknowledgements

Cotowali is supported by 2021 Exploratory IT Human Resources Project (The MITOU Program by IPA: Information-technology Promotion Agency, Japan.

About

A statically typed script language that transpile into POSIX sh

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • V 98.3%
  • Verilog 0.7%
  • GLSL 0.4%
  • Dockerfile 0.3%
  • Shell 0.2%
  • Vim Script 0.1%
0