dwarf is a typed, interpreted, language that shares syntax with Rust.

Related tags

Command-line dwarf
Overview

Build Status codecov Lines of Code

The dwarf Programming Language

dwarf is a programming language based heavily upon, and implemented in, Rust. The language is interpreted (and slow) with a VM (fast-ish) on the way.

There is a book 📒 in progress. Check it out!

Nota Bene: This is a work in progress. The parser is pretty good, but not perfect, at recognizing the language. However, the errors that it reports aren't always useful.

I appreciate feedback. Let me know if you love it, or hate it. There are likely as not bugs, and corner cases. File a bug report, and let me know.

Installation

The easiest thing to do is to download a release.

⚠️ Linux Build Problem: I'm having some issues compiling a dependency on linux.

The next easiest thing to do is to clone the repo and build it yourself. Of course you'll need to have rust installed .

git clone https://github.com/uberFoo/dwarf.git
cd dwarf
cargo install --path . --bin dwarf`

Once you have a binary, give it a whirl:

dwarf https://raw.githubusercontent.com/uberFoo/dwarf/develop/mandelbrot.tao -- 50

Beautiful Error Messages!

error

Check out ariadne and you too can have cool error messages!

Goals

  • Typed, interpreted DSL
  • Easily embeddable
  • Rust-like syntax

Non-Goals

  • Interpreter / debugger performance
  • 100% Rust feature / syntax parity

On the Horizon

These are the thins that spring to mind when I think of what I'd most like to do next with dwarf. In no particular order:

  • VSCode integration
  • Multiple files (use items)
  • enums
  • lambdas
  • Compiler for VM
  • Visibility modifiers
  • Generics
  • Macros (Yes, and I don't know why other interpreted languages don't have them. Am I crazy?)
  • Extensions via plugins
  • Char type
  • if let expressions
  • Doc Comments, with Doc Tests

Supertype / subtype hierarchies

There will be some sort of support for OO-like behavior. Minimally we need inheritance, and probably polymorphism.

Virtual Machine

There's a sort-of hybrid-VM currently, but no compiler.

Syntax

dwarf syntax is a strict subset of Rust's. In fact, I use the Rust language syntax parser in vscode to highlight, navigate, and edit Dwarf source.

The bits that are missing include iterators, enumerations, paths, visibility modifiers, generics (for now), and the list goes on.

REPL

Debugger

Architecture

Parser

There is a hand written parser that takes care of turning the source into an AST. The parser is great at parsing good code, and terrible and everything else. Fixing this is on my todo list.

Compiler

The AST is "compiled" into an in-memory representation that is comprised of the generated code. It's a model, and I should probably include pictures, or some way to look at it, despite it's terrible layout. The model looks like a standard UML class diagram, and it may as well be. I sort of turn it sideways and treat it as an AST.

So what the compiler really does is translate one AST into another. It really does more than that though. It resolves as much type information as it can. It resolves names. It may do more, I'll have to look.

Interpreter

After the compiler comes the interpreter. It reads the model/AST and executes it. I think that the default is to execute a main function.

If you start in the REPL, you get the execution in a loop.

Debugger

License

dwarf is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE, LICENSE-MIT for details.

You might also like...
Fully-typed global state management with a topics subscription system for Dioxus 🧬

dioxus-radio 📡🦀 ⚠️ Work in progress !! ⚠️ . Fully-typed global state management with a topics subscription system for Dioxus 🧬. Who is this for You

Use LLMs to generate strongly-typed values

Magic Instantiate Quickstart use openai_magic_instantiate::*; #[derive(MagicInstantiate)] struct Person { // Descriptions can help the LLM unders

Costless typed identifiers backed by UUID, with kind readable in serialized versions

Why kind ? With kind, you use typed identifiers in Rust, with no overhead over Uuid have the type be human readable and obvious in JSON and any export

Rust syntax in Turkish
Rust syntax in Turkish

pas pas (Turkish for Rust) allows to write Rust programs in Turkish, using Turkish keywords and function names, adapted from the original French imple

A syntax highlighter for Node powered by Tree Sitter. Written in Rust.

tree-sitter-highlight A syntax highlighter for Node.js powered by Tree Sitter. Written in Rust. Usage The following will output HTML: const treeSitter

🌴 Syntax highlighting in Rust.

🌴 HL (WIP) Syntax highlighting written in Rust. The project is designed to generate html syntax highlighting for the given file. This software is ins

Fast, minimal, feature-rich, extended formatting syntax for Rust!

Formatting Tools Fast, minimal, feature-rich, extended formatting syntax for Rust! Features include: Arbitrary expressions inside the formatting brace

Rust regex in ECMAScript regular expression syntax!

ecma_regex The goal of ecma_regex is to provide the same functionality as the regex crate in ECMAScript regular expression syntax. Reliable regex engi

Build Abstract Syntax Trees and tree-walking models quickly in Rust.

astmaker Build Abstract Syntax Trees and tree-walking models quickly in Rust. Example This example creates an AST for simple math expressions, and an

Comments
  • Missing Goals

    Missing Goals

    Since discovering this newly launched language, I've been thrilled with its potential and its unique features. Unfortunately, one important detail that seems to be missing from the README file is the set of goals for the language. Could the developers perhaps add a section that outlines these goals, as this would provide potential contributors and users with a clearer understanding of the project's direction and intentions? Knowledge of these objectives would be particularly beneficial for those considering contributing to the project.

    In order to facilitate this, perhaps a brief discussion among the core team could help define these goals. This way, everyone involved in the project would have a comprehensive understanding of the overall vision and where they can contribute most effectively. Thanks for considering this suggestion!

    opened by makopov 1
  • Closure Type Inference

    Closure Type Inference

    The lambda.tao test contains the following bit of code:

    runner(|| {
        chacha::assert_eq(answer, 42);
        // This is pretty lame. I think the extent of the type checking machinery
        // is going to need to be updated.
        answer as int = 69;
    });
    

    That last line bothers me, as the comment indicates.

    type inference 
    opened by uberFoo 0
Owner
Keith Star
Eat, sleep, hack.
Keith Star
🪂 SkyFolder shares your folders on the network!

Skyfolder Easily share your files & folders on the network. Security, Simplicity, Style all built in. It's like your own personal Google Drive! Skyfol

null 20 May 29, 2023
Reflection via DWARF.

deflect [EXPERIMENTAL] Deflect brings reflection to Rust using DWARF debug info. Deflect can be used to recover the concrete types of trait objects, i

Jack Wrenn 206 Jan 5, 2023
Synthia is a lightweight and beginner-friendly interpreted programming language developed in Rust

Synthia is a lightweight and beginner-friendly interpreted programming language developed in Rust. With a simple, intuitive syntax and a focus on ease of use, Synthia is perfect for both newcomers to programming and experienced developers looking for a flexible scripting language

Shiva 3 Oct 5, 2023
Count your code by tokens, types of syntax tree nodes, and patterns in the syntax tree. A tokei/scc/cloc alternative.

tcount (pronounced "tee-count") Count your code by tokens, types of syntax tree nodes, and patterns in the syntax tree. Quick Start Simply run tcount

Adam P. Regasz-Rethy 48 Dec 7, 2022
A C-like programming language that is similar to Rust's syntax. Toy programming language.

CRUST This is a hobby project to learn about compilers and language design. I've designed the language to be similar to C and Rust. Heavily inspired b

Mahmoud Almontasser 50 Jul 13, 2024
Interpreted, optimized, JITed and compiled implementations of the Brainfuck lang.

Interpreted, Optimized, JITed and Compiled Brainfuck implementations This repo contains a series of brainfuck implementations based on Eli Bendersky b

Rodrigo Batista de Moraes 5 Jan 6, 2023
A statically typed language that can deeply improve the Python ecosystem

The Erg Programming Language This is the main source code repository for Erg. This contains the compiler and documentation. 日本語 | 简体中文 | 繁體中文 Erg can

The Erg Programming Language 2.1k Jan 1, 2023
Notes on learning the Rust programming language syntax.

notes-on-rust Notes on learning the Rust programming language syntax. Resources https://www.rust-lang.org/learn/get-started https://doc.rust-lang.org/

Fred Snyder 1 Jan 2, 2022
*slaps roof of [programming language]* this bad boy can fit so much [syntax sugar] into it

An attempt to give myself a new Pareto-optimal choice for quick-and-dirty scripts, particularly when I'm not on a dev computer, and to practice writin

Brian Chen 985 Apr 25, 2023
Fully-typed, async, reusable state management and synchronization for Dioxus 🧬

dioxus-query ?? ⚡ Fully-typed, async, reusable state management and synchronization for Dioxus ??. Inspired by TanStack Query. ⚠️ Work in progress ⚠️

Marc Espín 9 Aug 7, 2023