[ragel-users] syntax improvement, new operators

Adrian Thurston thurs... at cs.queensu.ca
Fri Feb 9 03:48:01 UTC 2007

Hi Erich,

I'm glad to see you are still working with Ragel! By the way, I've 
updated your name in the CREDITS file and elsewhere.

> Character Actions
> =============
> > aka First -- This action will be executed on the first character the machine recognizes.
> $ aka Each -- This action will be executed on each character the
> machine recognizes.
> @ aka Match -- This action will be executed on characters the machine
> recognizes that puts the machine into a match state.
> < aka Continue -- (New) This action will be executed on the next
> character the machine recognizes when the machine is in a match state.

So it seems that you prefer to express these operators in terms of the 
characters of the input string that is processed. This is distinct from 
my approach, where I talk about the transitions of a regular 
expression's corresponding state machine.

I prefer to express the operators in terms of transitions because I find 
it to be very precise. For example, with "entering transition actions" 
you can go and look at the graphviz drawing and find the transitions 
which take you into the machine. That's me though, and I would very much 
like to hear what others think. Is it better to talk about the 
transitions that the actions are put into, or is better to talk about 
the characters that are moved over when the actions are executed?

The < operator you have given I find interesting. As I understand it, 
this would embed the action on the transitions which leave final states 
(but stay in the machine). Could you give an example of when it is useful?

> Machine Actions
> ============
> % aka Accept -- This action will only be executed when the machine
> accepts a match.

The word "accept" I find to be somewhat ambiguous. It doesn't strike me 
that it means only one of "on the last character" or "on the next 
character." It seems to me that it could easily be interpreted as either 
of those. I chose the word "leaving" for this operator because it's 
clear to me that it means on the next character.

> %\ aka Fail -- (New) This action will only be executed when the
> machine fails to either: (a) recognize a character, or (b) accept a
> match.

I'm not quite sure what you mean with (b). I would assume you mean the 
same as above, what is currently known as the leaving (or pending out) 
operator. But then I believe this new operator would be the same as the 
$! operator. Could you clarify?

> %? aka Skip -- (New) This action will be executed instead of Fail when
> either the Optional operator or the Kleene Star operator is applied to
> the machine.

I'm not sure I understand this operator. If you write:

( expr %? skip_act )?

Is it the same as writing the following?

( expr | "" %skip_act )

Could you give us an example of the kind of problem that motivated these 
operators? Especially the part about setting and clearing external state 
flags to do proper resource acquisition and release. An example would 
really help me to understand the issue.


More information about the ragel-users mailing list