Lisp but using indentations

Overview

Calcit Runner

An interpreter for Calcit snapshot file.

Running Calcit Editor with compact=true caclcit-editor enables compact mode, which writes compact.cirru and .compact-inc.cirru instead of Clojure(Script). And this project provides a runner for compact.cirru, written on Rust for low overhead.

A compact.cirru file can be:

{} (:package |app)
  :configs $ {} (:init-fn |app.main/main!) (:reload-fn |app.main/reload!)
    :modules $ []
  :files $ {}
    |app.main $ {}
      :ns $ quote
        ns app.main $ :require
      :defs $ {}
        |main! $ quote
          defn main! () (+ 1 2)
        |reload! $ quote
          defn reload! ()

APIs implemented in Calcit Runner is mostly learning from Clojure. Major difference arguments order of list functions.

Usage

Run:

cargo run calcit/compact.cirru

# evaluate

cr compact.cirru --once # run only once
cr compact.cirru # watch mode enabled by default

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

cr -e="range 100" # eval from CLI

# emit code

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

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

cr compact.cirru --emit-js --mjs # TODO compile to mjs

For linux users, download pre-built binaries from http://bin.calcit-lang.org/linux/ .

Bundler

There's also another command for bundling compact.cirru from separated files:

package.cirru
src/
  app.main.cirru
  app.lib.cirru

package.cirru should contain fields like.

{}
  :package |app
  :modules $ []
  :init-fn |app.main/main!
  :reload-fn |app.main/reload!
  :version |0.0.1

and files in src/ are source files of namespace form and definitions. Ny running:

bundle_calcit --src ./src --out ./compact.cirru

a bundled compact.cirru file will be included.

Development

Modules

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

Calcit Runner use ~/.config/calcit/modules/ as modules directory. Paths defined in :modules field are just loaded as files based on this directory, which is: ~/.config/calcit/modules/phlox/compact.cirru.

To load modules in CI environment, create that folder and clone repos manually.

Older version

This interpreter was first implemented in Nim and then switch to Rust. Main change is the order of arguments where operands are now placed at first.

License

MIT

Comments
  • refactor: replace deprecated String.prototype.substr()

    refactor: replace deprecated String.prototype.substr()

    opened by CommanderRoot 3
  • breaking fix parse-cirru on js side

    breaking fix parse-cirru on js side

    To be consistent, parse-cirru should always return data with type :cirru-quote. This is a breaking change t o code that relies on parse-cirru on js side.

    opened by tiye 2
  • add cirru-quote variant for better meta programming

    add cirru-quote variant for better meta programming

    Since Cirru is a syntax for various DSLs, there are many cases we want to embed Cirru inside Calcit code to program other DSLs. To make it convenient and more performance, CirruQuote variant is added into core.

    New APIs:

    • cirru-quote which is a special form are symbol reading phase,
    • parse-cirru-list, which is previously parse-cirru that returns list, so it's breaking change,
    • parse-cirru, which returns CalcitCirruQuote variant.
    • &cirru-quote:to-list, which converts CalcitCirruQuote into Calcit list.

    This is designed to simplify calcit-calx and calcit-wasmtime, and will probably break docs site.

    opened by tiye 1
  • Convert JS Object to Calcit map / JS array to Calcit list

    Convert JS Object to Calcit map / JS array to Calcit list

    I don't see anything in the documentation that allows for the conversion of JS Objects or Arrays to the Calcit map or list. Am I missing something, and if not, is this intended?

    Also, at one point I attempted the above using the parse-json method listed on the API site, but it doesn't appear to be available.

    opened by TheMrAmazing 1
  • new macro tag-match

    new macro tag-match

    tag-match provides arms that matches :tag field in a HashMap and give it a new name:

    tag-match data
      :a new-name-a
        str-spaced "|found branch of" :a "|with value" $ :sth-of-a new-name-a
      :b new-name-b
        str-spaced "|found branch of" :b "|with value" $ :sth-of-b new-name-b
      _ :other
    

    data should match map? data with a field :tag, for example:

    {}
      :tag :a
      :sth-of-a "|some data belongs to a"
    
    opened by tiye 0
  • Fail to run `cr` after `cargo install calcit`

    Fail to run `cr` after `cargo install calcit`

    ❯ cr
    calcit version: 0.6.8
    thread 'main' panicked at 'expected Cirru snapshot: "compact.cirru"', /home/xyh/.cargo/registry/src/github.com-1ecc6299db9ec823/calcit-0.6.8/src/bin/cr.rs:77:70
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    ❯ rustc --version
    rustc 1.64.0 (Arch Linux rust 1:1.64.0-1)
    
    ~
    ❯ cargo --version
    cargo 1.64.0
    
    opened by xieyuheng 0
  • use some mutex

    use some mutex

    inspired https://www.slideshare.net/mitsunorikomatsu/performance-comparison-of-mutex-rwlock-and-atomic-types-in-rust .

    no confirmed change in performance.

    opened by tiye 0
  • handle a special case of variable shadowing

    handle a special case of variable shadowing

    for a case like:

    ; "a special case variable shadowing of `b`"
    let
        b -1
        a $ loop
            xs $ []
            b 0
          if (>= b 5) xs
            recur (conj xs b) (inc b)
      assert= a $ [] 0 1 2 3 4
      assert= b -1
    

    where b is defined both outside and inside, which reused the return_label of loop recursion. but actually it does not forward value, it only returns. the outer context should be unaware for code in bind function.

    opened by tiye 0
