Programming language just for fun, will kill LUA some day.

Related tags

Utilities loom
Overview

Loom

Tests Contributor Covenant License: MIT

Programming language just for fun, will kill LUA some day.

Currently development of this language is algorithm driven. I'm trying to implement various algorithms in my language and then I'm adding missing parts to make them work :D Below you can find Shor's algorithm for finding prime factors of an integer.

Input:

fn gdc(a, b) {
  while(b!=0) {
    t = b;
    b = a % b;
    a = t;
  };
  a
};

fn findPow(x, z) {
  y = 1;
  while (pow(x, y) % z != 1) {
    y = y + 1;
  };
  y
};

fn shor(x) {
  a = 2;
  while (a < x) {
    if (gdc(a,x) == 1) {
      r = findPow(a, x);
      p = gdc(pow(a, r/2) + 1, x);
      q = gdc(pow(a, r/2) - 1, x);
      if (p*q == x) {
        return "[ " + p + ", " + q +" ]";
      };
    };
    a = a + 1;
  };
  ''
};
x = 21;
y = 49;
print("gdc("+x+","+y+") = " + gdc(x,y));
print("shor(15) = " + shor(15));
0

Output:

gdc(21,49) = 7
shor(15) = [ 5, 3 ]

Exited with code: 0

How to run

# cargo run -p cli -- --help

Usage: cli [OPTIONS] <PATH>

Arguments:
  <PATH>  Path to file to run

Options:
  -c, --no-colors  Disable colored output
  -v, --verbose    Enable verbose output
  -h, --help       Print help
  -V, --version    Print version

Code highlights

Tree-sitter parser and highlighting included.

cd tree-sitter-loom
tree-sitter generate
tree-sitter test 

Configuration for NeoVim:

Language server

Repository contains also LSP server for language. For now only simple diagnostics are supported.

NeoVim configuration

Configuration to start development in NeoVim.

filetype

vim.filetype.add({
  extension = {
    lum = 'loom',
  }
})

LSP

local configs = require 'lspconfig.configs'

if not configs.loom then
  configs.loom = {
    default_config = {
      cmd = { '~/Workspace/Loom/target/debug/lsp' },
      root_dir = lspconfig.util.root_pattern('.git'),
      filetypes = { 'loom' },
      name = { 'loom' },
    },
  }
end

lspconfig.loom.setup {}

tree-sitter

local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.loom = {
  install_info = {
    url = "~/Workspace/Loom/tree-sitter-loom", -- path to location 
    files = {"src/parser.c"},
    branch = "main",
    generate_requires_npm = false,
    requires_generate_from_grammar = false,
  },

  filetype = "loom",
}
vim.treesitter.language.register('loom', 'loom')  

Loading new tree-sitter config in nvim:

:TSUpdate

License

MIT License

Copyright (c) 2023 Mateusz Russak

You might also like...
A formal, politely verbose programming language for building next-gen reliable applications

vfpl Pronounced "Veepl", the f is silent A politely verbose programming language for building next-gen reliable applications Syntax please initialize

Cookiecutter templates for Serverless applications using AWS SAM and the Rust programming language.

Cookiecutter SAM template for Lambda functions in Rust This is a Cookiecutter template to create a serverless application based on the Serverless Appl

The compiler of the okta programming language.
The compiler of the okta programming language.

oktac The compiler of the okta programming language. For more information please visit the official website, and to quickly get okta running refer to

Aws-sdk-rust - AWS SDK for the Rust Programming Language

The AWS SDK for Rust This repo contains the new AWS SDK for Rust (the SDK) and its public roadmap. Please Note: The SDK is currently released as a dev

⚙️ Crate to discover embedded programming with uno r3 project

⚙️ Crate to discover embedded programming with uno r3 project

Language Integrated Query in Rust.

Linq in Rust Language Integrated Query in Rust (created by declarative macros). Inspired by LINQ in .NET. What's LINQ This project is under developmen

in progress pretty printing calculator language
in progress pretty printing calculator language

in progress pretty printing calculator language

Rust language bindings for Bitcoin secp256k1 library.

Full documentation rust-secp256k1 rust-secp256k1 is a wrapper around libsecp256k1, a C library by Pieter Wuille for producing ECDSA signatures using t

lipsum-cli is a small terminal application written in Rust language.

lipsum-cli is a small terminal application written in Rust language. It's used for generating pseudo-Latin lorem ipsum filler text in terminal.

Owner
Mateusz Russak
Mateusz Russak
Type-check non-existing `Phantom` code for Fun And Profit

Sometimes you may want to write Rust code that ought to be type-checked (e.g., borrow-checked) in the same fashion as real Rust code even though that code is never intended to be run / to affect or even reach code generation.

Daniel Henry-Mantilla 4 Jun 5, 2022
File Tree Fuzzer allows you to create a pseudo-random directory hierarchy filled with some number of files.

FTZZ File Tree Fuzzer allows you to create a pseudo-random directory hierarchy filled with some number of files. Installation $ cargo +nightly install

Alex Saveau 22 Dec 28, 2022
Replay git history with some tweaks

Git-replay Overview Git-replay is a simple tool that replays the history of a Git repository but with some tweaks (i.e., it can change the author name

Tak-gun Na 3 Mar 22, 2022
The rust implementation of IPLD schemas and some associated functionalities.

Linked Data IPLD schemas and what to do with them. Beacon Directory of user content and metadata. Since this object should not change it can be used a

Defluencer 3 Mar 4, 2022
Ditch your status bar for some snazzy desktop notifications.

citron Ditch your panel for some snazzy desktop notifications. citron is: a non-intrusive alternative to status bars. on-demand, i.e. does not run in

Aziz Ben Ali 1 Jan 11, 2022
Creating CLI's just got a whole lot better.

Staq Creating CLI's just got a whole lot better. Don't worry about CLI colouring, networking, Size of Executables, Speed ever again Have any doubts? R

null 12 Jun 6, 2021
tri-angle trader without trade, just watch pair's price change, print arbtrage chance.

tri-angle trader without trade, just watch pair's price change, print arbtrage chance.

铁哥 5 Nov 19, 2022
For when you really, really just want to know that your config changed

really-notify This crate is for when you really, really just want to know that your config changed. K8s configmap symlink shenanigans? No problem. Mul

Max Bruce 13 Jun 20, 2023
Fegeya Gretea (aka green tea), new generation programming language.

Fegeya Gretea Gretea (aka green tea), new generation programming language. A taste of Gretea's syntax: import tea.green.fmt module hello { fn hel

Ferhat Geçdoğan 13 Sep 28, 2022
An experimental programming language for exploring first class iterators.

An experimental programming language for exploring first class iterators.

Miccah 4 Nov 23, 2021