All Projects → calcit-lang → calcit_runner.rs

calcit-lang / calcit_runner.rs

Licence: other
Lisp compiling to JavaScript ES Modules

Programming Languages

rust
11053 projects
Cirru
14 projects
typescript
32286 projects

Projects that are alternatives of or similar to calcit runner.rs

dirgen
Generate files and folders from a template file
Stars: ✭ 21 (-72%)
Mutual labels:  indentation
Common Tags
🔖 Useful template literal tags for dealing with strings in ES2015+
Stars: ✭ 1,761 (+2248%)
Mutual labels:  indentation
indent.js
Pure code indentation for jsx, tsx, ts, js, html, css, less, scss.
Stars: ✭ 55 (-26.67%)
Mutual labels:  indentation
babel-plugin-dedent
Remove indentation from multiline template strings
Stars: ✭ 32 (-57.33%)
Mutual labels:  indentation
nvim-yati
Yet another tree-sitter powered indent plugin for Neovim.
Stars: ✭ 60 (-20%)
Mutual labels:  indentation
deep-learning-for-indentation
Extraction of mechanical properties of materials through deep learning from instrumented indentation
Stars: ✭ 35 (-53.33%)
Mutual labels:  indentation
Pyxell
Multi-paradigm programming language compiled to C++, written in Python.
Stars: ✭ 42 (-44%)
Mutual labels:  indentation
vscode-blockman
VSCode extension to highlight nested code blocks
Stars: ✭ 233 (+210.67%)
Mutual labels:  indentation
unindent
Report code that is unnecessarily indented
Stars: ✭ 18 (-76%)
Mutual labels:  indentation
LuaExtended
An improved ST3 Lua syntax definition.
Stars: ✭ 19 (-74.67%)
Mutual labels:  indentation
ogrep-rs
Outline grep — search in indentation-structured texts (Rust version)
Stars: ✭ 32 (-57.33%)
Mutual labels:  indentation
node-ts-dedent
TypeScript package which smartly trims and strips indentation from multi-line strings
Stars: ✭ 119 (+58.67%)
Mutual labels:  indentation
flex-bison-indentation
An example of how to correctly parse python-like indentation-scoped files using flex (and bison).
Stars: ✭ 32 (-57.33%)
Mutual labels:  indentation
vim-stylus
A better vim plugin for stylus, including proper and up-to-date syntax highligting, indentation and autocomplete
Stars: ✭ 49 (-34.67%)
Mutual labels:  indentation

Calcit Scripting Language

Semantically a dialect of ClojureScript. Built with Rust. Compiles to JavaScript ES Modules.

Browse examples or also try WASM version online.

Core design:

  • Interpreter runs on Rust, extensible with Rust FFI
  • Persistent Data Structure
  • Structural Editor(with indentation-based syntax as a fallback)
  • Lisp macros, functional style
  • Compiles to JavaScript in ES Modules, JavaScript Interop
  • Hot code swapping friendly

Install

Build and install with Rust:

# get Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# get Calcit
cargo install calcit

3 binaries are installed:

  • calcit, the runtime and js compiler
  • caps, for downloading dependencies declared in package.cirru
  • bundle_calcit, bundle code if you don't want to use Calcit Editor

For Ubuntu latest, try binaries from Releases, which are provided for CI usages.

Usage

Snippets evaling:

cr -e 'range 100'

multi-lines snippet:

cr -e '

println "|a demo"

->
  range 100
  map $ fn (x)
    * x x

'

Run with a compact.cirru:

cr compact.cirru -1 # run only once

cr compact.cirru # watch mode enabled by default

By default Calcit reads :init-fn and :reload-fn inside compact.cirru configs. You may also specify functions,

cr compact.cirru --init-fn='app.main/main!' --reload-fn='app.main/reload!'

and even configure :entries in compact.cirru:

cr compact.cirru --entry server

JavaScript codegen

It compiles to JavaScript and runs in consistet semantics. However it might require a lot of JavaScript interop.

cr compact.cirru --emit-js # compile to js
cr compact.cirru --emit-js --emit-path=out/ # compile to js and save in `out/`

By default, js code is generated to js-out/. You will need Vite or Node to run it, from an entry file:

import { main_$x_, reload_$x_ } from "./js-out/app.main.mjs";
main_$x_();

Calcit Editor & Bundler

Install Calcit Editor and run ct to launch editor server, which writes compact.cirru and .compact-inc.cirru on saving. Try launching example by cloning Calcit Workflow.

Read more in Minimal Calcit to learn how to code Calcit with a plain text editor.

Read more in Respo Calcit Workflow to learn to create an MVC webpage with Respo.

Modules

package.cirru declares dependencies that need to download, which correspond to repositories on GitHub. Specify a branch or a tag:

{}
  :dependencies $ {}
    |calcit-lang/memof |0.0.11
    |calcit-lang/lilac |main

Run caps to download. Sources are downloaded into ~/.config/calcit/modules/. If a module contains build.sh, it will be executed mostly for compiling Rust dylibs.

To load modules, use :modules configuration in calcit.cirru and compact.cirru:

:configs $ {}
  :modules $ [] |memof/compact.cirru |lilac/

Paths defined in :modules field are just loaded as files from ~/.config/calcit/modules/, i.e. ~/.config/calcit/modules/memof/compact.cirru.

Modules that ends with /s are automatically suffixed compact.cirru since it's the default filename.

Development

I use these commands to run local examples:

# run tests in Rust
cargo run --bin cr -- calcit/test.cirru -1

# run tests in Node.js
cargo run --bin cr -- calcit/test.cirru --emit-js -1 && yarn try-js

# run snippet
cargo run --bin cr -- -e 'range 100'

cr compact.cirru --emit-ir # compiles intermediate representation into program-ir.cirru

Other tools:

Some resources:

License

MIT

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].