All Projects → gonzula → Splash

gonzula / Splash

Licence: gpl-3.0
Simple Programming LAnguage for SHortcuts

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Splash

C3c
Compiler for the C3 language
Stars: ✭ 178 (-7.29%)
Mutual labels:  compiler
Philip2
An Elm to OCaml compiler
Stars: ✭ 182 (-5.21%)
Mutual labels:  compiler
Minijit
A basic x86-64 JIT compiler written from scratch in stock Python
Stars: ✭ 185 (-3.65%)
Mutual labels:  compiler
Potigol
Linguagem Potigol - Linguagem de programação funcional moderna para iniciantes - A Functional Programming Language for Beginners
Stars: ✭ 179 (-6.77%)
Mutual labels:  compiler
Varjo
Lisp to GLSL Language Translator
Stars: ✭ 181 (-5.73%)
Mutual labels:  compiler
Veriloggen
Veriloggen: A Mixed-Paradigm Hardware Construction Framework
Stars: ✭ 182 (-5.21%)
Mutual labels:  compiler
Command Block Assembly
Compile high-level code into Minecraft commands
Stars: ✭ 175 (-8.85%)
Mutual labels:  compiler
El Compilador
An SSA-based compiler for Emacs Lisp
Stars: ✭ 187 (-2.6%)
Mutual labels:  compiler
Whileycompiler
The Whiley Compiler (WyC)
Stars: ✭ 181 (-5.73%)
Mutual labels:  compiler
Mlkit
Standard ML Compiler and Toolkit
Stars: ✭ 183 (-4.69%)
Mutual labels:  compiler
Rubyspeed
Compile ruby functions to C
Stars: ✭ 180 (-6.25%)
Mutual labels:  compiler
Snapdragon
snapdragon is an extremely pluggable, powerful and easy-to-use parser-renderer factory.
Stars: ✭ 180 (-6.25%)
Mutual labels:  compiler
Appfairy
A CLI tool to Migrate a Webflow project into a React app
Stars: ✭ 183 (-4.69%)
Mutual labels:  compiler
Go.vm
A simple virtual machine - compiler & interpreter - written in golang
Stars: ✭ 178 (-7.29%)
Mutual labels:  compiler
Hybridizer Basic Samples
Examples of C# code compiled to GPU by hybridizer
Stars: ✭ 186 (-3.12%)
Mutual labels:  compiler
Wag
WebAssembly compiler implemented in Go
Stars: ✭ 177 (-7.81%)
Mutual labels:  compiler
Tampio
Tampio: An object-oriented programming language made to resemble Finnish
Stars: ✭ 181 (-5.73%)
Mutual labels:  compiler
Lhc
The LLVM LHC Haskell Optimization System
Stars: ✭ 188 (-2.08%)
Mutual labels:  compiler
Faerie
Magical ELF and Mach-o object file writer backend
Stars: ✭ 187 (-2.6%)
Mutual labels:  compiler
Prototype
(deprecated) The journey continues at ASNEXT: https://github.com/AssemblyScript/assemblyscript
Stars: ✭ 2,114 (+1001.04%)
Mutual labels:  compiler

SPLASH : Simple Programming LAnguage for SHortcuts

splash icon AppStore badge

The first real programming language that compiles to Apple's Shortcuts.app

What it is

Although the Shortcuts app is designed for non programmers/beginners, it's programming interface is similar to assembly in the meaning that very simple expressions need dozens of blocks.

To solve this problem, SPLASH is being developed as a programming language designed for non programmers/beginners that compiles directly to shortcuts.

Example GIF

For what it's worth

Splash is meant to reduce substantially the manual labor, improve readability and maintainability of shortcuts. It's still under development but with a few fully working features. Between them:

  • Complex mathematical expressions
  • Flow control (ifs and elses)
  • String interpolation (variables inside a string)

And those are some of the features in the backlog:

  • Loops
  • Functions declarations

How it works

The programming language

The best way to learn is with some examples

Here's an example splash program that given an age tells the person's stage of life.

shortcut file

video of the shortcut

age := AskNumber()  # The ':=' stores the right side expression
                    # on the left side variable

                    # And AskNumber() asks the user for a number input
                    # when the shortcut is running

if age < 12 {
    ShowResult("Child")
} else if age < 18 {  # Blocks of code are surrounded by '{' and '}'
    ShowResult("Teen")
} else if age < 60 {
    ShowResult("Adult")
} else {
    ShowResult("Elder")
}

# And comments are preceded by '#'

Here's an example with more advanced expressions that solves any quadratic expression in the form ax² + bx + c = 0

shortcut file

video of the shortcut

a := AskNumber()
b := AskNumber()
c := AskNumber()

delta := b^2 - 4 * a * c  # a^b is a to the b power

if a == 0 {
    x := -c/b

    answer := "x = {x}"  # This is a string interpolation
                         # It resolves to "x = (value of variable x)"
} else if delta == 0 {  # '==' tests for equality
    x := -b / (2 * a)

    answer := "x1 = x2 = {x}"
} else if delta > 0 {
    x1 := (-b + delta^(1/2))/(2 * a)
    x2 := (-b + -delta^(1/2))/(2 * a)

    answer := "x1 = {x1}\nx2 = {x2}"
} else {
    xr := -b / (2 * a)
    xi := (-delta)^(1/2) / (2 * a)
    nxi := -xi

    answer := "x1 = {xr} + {xi}i\nx2 = {xr} + {nxi}i"
}

ShowResult(answer)  # ShowResult shows an alert with the
                    # value passed inside the parenthesis

And a last example that tells if an year is a leap year:

shortcut file

video of the shortcut

year := AskNumber()

if year % 4 > 0 {  # The % symbol performs the modulo operation
    leap := 0
} else if year % 100 > 0 {  # And, diffently from shortcuts,
                            # you can have math expressions in
                            # the comparison
    leap := 1
} else if year % 400 > 0 {  # So this line checks if year is divisible by 400
    leap := 0
} else {
    leap := 1
}

if leap == 0 {
    type := "common"
} else {
    type := "leap"
}

ShowResult("{year} is a {type} year")

How to get started

You can use this language on your iOS device by downloading the app from the App Store or cloning this repo and compiling it on your Xcode. (You will need an Apple Developer account)

Or you can compile the compiler on your computer. It's pure C code, without any dependencies, so it works on any operating system.

Installing the app via Xcode

You will need to have installed bison installed.

brew install bison
ln -s /usr/local/opt/bison/bin/bison /usr/local/bin/bison

And then it's just a matter of building the Xcode project

Compiling the Compiler

The easy way

Download the compiled version from the latest release

linux version

macOS version

and run

chmod +x splash

Compiling from source

You can compile the splash compiler from source, cloning this repo and running make. You will need bison, flex and a C compiler

On macOS you can install the dependencies with homebrew:

brew install bison
ln -s /usr/local/opt/bison/bin/bison /usr/local/bin/bison

On ubuntu:

sudo apt install bison flex gcc

How to run

On a terminal window located at the folder you installed splash

./splash input_file output_file

The splash compiler adds a .shortcut extension to output_file that is required by the shortcuts app.

Also, the name of that output file is the display name of your shortcut.

How to import the shortcuts

The easiest way is to airdrop the .shortcut file to your device.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].