The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [state-machine]

A state machine is a model for designing systems which change based upon their current state and what input they receive.

Filter by
Sorted by
Tagged with
7
votes
0answers
307 views

STTCL FSM framework based on the GoF State Pattern, Part I: The basic interfaces

Preface I have decided to let my pet project created some years ago to undergo a code review here. The review will be broken into parts according to meta question Multiple reviews or one big review?...
2
votes
0answers
49 views

STTCL FSM framework based on the GoF State Pattern, Part II: Abstraction of asynchronous/concurrency features

Preface I have decided to let my pet project created some years ago to undergo a code review here. The review will be broken into parts according to meta question Multiple reviews or one big review?...
14
votes
1answer
31k views

State pattern + C++ template

This finds its origin in the following reflection. In their book from 1995, the so-called gang of four (GoF) described the state pattern. What they were actually telling us in their description, is ...
6
votes
5answers
262 views

Simple tokenizer v2 - reading all matching chars at once

I have rewritten my tokenizer according to most of the suggestions from the previous question here. API It now reads all chars as long as they match the pattern. I use three types of attributes to ...
6
votes
1answer
772 views

A variant of state pattern + C++ template FSM without state creation/destruction penalty

This is a variant of the solution posted here, without state creation/destruction penalty. Note that my comment in the original question about the simplification provided by C++11's inherited ...
11
votes
2answers
164 views

Using state transitions to filter C comments

This is my second attempt at K&R 1-23, Write a program to remove all comments from a C program. Don't forget to handle quoted strings and character constants properly. C comments don't nest....
8
votes
2answers
424 views

Does this simulation follow abstraction and encapsulation?

This below code implements a simulation of an ocean(as 2d-array of cells) which currently have Shark, fish or be Empty. User can run this simulation, as shown below: ...
6
votes
2answers
247 views

Finite state automata

This is a non-deterministic finite state automata (NFA) meant to be used with a Regex engine. To show some example usage, suppose you wanted to construct an NFA for the regex ...
5
votes
1answer
86 views

UTF8 Codepoint decode and length v.2

This is the complete rewrite of a function to decode an UTF-8 codepoints and return the encoding length (or 0 if the codepoint is ...
3
votes
2answers
247 views

Simple tokenizer v1 - reading char by char

I was feeling like writing a new Uri parser. The previous one was too limited and wasn't able to parse the authority part. This one is also based on the pretty ...
9
votes
1answer
872 views

Simple parsing for string formatting (version 2)

This is my second attempt (version 1) at writing a string formatting utility which uses parsing. This time I more explicitly designed it as a finite state machine. I have very little experience with ...
8
votes
1answer
7k views

Deterministic finite automaton in Java

Formally, a deterministic finite automaton is a 5-tuple \$M = (Q, \Sigma, \delta, q_0, F)\$, where \$Q\$ is the set of all possible states \$\Sigma\$ is the alphabet \$\delta \colon Q \times \Sigma \...
7
votes
3answers
932 views

Efficient data-driven finite state machine

In creating this answer to a recent question, I thought I might write a fully worked example that implements a finite state machine in C. The purpose is to implement the following function: ...
4
votes
1answer
202 views

Time-dependent state machine

I keep having to write state machines that depend on time for various experiments I run and I'd like to know how to write them better. This state machine is for training a neural network by feeding in ...
3
votes
0answers
82 views

STTCL FSM framework based on the GoF State Pattern, Part III: Policy based design of higher level State Machine constructs

Preface I have decided to let my pet project created some years ago to undergo a code review here. The review will be broken into parts according to meta question Multiple reviews or one big review?...
3
votes
1answer
1k views

Simple Javascript state management class

So I needed very basic state management and notification for a small game-like thing I'm building. I decided to implement something like a finite state machine (but not quite, it doesn't transition ...
2
votes
1answer
765 views

Very basic shell on microcontroller in C - follow-up

This is a follow-up of: Very basic shell on microcontroller in C A few days back I've asked for a review on a simple shell parser in c. Based on the answers, I've restructured my code to use a table-...
2
votes
1answer
1k views

Object Oriented Finite State Machine

I wrote a little library for myself: implementing a generic finite state machine. I will be using this library in class assignments. I clearly have little understanding of C++ templates because most ...