state-machine

Converting regular expression to finite state machine

﹥>﹥吖頭↗ 提交于 2019-11-30 07:37:59
would you have a hint at algorithm to convert any regular expression to a finite state machine. For instance, an algorithm parsing a regexp and adding states to the fsm appropriately? Any reference or deeper idea? I am writting this with Python Thanks and regards Use Michael Sipser's Introduction to the Theory of Computation . Chapter 1 gives detailed algorithms for converting a regular expression to a deterministic or non-deterministic finite-state automaton (DFA or NFA), in the context of proving their equivalence (a DFA, an NFA and a regular expression can match exactly the same classes of

Auto advancing state machine with Stateless

六眼飞鱼酱① 提交于 2019-11-30 03:42:31
问题 I've been experimenting with Stateless (HSM in C#) (https://code.google.com/p/stateless/) lately and I've come across something that I'm not really sure how to achieve. Let's say I have the following states: Start. Connect Read Finish What I'm trying to achieve is: when the TCP connection (in the Connect state) is established, advance to the Read state. Or, if it fails, advance to the Finish state (where it may return to the Connect state and attempt a new connection after a timeout period).

PHP state machine framework

跟風遠走 提交于 2019-11-29 20:29:31
I doubt that is there any state machine framework like https://github.com/pluginaweek/state_machine for PHP. I've had to define many if-else logical clauses, and I would like something to help make it more fun by just defining: Condition required to transition State after transition Then this can be reused to check if conditions match or not, for example $customer->transition('platinum'); I expect this line of code to implicitly check if the customer can transition or not. Or explicitly check by: $customer->canTransitTo('platinum'); Thanks in advance, noomz I don't know a framework like this

Java enum-based state machine (FSM): Passing in events

可紊 提交于 2019-11-29 20:09:51
I'm using several enum-based state machines in my Android application. While these work very well, what I am looking for is a suggestion for how to elegantly receive events, typically from registered callbacks or from eventbus messages, into the currently active state. Of the many blogs and tutorials concerning enum-based FSMs, most of them give examples of state machines that consume data (e.g. parsers) rather than show how these FSMs may be driven from events. A typical state machine I'm using has this form: private State mState; public enum State { SOME_STATE { init() { ... } process() { ..

How to implement a RESTful resource for a state machine or finite automata

两盒软妹~` 提交于 2019-11-29 16:07:59
问题 I'm a Rails and REST newbie and I'm trying to figure how best to expose a resource that is backed by a domain object that has a state machine (in other words is a finite automata). I've seen a number of gems for making a model class a state machine, such as aasm, transitions, workflow, but none of them document examples of how they are actually used in a resource oriented controller. They all seem to imply that state transitions are triggered by an "event" , which is really a method call.

VHDL state machine differences (for synthesization)

雨燕双飞 提交于 2019-11-29 11:42:36
I am taking a class on embedded system design and one of my class mates, that has taken another course, claims that the lecturer of the other course would not let them implement state machines like this: architecture behavioral of sm is type state_t is (s1, s2, s3); signal state : state_t; begin oneproc: process(Rst, Clk) begin if (Rst = '1') then -- Reset elsif (rising_edge(Clk)) then case state is when s1 => if (input = '1') then state <= s2; else state <= s1; end if; ... ... ... end case; end if; end process; end architecture; But instead they had to do like this: architecture behavioral of

Java library to check whether a String contains a number *without* exceptions

走远了吗. 提交于 2019-11-29 06:48:54
I'm looking for a method that returns a boolean if the String it is passed is a valid number (e.g. "123.55e-9", "-333,556"). I don't want to just do: public boolean isANumber(String s) { try { BigDecimal a = new BigDecimal(s); return true; } catch (NumberFormatException e) { return false; } } Clearly, the function should use a state machine (DFA) to parse the string to make sure invalid examples don't fool it (e.g. "-21,22.22.2", "33-2"). Do you know if any such library exists? I don't really want to write it myself as it's such an obvious problem that I'm sure I'd be re-inventing the wheel.

Can UML state machine diagram be used to show the screen navigation?

心不动则不痛 提交于 2019-11-29 05:23:09
Can UML state machine diagram be used to show the screen navigation? Sure you can create a UML model of the UI as a state machine, for example: Screens are states State transitions i.e. screen changes occur on specific inputs or other triggers Did you actually have some more specific question? You can use state machines but it is also possible to use sequence diagrams for that. If you don't need to stick to the pure UML, there are plenty of approaches devoted to the specification of web systems that include the concept of web navigation models (with elements as pages, links,...). These

Mealy v/s. Moore

痴心易碎 提交于 2019-11-28 21:19:47
What is the difference between Mealy & Moore type of finite state machines? In a Moore machine the output produced is associated to the current state of the machine and on it only. In a Mealy machine, instead, it is associated to both a state and a specific input. From a practical point of view you have that output is placed on states in a Moore machine (so every state has its ouput), while on the latter you have outputs on transitions (so an ouput is decided from the current state AND the outgoing transition) Moore machine output is a function only of the state of the machine, Mealy machine

PHP state machine framework

别来无恙 提交于 2019-11-28 17:11:43
问题 I doubt that is there any state machine framework like https://github.com/pluginaweek/state_machine for PHP. I've had to define many if-else logical clauses, and I would like something to help make it more fun by just defining: Condition required to transition State after transition Then this can be reused to check if conditions match or not, for example $customer->transition('platinum'); I expect this line of code to implicitly check if the customer can transition or not. Or explicitly check