A Modal implementation and web frontend

4ecf648 build.zig.zon: Sort paths

~smlavine pushed to ~smlavine/zm git

a month ago

c99fc7d Integrate the Zig build system

~smlavine pushed to ~smlavine/zm git

2 months ago


zm, or zmodal for long is an implementation of the Modal programming language.

This is a fork of the C reference implementation written by Devine Lu Linvega.

Latest version: 0.1.2.

The ultimate goal of this project is to rewrite and modularize the implementation in Zig, which can be used as a command line program or also compiled into WASM to be used as part of a web playground.

Current status: I've converted the CLI wrapper feature-equivalent to Zig. Now I'm going to work on translating the library from C to Zig. I'd like to do this piecemeal, so I'll need to find a decent way to translate things such that I'm not having to work on running Zig code from C as well sa vice-versa -- so this will probably mean a top-down translation of the library internals.

Come chat with us in the #modal channel on Libera.Chat!

#Current changes from the reference implementation

  • "Object-oriented" and separated as a library
  • Single interrupt ?: for procedures
  • More examples
  • Expanded escape sequences
    • \a, \e, \n, \r, \s, \t, \\, and \xHH are supported.
  • -F, -w options
  • New changes licensed under AGPLv3 as this implementation is intended for use in a web environment

The c branch contains an enhancement of the C reference implementation that is available as a C library.

#TODO changes from the reference implementation

  • Document, document, document
  • Rewrite in Zig
  • Handle adversarial input -- ex convert foo ?(bar) input to foo \x3F\x28bar\x29 or something. Will be a matter for redefining I/O ops.
  • Expand supported interrupts (including past one char long)
  • Graphics
    • SDL2?
    • Write in a way that different environments/builds can hook different calls -- i.e. SDL2-based graphics for a native application, <canvas>-based for web




./zm examples/hello.modal
	-v Print version
	-q Quiet mode, no step printing
	-F Print the final program state to stdout (implies quiet)
	-p Print summary with refs count
	-n Infinite mode, no rewrites limit
    -w Pause for line input before every rewrite -- useful for debugging.
       Actual "i" interrupts will be given a ">>" prompt to distinguish.


Modal was created by wryl.

C implementation by Devine Lu Linvega.

zm written by me, Sebastian LaVine.

See the C implementation for the source for many of the examples.

Copyright (c) 2024 Sebastian LaVine.

zm is Free Software, made available under the terms of the AGPLv3.

Copyright (c) Devine Lu Linvega.

The C reference implementation was originally published under the terms of the MIT license.