[ragel-users] Action for leaving a machine from a non-final state
Ivan Reche
ivan.reche at gmail.com
Sun Feb 19 21:37:09 UTC 2012
Hello there,
I'm using ragel to read peripherals input using a microcontroller. I need
to have two machines: one for parsing commands and the other for storing
data.
Let's suppose that my setup is like this: when the device is turned on, I
know that I'm in command mode and I will parse some ASCII words to
acknowledge the peripheral's state. However, if I get the word *OPEN*,
every character that I received after the second * will be stored as data.
While in this data mode (where I store every character), if I receive the
*CLOS* string, I should NOT store *CLOS* in my data buffer and leave the
data mode (switch to the other machine).
I've accomplished almost everything that I need with this machines, except
the part of not storing the *CLOS* object. My first solution was to just
delete it after a match of *CLOS*, but this causes problems with parallel
execution in my environment because in a give moment I might have data in
my buffer that is not really data.
So I created some locks that will prevent the data machine from storing the
caracters when I begin to match what is a candidate of *CLOS* (example:
*CL). This works fine if the candidate proves to be, indeed, a *CLOS*
string, but I don't know how to associate an action to the event of *CL not
ending up in a *CLOS* (example: *CLabc). At this point, I want to store
*CLabc in my buffer and continue storing characters.
I'm kind of new to Ragel and I'm enjoying it very much. However, I don't
know if I'm doing things in an awkward or if I am indeed in the right track.
How do I achieve what I want to do? Is there a better way?
Cheers,
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20120219/45d6f81e/attachment-0001.html>
-------------- next part --------------
_______________________________________________
ragel-users mailing list
ragel-users at complang.org
http://www.complang.org/mailman/listinfo/ragel-users
More information about the ragel-users
mailing list