A library and tool for automata and formal languages, inspired by JFLAP

Overview

Sugarcubes

https://henryksloan.github.io/sugarcubes/

Sugarcubes is a library and application for automata and formal languages. It is inspired by JFLAP, and is intended to eventually to be an alternative to JFLAP.

Screenshot of a finite automaton in Sugarcubes

Usage

Double-click the background to add a state.
Double-click a state and drag onto another state (or the same state) to add a transition.
Click and drag a state to move it. Right click a state for more options, such as deleting it or making it initial or final. Right click a transition symbol for more options, like deleting it.

Building

To build the desktop frontend, run:

cargo run --release

WASM

To build for WASM, run:

# Add the WASM compilation target if you haven't already
rustup target add wasm32-unknown-unknown

cargo build --release --target wasm32-unknown-unknown

This will produce a WASM binary in target/wasm32-unknown-unknown/release/sugarcubes.wasm, which can be placed in the docs directory and hosted as described in the miniquad docs.

Progress

Sugarcubes is in an early stage of development, having support for editing and simulating finite automata. The first MVP will be a fully usable finite automaton simulator and editor.

Next steps

  • Usable FA edit mode
    • State naming, labels (should these JFLAP features be merged?)
    • Keyboard shortcuts for context menu operations
    • Multiple select mode
      • Click-drag starting on the background
      • Movement and deletion of multiple objects
  • Simulation rewinding (this may require some sophistication to avoid combinatoric memory usage)
  • Saving (initially, either JFLAP-compatible or a custom file format)
  • Support loading input files for multiple run simulation
  • Under consideration
    • Implement undo/redo for moving
    • Editing transitions with the context menu

Eventual goals

  • More automata
    • Push-down automata
    • Turing machines
    • Possibly others like Mealy machines and Moore machines
  • Filetype-compatility with JFLAP
    • Can be implemented incrementally, per-model type
  • Regular expressions and grammars
  • Operations and conversions like minimization
  • Graph visual organization like alignment
  • Turing machine blocks
  • Built-in tutorials

Stretch goals/pipe dreams

  • Collaborative editing
  • Generating URLs of models for easy sharing
Comments
  • Minor fixes to state naming

    Minor fixes to state naming

    • Ensure that state names are saved and restored by the commands subsystem
    • Allow renaming to be undone and redone
    • Move the cursor to the end of the name setting input when it is opened
    opened by henryksloan 0
  • State names

    State names

    • Added a map to the States struct to store state names
    • Added default name generation like JFLAP (q1, q2...)
    • Added egui context menu button and window for renaming states
    • Save and load names from JFF files
    opened by henryksloan 0
  • New file creation and improved saving

    New file creation and improved saving

    • Added logic to use Window.showSaveFilePicker() if it is available
      • This is much better than the dialogless save, but is only available on some platforms (luckily including Chrome)
      • This should eventually be used for the "Save as..." feature
        • How can this distinction be reconciled when the dialog isn't available?
    • Added simple implementation for creating a new file
    opened by henryksloan 0
  • Add support for saving JFF files

    Add support for saving JFF files

    • Added implementation for DocumentCommand::SaveJFF
      • Serializes fa and states to an XML tree
      • Then sends a string with its contents to the frontend
    • Added a Save button to the File menu
    • Added code utilizing FileSaver to save the file
      • This currently only supports saving to a single file named sugarcubes.jff
    opened by henryksloan 0
  • Support for opening JFF files

    Support for opening JFF files

    Most exciting PR so far!!

    • Added xmltree dependency for easily parsing XML to a tree of enums
    • Cleaned up message handling by moving top message handling to a new struct
    • Added a static buffer of DocumentCommand, that can be written to by JS
    • Implemented reading a JFF automaton structure from JFLAP
      • Reads all states and adds them to a new States + FiniteAutomaton pair, and then reads all the transitions and adds them to the FiniteAutomaton
      • If the entire reading occurs without error, the real fa and states are overwritten
    opened by henryksloan 0
  • Multiple run input loading

    Multiple run input loading

    • Added Clear and Load from file buttons to the multiple run panel
    • Added functionality for reading files line-by-line and loading them to the multiple run panel
    • Made the body of the multiple run panel into a scrolling area
    • Disabled resizing of the multiple run panel
      • In the future, resizing should definitely be enabled
      • Sizing below the default is currently very finicky in egui

    In the future, more checks should be done on the file, likely all on the backend. It should probably reject certain file extensions. Perhaps, it should only accept certain file extensions, including .txt and files without an extension. Base this on what JFLAP does.

    opened by henryksloan 0
  • JS interoperation

    JS interoperation

    • Created a miniquad plugin to expose JS function to Rust, using sapp-jsutils
    • Implemented file loading function on frontend
    • Added proof-of-concept file loading
      • Appends the file name to the multiple-run list
    • Moved the top panel into a single-threaded static
    opened by henryksloan 0
  • New line support for multiple run

    New line support for multiple run

    • Pressing Enter on the last line of the multiple run list will add a new line, provided that the last line is not empty
    • If the last line of the multiple run list is empty, it will not be tested when Run is clicked
    opened by henryksloan 0
  • Multiple run simulation

    Multiple run simulation

    • Added a new simulation mode, allowing multiple strings to be evaluated instantly
    • Fixed a bug with detecting accepts and rejects involving lambda transitions
    • Adjusted camera position to automatically account for horizontal components

    The major TODO is to allow the user to add rows to the multiple run area.

    opened by henryksloan 0
  • Fast simulation

    Fast simulation

    • Added a "Fast Run" button to the simulate menu
    • Began refactoring top panel code to be split up
    • Added an early implementation of fast running
      • This requires a hard iteration limit for safety, but should eventually involve a utility struct that facilitates user confirmation
    opened by henryksloan 0
  • More robust undo/redo system

    More robust undo/redo system

    • Consolidated almost all top panel features to commands
      • Added a TopPanelCommand enum that can wrap a Command, or things like Undo, Redo, Step, etc.
    • Added commands for creating states and transitions
      • So they can now be Undone
      • This involves generating the state ID before adding it, which in theory makes it non-atomic, so be careful

    These features make me mostly satisfied with the set of undoable actions. I now think it is optional to 1) implement Undo/Redo for moving states, and 2) edit transitions in the context menu. Therefore, I moved them to an "under consideration" section in the README. That said, I think features like large-scale alignment of states should be undoable.

    opened by henryksloan 0
