- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
bool Document::_Parse_Auto (char sym)
{
bool error = 0;
switch (mInfo.AutoState)
{
case 0:
{
if (is_stag (sym))
mInfo.AutoState = 1;
else
mInfo.AutoState = 14;
break;
}
case 1:
{
if (is_name (sym))
mInfo.AutoState = 24;
else if (is_delim (sym))
mInfo.AutoState = 2;
else if (is_prcom (sym))
mInfo.AutoState = 11;
else if (is_info (sym))
mInfo.AutoState = 25;
else if (is_ekey (sym))
mInfo.AutoState = 21;
else
error = true;
break;
}
<100500 строк case'ов>
case 26:
{
if (is_etag (sym))
mInfo.AutoState = 0;
else
error = true;
break;
}
}
return error;
}
void Document::_Parse_React (char sym)
{
switch (mInfo.AutoState)
{
case 0:
{
switch (mInfo.NodeType)
{
case ParseInfo::preproc:
{
delete mInfo.CurrentNode;
mInfo.CurrentNode = mInfo.LastTextNode;
break;
}
case ParseInfo::info:
{
delete mInfo.CurrentNode;
mInfo.CurrentNode = mInfo.LastTextNode;
break;
}
case ParseInfo::close:
{
if (mInfo.name == mInfo.CurrentNode->name)
mInfo.CurrentNode = mInfo.CurrentNode->parent;
else
{ mInfo.Error = 51; return; }
mInfo.name.clear ();
break;
}
}
break;
}
<ещё 100500 строк case'ов>
case 25:
{
mInfo.NodeType = ParseInfo::info;
mInfo.LastTextNode = mInfo.CurrentNode;
mInfo.CurrentNode = new Node;
break;
}
}
switch (mInfo.LastAutoState)
{
<и ещё 100500 строк case'ов>
Это я в 10 классе писал XML парсер, работающий на конечном автомате, в котором было 27 состояний.
Lure Of Chaos 20.03.2011 23:31 # 0
YuraTim 20.03.2011 23:37 # +3
Lure Of Chaos 20.03.2011 23:45 # 0
absolut 21.03.2011 10:06 # 0
TarasB 21.03.2011 14:13 # +3
absolut 21.03.2011 14:32 # +3
Lure Of Chaos 21.03.2011 22:20 # 0
YuraTim 21.03.2011 17:26 # 0
bugmenot 21.03.2011 22:03 # 0
Lure Of Chaos 21.03.2011 22:21 # +3