Answer to Q1:
DEF
represents the default transition, which is taken if no other transition can be taken.
Answer to Q2:
This depends on what you are using Ragel for.
- Defining FSM using regular languages:
Do you want move from State A to State B on
any
character?
- Defining FSM using state charts:
Do you want to move from State A to State B on any event? Do you have a notion of a 'default' transition?.
This issue be most clearly understood by working though the example in Section 6.4.5 of the manual (version 6.10), where parsing and state charts are both used.
This can sometimes arise when you use explicitly any
as a state.
Example:
%%{
machine def_eg;
action to_action_1 {}
action to_action_2 {}
action from_action_1 {}
eg = (
start: (
any -> s1
),
s1: (
any -> s2
)>to(to_action_1) >from(from_action_1),
s2: (
any -> final
)>to(to_action_2)
);
main := ( eg ) ;
}%%
%% write data
And the graphviz (ragel -Vp -o def_eg.dot def_eg.rl
):

Now, with the expressions changed from any character to a single character. And using these single characters to represent states.
%%{
machine def_eg;
event_1='1';
event_2='2';
event_3='3';
action to_action_1 {}
action to_action_2 {}
action from_action_1 {}
eg = (
start: (
event_1 -> s1
),
s1: (
event_2 -> s2
)>to(to_action_1) >from(from_action_1),
s2: (
event_3 -> final
)>to(to_action_2)
);
main := ( eg ) ;
}%%
%% write data
Is illustrated as:
