From bddb011df4999f7ffeeddf6a4b66e2da6ab19ea0 Mon Sep 17 00:00:00 2001 From: Cody Date: Thu, 15 Dec 2022 13:23:48 -0600 Subject: Initial language designs & lexer from crafting interpreters The very initial language designs I came up with for Sloth. Likely contains inconsistencies and definitely contains things that will be changed in the future. This is basically just a dump of every idea I've had for the language thus far. As for the lexer right now it is heavily based on the one from the Crafting Interpretrs book and doesn't yet parse Sloth grammar. --- tour/tooling.sloth | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 tour/tooling.sloth (limited to 'tour/tooling.sloth') diff --git a/tour/tooling.sloth b/tour/tooling.sloth new file mode 100644 index 0000000..74a74fe --- /dev/null +++ b/tour/tooling.sloth @@ -0,0 +1,88 @@ +#!/usr/bin/env sloth + +## Making sure all your imports are correct and lint rules are being followed is +## important. You can do this in sloth using the `--check` flag. +## +## Examples: +## sloth --check file.sloth + +## Testing is important when trying to write resiliant, bug free software. Sloth +## comes with a full featured testing framework built in. In order to test your +## projects you can use the `--test` flag. +## +## Examples: +## sloth --test file.sloth + +## Benchmarking is important to make sure our software is fast. Sloth comes with +## a full featured micro-benchmarking framework built in. In order to benchmark +## your project you can use the `--bench` flag. +## +## With our benchmarking framework you will get 3 responses: +## - cold :: execution time before any code was JIT compiled +## - warm :: execution time after some code was JIT compiled +## - hot :: execution time after all code that can be JIT compiled is JIT +## compiled +## +## Examples: +## sloth --bench file.sloth + +## Maintaining the same code style accross an entire project is important while +## collaborating with others. In order to help with maintining these code styles +## sloth has a built in formatter that can be ran with the `--format` flag. +## +## In addition you can use `--format-mode check` in order to only check if the +## styles are valid, this is useful for CI pipelines. +## +## Examples: +## slock --format file.sloth +## slock --format --format-mode check file.sloth + +## Dealing with dependencies can be a bit of a pain, in order to make it a bit +## easier you can automatically update all dependencies in a project using the +## `--update` flag. This will scan through your project looking for looking for +## any `use extern` statements with an outdated version specified and update them. +## +## Examples: +## slock --update file.sloth + +## In order to push to canopy (the package repository) your dependencies must +## be locked to a specific version. In order to do this easily you can use the +## `--lock` flag. This will scan through your project looking for any `use extern` +## statements without a version specified and automatically specify the latest +## version. +## +## Examples: +## sloth --lock file.sloth + +## Publishing sloth packages to canopy can be done in 3 days, from the site by +## uploading a zip, from the site from a git repo or using the CLI. It can be +## done through the CLI using the `--publish` flag. +## +## Examples: +## sloth --publish file.sloth + +## If you wish to ahead of time compile your sloth code you can do so with the +## `--aot` flag. By default this will ahead of time compile to your platform +## however you can optionally specify one using the `--aot-target` flag. +## +## Limitations: +## - AOT compilation requires strict mode +## +## Examples: +## sloth --aot file.sloth +## sloth --aot --aot-target wasm file.sloth + +# Easily write tests with the test and assert keywords +test "add function" { + assert add(5, 5) == 10; + assert add(10, 5) == 15; + assert add(10, 5) != 10; +} + +# Easily write benchmarks with the bench & prepare keyword +bench "add function" { + # Use the `prepare` keyword to exclude code from the benchmark + prepare client = WebClient::new(); + + client.get("https://example.com"); +} -- cgit v1.2.3