Owner
Henry Sloan
Google STEP Intern :: Summer 2020 Remote I have been coding since middle school, working extensively with software and web development.
Henry Sloan
Frame is a markdown language for creating state machines (automata) in 7 programming languages as well as generating UML documentation.

Frame Language Transpiler v0.5.1 Hi! So very glad you are interested in Frame. Frame system design markdown language for software architects and engin

Mark Truluck 35 Dec 31, 2022
Provably optimal zero-copy parsers using nondeterministic finite automata.

inator: an evil parsing library You supply the evil plan; we supply the -inator! or, Provably Optimal Zero-Copy Parsers with Nondeterministic Finite A

Will Sturgeon 51 Oct 4, 2023
The language that eats the stack. Heavily inspired by porth which is inspired off of forth

Snack The language that eats the stack. Heavily inspired by porth which is inspired off of forth Install To use Snack you will need Rust and fasm Afte

Cowboy8625 2 Mar 20, 2022
Solutions of Advent of Code 2021 in Rust, and some other languages.

advent-of-rust Solutions of Advent of Code 2021 in Rust, and some other languages. Puzzles Puzzle Stars Languages Day 1: Sonar Sweep ⭐ ⭐ Rust Python D

rene-d 6 Jan 7, 2023
Opensource diagnostic software for Daimler vehicles, inspired by Xentry and DAS, written in Rust

OPENSTAR An opensource diagnostic application for Daimler vehicles inspired by DAS and Xentry. Some of the work here is based on OpenVehicleDiag If yo

Ashcon Mohseninia 21 Nov 20, 2022
A Litecord compatible/inspired OSS implementation of Discord's backend for fun and profit.

A Litecord compatible/inspired OSS implementation of Discord's backend for fun and profit.

Evie Viau 3 May 9, 2022
Wally is a modern package manager for Roblox projects inspired by Cargo

Wally is a package manager for Roblox inspired by Cargo (Rust) and npm (JavaScript). It brings the familiar, community-oriented world of sharing code from other communities into the Roblox ecosystem.

Uplift Games 194 Jan 3, 2023
Matrix bot inspired by Shirt Bot.

matrix-openai-bot Matrix bot inspired by Shirt Bot. Usage Run the bot after building it or grabbing the latest release $ matrix-openai-bot Edit the ge

null 5 Oct 26, 2021
Programming language from down under, inspired by this Reddit post.

aussie++ Programming language from down under, inspired by this Reddit post. View live demo here. Special thanks to MarkWhyBird, louis100, and others

Zack Radisic 562 Dec 27, 2022
Pool is a befunge inspired, two-dimensional esolang

Pool is a befunge inspired, two-dimensional esolang

null 1 Nov 1, 2021
Programming Language Inspired by Brainfuck

Brainsuck Brainfuck but not really... like... a better version of it. Installation Requirements: Rust version 1.50 or higher Linux curl https://raw.gi

Derin Önder Eren 27 Nov 18, 2022
A Star Wars inspired by programming language

The Force The Force is a gateway to abilities many believe are unnatural... Getting Started Install Rust. We also provide a Dev Container if you would

Matthew Booe 14 Dec 21, 2022
Crates Registry is a tool for serving and publishing crates and serving rustup installation in offline networks.

Crates Registry Description Crates Registry is a tool for serving and publishing crates and serving rustup installation in offline networks. (like Ver

TalYRoni 5 Jul 6, 2023
Schema2000 is a tool that parses exsiting JSON documents and tries to derive a JSON schema from these documents.

Schema 2000 Schema2000 is a tool that parses exsiting JSON documents and tries to derive a JSON schema from these documents. Currently, Schema2000 is

REWE Digital GmbH 12 Dec 6, 2022
CLI tool that make it easier to perform multiple lighthouse runs towards a single target and output the result in a "plotable" format.

Lighthouse Groupie CLI tool that make it easier to perform multiple lighthouse runs towards a single target and output the result in a "plotable" form

Polestar 1 Jan 12, 2022
A tool to calculate mean and standard deviation from multiple tests using PageSpeed Insights API.

psi-sample PSI Test tool is an open source tool to assist web developers that runs Page Speed Insight test manually! Installing To install the psi-tes

Igor Brasileiro 14 Sep 10, 2022
A CLI tool to convet Hex color code or RGB to color code, RGB, HSL and color name(if exists)

iro -色- A CLI tool to convert the hex color code or RGB to color code, RGB, HSL, color name(if exists, according to jonathantneal/color-names). Usage

Kyohei Uto 3 Dec 9, 2022
A dynamic output configuration tool that automatically detects and configures connected outputs based on a set of profiles.

shikane A dynamic output configuration tool that automatically detects and configures connected outputs based on a set of profiles. Each profile speci

Hendrik Wolff 15 May 4, 2023
🛠️ | System tool for all my lovers

<<<<<<< HEAD ?? love-fetch Original code ferris-fetch ?? ??️ System tool for all my lovers ?? How to install it ?? cargo install love-fetch License ??

Fabio Grimaldi 11 Jun 13, 2021