MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - State Machine Translator
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

State Machine Translator

 Post Reply Post Reply
Author
Message
mert View Drop Down
Member
Member


Joined: 16.Mar.2016
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote mert Quote  Post ReplyReply Direct Link To This Post Topic: State Machine Translator
    Posted: 07.Apr.2018 at 05:30
Dear All,

I am trying to write a generator for the simplified version of the UML state machine diagram. In my notation, there are simply the start/end state notations, the state notation, and the transition arrow. I am trying to figure out how to traverse an entire diagram starting from its start state and ending with its end state. 

The following code visits the start state and the next state. However, I cannot figure out how I can keep moving to each next state until I reach the end state.

foreach .Start {
do ~()>()~() {
do .State {
:Name
}
}
}
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 537
Post Options Post Options   Thanks (1) Thanks(1)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 07.Apr.2018 at 08:16
Have you tried looking in the manual? The MERL Primer shows how to do that (5.2.6): I'd suggest you do the whole Primer, it's the quickest way to get yourself up to speed.

Note also that in your second line, you navigate from the Start, to any role, to the relationship, to any role in that relationship (including the one you just came from). That will make you loop back to where you started from (see Loop-Backs in the manual). You'll be saved in this case by the fact that your next line will only take you to a State, not a Start, but as you navigate further from State to State you need to take account of which direction you're going in: 
do ~From~To.State {...}
If you need to look at the Transition relationship, e.g. some property or other role attached to it, you can do that after ~From: 
do ~From
{  do >Transition { :Event }
   do ~To.State {...}
}
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 10.16
Copyright ©2001-2013 Web Wiz Ltd.

This page was generated in 0.047 seconds.