Related articles |
---|
question on NFA and DFA generated by flex naumann@stce.rwth-aachen.de (Uwe Naumann) (2008-03-07) |
From: | Uwe Naumann <naumann@stce.rwth-aachen.de> |
Newsgroups: | comp.compilers |
Date: | Fri, 07 Mar 2008 07:10:29 +0100 |
Organization: | Compilers Central |
Keywords: | lex, question, DFA |
Posted-Date: | 08 Mar 2008 10:55:42 EST |
Consider the following simple flex input:
++++++++++++++++
var v
%%
{var} {}
. {}
%%
int main()
{
yylex();
return 0;
}
++++++++++++++++
Running flex in trace mode (flex -T scanner.l) it tells me
about the generated NFA and DFA:
++++++++++++++++
%%
1 (v)
2 .
3 End Marker
********** beginning dump of nfa with start state 11
state # 1 257: 0, 0
state # 2 257: 0, 0
state # 3 118: 4, 0
state # 4 257: 0, 0 [1]
state # 5 257: 1, 3
state # 6 -1: 7, 0
state # 7 257: 0, 0 [2]
state # 8 257: 5, 6
state # 9 -2: 10, 0
state # 10 257: 0, 0 [3]
state # 11 257: 8, 9
********** end of dump
DFA Dump:
state # 1:
1 4
2 5
3 6
state # 2:
1 4
2 5
3 6
state # 3:
state # 4:
state # 5:
state # 6:
state # 3 accepts: [4]
state # 4 accepts: [2]
state # 5 accepts: [3]
state # 6 accepts: [1]
...
++++++++++++++++
Can anybody tell me what states
2 in NFA (dead state?)
3 in DFA (corresponding dead state resulting from subset construction?)
2 in DFA (alternative start state but still dead?)
are good for?
I understand that "accepts: [1]" indicates a final state accepting "v".
What is "accepts: [4]" trying to tell me? I can only see three rules...
Thanks for your help.
Uwe.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.