From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_05 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 22 Oct 92 02:26:25 GMT From: news.byu.edu!hamblin.math.byu.edu!sol.ctr.columbia.edu!The-Star.honeywell .com!saifr00.cfsat.honeywell.com!schall@gatech.edu (Loren Schall) Subject: Is a generic finite state machine engine reasonable? Message-ID: <1992Oct22.022625.13802@saifr00.cfsat.honeywell.com> List-Id: I originally asked this question in comp.programming, but I think I'm really looking for a more specific solution. >Hello Netters, a colleague of mine brought me an interesting question >and I knew that you would have some useful input. > >We're involved with a large realtime application that includes several >pieces which could reasonably be implemented as finite state machines. >Is it possible and reasonable to implement a "generic" finite state >engine? Please reply via e-mail and I'll summarize and re-post. If >you think this is an inapropriate place for this discussion, tell me >where the right place is. > >I'm envisioning a (static) initialization step where the specific >machine is defined (inputs, transitions, and outputs) and an >invocation process taking an input and producing an output (the >actual state transition being internal and invisible). > >The main objective we're looking for is ease of maintenance. We >believe that it would be easier to maintain several state machine >descriptions and one implementation, than several different state >machine implementations. > >Does anyone know of any appropiate references or examples (Ada, C, >or C++ would be must useful). > >Thanks, in advance, for any help you can offer. I'm not very familiar will OOP. Isn't there some way to implement this in Ada (instanciate and call)? This would become part of an existing project that is moving from Pascal to Ada. comp.programming replies: #Look into LEX. #I am sure you will be able to write a good utility using LEX to serve #all your needs involving finite state machines. I hadn't really thought about lex/flex. I was hoping to avoid a two step process. Most of the programmers that would be using this are unfamiliar with Unix (and its ideas). *You may infer a general code-mapping algorithm that compiles DFA's *directly into code, instead of into an abstract DFA implemented on top *of the code layer, from the pesudo-code example below. [example deleted] =In this years conference on Compiler Construction a paper by L.O. =Larsen describes how one can generate an efficient specific finite =state machine from a generic one by partially evaluating the generic =machine with respect to a definition. The paper is in Springer-Verlag =LNCS 641. (I haven't checked out this paper, yet.) I was kind'a thinking of using "an abstract DFA implemented on top of the code". Is this the wrong approach? Let me expand on my original idea. What I'm really looking for is an easy way to implement The Specification. Several place in our System Specification, state tables or state diagrams are used to describe the expected response(s). It would be most convenient if these could be (almost) directly translated to code. Am I making any sense? Is this kind of thing possible or do I have to look at making a translator (state machine description -> Ada)? It is a requirement that we use Ada, so nothing but Ada code can be concidered the *offical* source. I eagerly await any suggesting you might have to offer. Loren schall@swtech.cfsat.honeywell.com (Loren Schall)