Home of


The State Machine Compiler

(Updated March 16, 2017)

Your application lives in a world of asynchronous, unordered events: mouse clicks, timeouts, messages, and OS signals. And you're ready for them. You've carefully designed your objects. You're using robust patterns that facilitate reuse and anticipates future product direction. Your dynamic models allow your objects to recover from all but the most catestrophic events. Your application is ready for anything.

But there's a hitch. Your detailed state diagrams are only pictures. How are you going to translate your drawings into code? A transition matrix is cryptic while switch statements means your state machine logic is scattered all over your code. The state pattern looks like a great solution but that means writing and maintaining a class for each state - too much work.

Enter SMC - The State Machine Compiler. Now you put your state diagram in one file using an easy-to-understand language. SMC generates the state pattern classes for you. No more hand-maintained transition matrices. No more widely scattered switch statements. Instead, the state diagram is in one place, coded directly from the picture to the SMC language and is easily maintained.

SMC uses the state pattern to its fullest extent. In the real world, events don't always happen when they should. Dealing with unexpected events is a must for a robust application. By combining virtual methods with the state pattern, SMC allows you to define "Default" transitions - transitions which allow your objects to handle unexpected events, recover and continue providing service (rather than crashing, burning and getting you into trouble).

SMC is a Java application. That means SMC will work on any platform where Java 1.7.0 or better is supported.

Version 6.6.1: Bug Fixes.

This release fixes the following bugs:

  • All: smc-anttash now recognizes all currently supported SMC target languages.
    (SMC bug 207, 208 )
  • Objective C: getPreviousState() now returns the correct value after a transition completes.
    (SMC bug 209 )
  • C++ using -crtp: When using -crtp, the generated code now outputs the correct getOwner() methods:
    inline DERIVED& getOwner() {...}
    inline const DERIVED getOwner() const {...}
    (SMC bug 210 )
  • Graphviz: The Graphviz .dot file now defines all transitions after defining subgraphs. This corrects the problem of subgraphs containing incorrect states due to jump transitions between subgraphs.
    (SMC bug 211 )
  • All: Corrected Makefile and smc.mk so that staging/Release directory is automatically created if it does not already exist. Also added macros to smc.mk which specify the Java source and target versions.
    (SMC bug 212 )

SMC & eBus: a match made in heaven

eBus is a Java middleware for sending messages between objects. eBus always received messages to be posted directly to an SMC transition, allowing the message to be interpreted within the FSM context. No more switch statements needed to tie inbound messages to the appropriate transition - it is done automatically for you.

To learn more, get the eBus Programmer's Manual (in PDF). This manual explains step-by-step how to use eBus and how to connect eBus to your SMC finite state machine.

Check the SMC project's Latest News to find out the latest, report bugs, ask questions, make suggestions or to learn how you can help improve this great tool.

What's New?
C JavaScript Python
C++ Lua Ruby
C# Objective-C Scala
Groovy Perl TCL
Java* PHP VB.net
See how easy it is to put SMC generated state machines into your code. This page walks you through the steps to using the State Machine Compiler. This page comes in fourteen flavors: C , C++ , C# , Groovy , Java , JavaScript , Lua , Objective-C , Perl , PHP , Python , Ruby , Scala , Tcl and VB.net .

* In Java, the state machine can be implemented using either the State Pattern or a transition table (using java.lang.invoke.MethodHandle).

Step into the picture gallery and check out the finite state machine pictures at all levels of detail, both the raw, SMC-generated version to the human-edited improvements. Graphing SMC
SMC Telephone Applet Step in, close the door and place a call. The SMC Telephone Demo is a Java applet driven by an SMC-generated finite state machine . You can watch the FSM do its thing while placing your call.
SMC Programmer's Manual And when all else fails (and only then), READ THE MANUAL!
Got questions? Then check out the Frequently Asked Questions (FAQ) page. Can't find your question? Then e-mail it to me and I will send you the answer and add it to the FAQ. SMC FAQ
Downloading SMC Alright, you're gonna bite. This page has the download links for SMC.
SMC contributers Stand up and and give them a hand! Who? Why those intrepid folks who have contributed to SMC, that's who! Find out who all make SMC the success that it is.
Is there some feature you would like to see added to SMC? Is there an irritating bug you would like to see fixed? Then make a wish. Or better yet, go here to make submit a feature request and here to submit a bug report. Your wish is my command
SourceForge.net Logo SourceForge.net has many other open source software downloads available. Surf over and check it out!
Support This Project

And in case you were wondering, SourgeForge provides all the servers, networks and software necessary to make SMC possible - without asking for anything in return!

Well I'm asking. You can now donate to the SMC project and 100% of the donation goes to SourceForge.net. If you want SMC to keep going, then we all have to keep SourceForge going.

Contacting Me
If you have any comments or questions, contact me.

Ohloh profile for cwrapp

View Charles Rapp's profile on LinkedIn

Copyright 2000 - 2009, 2011, 2013, 2017. Charles W. Rapp.
All rights reserved.