[ragel-users] some questions regarding ragel
adrian.thurston at esentire.com
Fri Nov 20 19:21:19 UTC 2009
The EOF actions are likely coming from leaving actions that are embedded
into the final state. The semantics of leaving actions is such that they
are executed when EOF arrives and we are in a state that has leaving
actions and the state is final.
I have long been interested in adding a write option that causes ragel
to process only one character. Since I haven't gotten to that yet, the
way to do it is to do something like this:
char c = something();
char *p = &c;
char *pe = p + 1;
I admit that this does not produce optimal code, as the pe testing code
is pointless, but it's all there is right now.
In regards to checks, yes, you can use conditions. This makes the
running code more complex, so it might not be for you. Best to try it
out. See the manual in "Beyond the Basic Model."
Григорий Фучеджи wrote:
> Hi. I'm new to ragel and currently exploring its features. I'm working
> on some applications using microcontrollers which have very limited
> resources. Microcontrollers communicate with each other with radio. I'm
> using ragel to parse radio protocol. So here is my questions:
> 1. Main part of my application is infinite loop, which is waiting for
> input, parses it with ragel-generated code and do some work. So I don't
> have EOF-thing at all. I don't use any EOF actions(at least explicitly).
> But generated code still contains some EOF-stuff which uses eof
> variable(thus I have to declare it). Documentation states: "If EOF
> actions are used then the eof variable is required."(so if I don't use
> EOF actions it shouldn't be required) I think I'm missing something.
> Maybe I have to state explicitly somewhere in .rl file that EOF is
> senseless in my case. Here is my dummy-playground-example for PC
> 2. Ragel assumes that data which have to be processed is between p and
> pe pointers. Can this be customized? Here is what I want. I have
> ring-buffer which fills in interrupt routines. I have interface function
> for this ring-buffer, which returns data from this buffer byte by byte (
> int cyw_tryread(uint8_t* ptr) ). If there is some valid data in buffer
> it writes it to (*ptr) and returns 1, otherwise 0. I want ragel to use
> this function as source of data instead of walking through p pointer. It
> seems that all I need to do for this is replace
> > if ( ++p != pe )
> > goto _resume;
> > if ( cyw_tryread(p))
> > goto _resume;
> pe pointer is useless here. So can I customize this in ragel without
> patching generated code(patching generated code is not very good thing
> to do...)
> 3. Can I embed C checks within machine definition statement? e.g. if I
> want machine that matches any character, that have nonzero bit number 2
> (xxxxx1xx). So for this characters (ch & 4) is true. Is there a way to
> define such machine?
> Any tips and explanations would be very much appreciated.
> Grygoriy Fuchedzhy
> ragel-users mailing list
> ragel-users at complang.org
More information about the ragel-users