Releases(0.6.19)
Owner
Calcit
Lisp but using indentations
Calcit
Lisp-style programming language

Bobbylisp A programming language, syntax are like mal and clojure. This project follow mal guides, Planning to add some more features after finishing

azur 36 Dec 19, 2022
Lisp interpreter that might be fast someday maybe?

ehlisp Pronunciation I'm not really sure. Maybe like an incorrect pronunciation of "ellipse", like "ellisp"? Also maybe like "a lisp". I named it this

Eddie Hatfield 3 Oct 6, 2022
Create a Python project automatically with rust (like create-react-app but for python)

create-python-project Create a Python project automatically with rust (like create-react-app but for python) Installation cargo install create-python-

Dhravya Shah 2 Mar 12, 2022
Easy way to write Node.js module using Rust

node-bindgen Easy way to write native Node.js module using idiomatic Rust Features Easy: Just write idiomatic Rust code, node-bindgen take care of gen

InfinyOn 346 Jan 3, 2023
Safe Rust <---> GraalVM Polyglot bindings using procedural macros

The class macro is the primary way to generate bindings to Java types; it will generate a struct (with generics if specified) that implements Pass and Receive and has all the methods you give stubs for. The methods generated can be used like normal rust methods, however mutability is not enforced. The fully-qualified type name should precede a block containing method and constructor stubs. Java primitives like char, int, and byte are aliased to corresponding Rust types.

Alec Petridis 33 Dec 28, 2022
Rust Lambda using Serverless

Rust Serverless Lambda Template

섹스 신청서 4 May 31, 2022
A Web-App written in Rust with Yew, using the same SyntaxHighlighter from Google Code Archive as planetb.ca

PlanetB SyntaxHighlighter About This is a small app, providing static files to have a frontend to format your code so you can paste it with styles to

Christof Weickhardt 2 Dec 14, 2022
Rust-ffi-guide - A guide for doing FFI using Rust

Using unsafe for Fun and Profit A guide to traversing the FFI boundary between Rust and other languages. A rendered version is available here. This gu

Michael Bryan 261 Dec 1, 2022
Parametric surfaces drawn using the Rust + WASM toolchain with WebGL, React, and TypeScript.

Parametric Surfaces in the Browser My.Movie.3.mp4 Wanted to experiment with WebGL using the Rust + WASM toolchain, with React and TypeScript to glue e

Benji Nguyen 45 Oct 21, 2022
A collection of unsound rust functions using entirly *safe* code

A collection of unsound rust functions using entirly *safe* code

null 2 Sep 6, 2022
Realtime audio processing / synthesis using Rust/WASM in the browser.

Rust Audio About This repo is my investigation into using Rust for creative audio coding on various platforms (e.g. desktop, web, etc.), but especiall

Austin Theriot 30 Jan 5, 2023
call rest api using rust + yew

Call Rest API With Rust and Yew: USA Weather Service API Open Data YEW Complete Tutorial YouTube Video https://youtu.be/dSJULWtd3y0 How to run trunk s

Security Union 8 Dec 23, 2022
Python bindings for akinator-rs using pyo3

Akinator-py python bindings for akinator-rs using pyo3 Installation Prebuilt wheels are uploaded onto pypi, if you platform is supported, you can inst

Tom-the-Bomb 4 Nov 17, 2022
Low level tooling for WebAssembly in JavaScript using wasm-tools

js-wasm-tools js-wasm-tools compiles some of the API of wasm-tools to JavaScript and WebAssembly via wasm-bindgen. This offers low level tooling for W

Dominic Elm 59 Dec 19, 2022
Lua bytecode parser written in Rust using nom, part of metaworm's lua decompiler

luac-parser (中文) lua字节码解析器, 目前支持 lua51, lua53, lua54 这是目前效果最好的lua反编译器 metaworm's luadec 的一部分 可以基于此代码定制你所需的lua字节码解析器,编译成WASM,让metaworm's luadec加载使用,来反编

metaworm 4 Mar 16, 2023
Freeze.rs is a payload toolkit for bypassing EDRs using suspended processes, direct syscalls written in RUST

Freeze.rs More Information If you want to learn more about the techniques utilized in this framework, please take a look at SourceZero Blog and the or

Optiv Security 385 May 9, 2023
A macro to generate constructor to instanicate structs from JsValue using duck-typing.

ducktor ducktor is a Rust crate that allows you to create types from wasm_bindgen::JsValue using duck typing. With ducktor, you can define a struct th

Muhammad Hamza 6 Jun 23, 2023
plugy empowers you to construct agnostic dynamic plugin systems using Rust and WebAssembly.

plugy plugy is a plugin system designed to enable the seamless integration of Rust-based plugins into your application. It provides a runtime environm

Geoffrey Mureithi 22 Aug 12, 2023
RDF playground using WASM-compiled Sophia

SoWasm: an RDF playground based on Sophia This started as an experiment of compiling Sophia into WebAssembly, and grew into a (hopefully) useful playg

Pierre-Antoine Champin 4 Dec 19, 2023