From 2975705ae4e409a7c9e66c224c65a5dad498c0a2 Mon Sep 17 00:00:00 2001 From: Florian Greiner Date: Thu, 23 Sep 2021 04:02:42 +0200 Subject: [PATCH 1/2] Add scripts for replacer actions --- .github/templates/Cargo.toml | 30 ++++++++++ .github/templates/README.md | 103 ++++++++++++++++++++++++++++++++++ .github/templates/replacer.sh | 8 +++ .github/version | 1 + 4 files changed, 142 insertions(+) create mode 100644 .github/templates/Cargo.toml create mode 100644 .github/templates/README.md create mode 100755 .github/templates/replacer.sh create mode 100644 .github/version diff --git a/.github/templates/Cargo.toml b/.github/templates/Cargo.toml new file mode 100644 index 00000000..73b2e981 --- /dev/null +++ b/.github/templates/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "rock" +version = "{version}" +authors = ["champii "] +edition = "2018" + +[dependencies] +clap = "2.32.0" +lazy_static = "1.2.0" +regex = "1" +env_logger = "0.5.12" +log = "0.4" +bitflags = "1.2.1" +concat-idents = "1.1.2" +# inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "master", features = ["llvm11-0"] } +inkwell = { version = "0.1.0-beta.3", features = ["llvm12-0"] } +either = "1.5" +serde = "*" +serde_derive = '*' +bincode = "*" +colored = "2.0.0" +paste = "1.0.5" + +[lib] +name = "rock" +path = "src/lib/rock.rs" + +[[bin]] +name = "rock" +path = "src/bin/main.rs" diff --git a/.github/templates/README.md b/.github/templates/README.md new file mode 100644 index 00000000..072814c8 --- /dev/null +++ b/.github/templates/README.md @@ -0,0 +1,103 @@ +# Rock {version} + +[![Rust](https://github.com/Champii/Rock/actions/workflows/rust.yml/badge.svg?branch={branch})](https://github.com/Champii/Rock/actions/workflows/rust.yml) + +Little toy language made with Rust and LLVM. +Aim to follow the Rust model with enforced safeness with a borrow checker and native performances thanks to LLVM. +It's highly inspired from Livescript, and will borrow (pun intended) some features and syntaxes from Crystal, from functional languages like Haskell, or even from Rust itself. + +# VTable +- [Features]( #features ) +- [Development notes]( #development-notes ) +- [Install]( #install ) + - [Using released binary]( #using-released-binary ) + - [With cargo from Git]( #with-cargo-from-git ) + - [From sources]( #from-sources ) +- [Quickstart]( #quickstart ) + +## Features + +- Strongly typed +- Type inference +- Custom operators +- Typeclass (Traits) +- Parametric Polymorphism by default +- Compile to LLVM IR + +## Development notes + +This project, its syntax and its APIs are subject to change at any moment. +This is a personal project, so please bear with me +(Differently put: this is a big red hot pile of experimental garbage right now) + +## Install + +How to install and run the compiler: + +### Using released binary + +[Rock {version}](https://github.com/Champii/Rock/releases/download/{version}}/rock) (Tested on arch linux) + +``` sh +wget https://github.com/Champii/Rock/releases/download/{version}/rock +chmod +x rock +./rock -V +``` + +### With cargo from git + +``` sh +cargo install --git https://github.com/Champii/Rock +rock -V +``` + +### From sources + +``` sh +git clone https://github.com/Champii/Rock.git +cd Rock +cargo run -- -V +``` + +## Quickstart + +Lets create a new project folder to compute some factorials + +``` sh +mkdir -P factorial/src && cd factorial +``` + +Add some files like this: + +- Copy the std lib files from [std](https://github.com/Champii/Rock/blob/master/std/src) into `./src/` + +- Create a `./src/main.rk` file: + +```haskell +mod lib + +use lib::prelude::* + +# Polymophic function +id a = a + +fact a = + if a <= 1 + then 1 + else a * fact (a - 1) + +main = print fact id 4 +``` + +Assuming that you built Rock and put its binary in your PATH: + +``` sh +rock run +``` + +Should output + +``` sh +24 +``` + diff --git a/.github/templates/replacer.sh b/.github/templates/replacer.sh new file mode 100755 index 00000000..0649d12e --- /dev/null +++ b/.github/templates/replacer.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail + +cp ./.github/templates/README.md . +sed "s/{version}/${NEW_VERSION}/g" README.md + +cp ./.github/templates/Cargo.toml . +sed "s/{version}/${NEW_VERSION}/g" Cargo.toml diff --git a/.github/version b/.github/version new file mode 100644 index 00000000..8c43fb43 --- /dev/null +++ b/.github/version @@ -0,0 +1 @@ +v0.1.4 From c31ec55f802ce043091e0dc0198513e7466f270f Mon Sep 17 00:00:00 2001 From: Champii Date: Thu, 23 Sep 2021 04:05:06 +0200 Subject: [PATCH 2/2] Create generator.yml --- .github/workflows/generator.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/generator.yml diff --git a/.github/workflows/generator.yml b/.github/workflows/generator.yml new file mode 100644 index 00000000..6bba59fe --- /dev/null +++ b/.github/workflows/generator.yml @@ -0,0 +1,17 @@ +name: Generator + +on: + create + +jobs: + replace: + runs-on: ubuntu-latest + name: Generate Readme. + env: + VERSION: $(cat .github/version) + NEW_VERSION: $VERSION-$GITHUB_REF + + steps: + - uses: actions/checkout@v2 + - name: Generate replacers + run: ./.github/templates/replacer.sh