![](/img/trans.png)
[英]What is the correct way to use a stack with a scanner block in Ragel?
[英]What is the DEF state in the Ragel (6.10) document illustrations
Ragel 6.10手冊對它生成的FSM進行了許多說明。 其中一些顯示狀態DEF。 盡我所能告訴您,這從未定義/討論過。
DEF
狀態? 提前致謝
回答第一季度:
DEF
表示默認過渡,如果無法進行其他過渡,則采用默認過渡。
對第二季度的回答:
這取決於您使用Ragel的用途。
any
字符上從狀態A轉移到狀態B? 通過使用手冊(版本6.10)第6.4.5節中的示例(其中同時使用了解析表和狀態圖),可以最清楚地了解此問題。
當您明確地將any
狀態用作狀態時,有時可能會出現這種情況。
例:
%%{
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
和graphviz( ragel -Vp -o def_eg.dot def_eg.rl
):
現在,表達式從任何字符更改為單個字符。 並使用這些單個字符來表示狀態。
%%{
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
如圖所示:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.