Git Product home page Git Product logo

smudge's Introduction

Linux Build Status Windows Build Status

The Smudge Programming Language

Smudge is a domain specific language for implementing state machines. The compiler generates standard C code as well as graphical state diagrams. Its output is optimized for use on very limited embedded systems, but designed to be used anywhere state machines are appropriate. Here's a simple example to show you what the language looks like:

first.smudge

SM_NAME
{
    *FIRST_STATE (@enterFirst)
    [
        event --> SECOND_STATE,
        altEvent -(@sideEffect)-,
        reenter --> FIRST_STATE
    ] (@exitFirst),

    SECOND_STATE
    [
        _ -(@sideEffect)-> FIRST_STATE
    ]
}

Getting Smudge

Binaries

There are binary releases available for Windows and Linux available on the Smudge releases page. The latest release includes a pdf of the tutorial, which is a great place to start learning Smudge.

Building From Source

First, make sure you have ghc installed, along with haskell-stack. In order to build the documentation, you'll also need rst2pdf and pdflatex.

Then, in your shell of choice, run:

$ make

The first time you build, it might tell you to run

$ stack setup

This may take a bit, as stack will have to download and configure the build environment.

This should work on Windows under Cygwin, as well as reasonably recent versions of Debian (with issues) and Ubuntu. It has worked on other distros and MacOS, and if you have trouble getting it to build we encourage you to ask for help on gitter. It generates an executable called smudge (or smudge.exe on Windows) that you can use to compile Smudge code by running stack exec smudge.

How to Use Smudge

Once you have Smudge installed, either because you built it from source or downloaded a release, the best way to learn how to use it is to look at the tutorial. It's in the release tarball and it's built as part of the normal build process in docs/tutorial/tutorial.pdf. Here's the quick version for the impatient though.

Prerequisites

First, make sure you have graphviz installed. It should be available through your package manager on Linux, through homebrew on MacOS, or within cygwin on Windows. If you're running on Windows, we strongly suggest that you use Cygwin.

Running

$ smudge --dot-fmt=Svg first.smudge
Wrote file "first.svg"
Wrote file "first.h"
Wrote file "first.c"
Wrote file "first_ext.h"

This generates 4 files. The .svg file is just an image with a diagram of your state machine. The .h file is the interface to the code generated by Smudge, and the _ext.h file contains generated prototypes for functions you must provide.

There's more!

Further example state machines can be found in the examples directory. In particular, first.smudge is the state machine shown above but with extensive comments to describe what it's doing.

There's also a gitter if you need help or want to communicate with the contributors.

License

Smudge is released under a standard BSD 3-clause license, found in LICENSE file.

smudge's People

Contributors

nate-bragg-bose avatar nathan-michaels-bose avatar nmichaels avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.