{
++i; state = 2; break;
}
t = type(str[i]);
++i;
if (t == ERROR || t == NEWLINE || t == END || t == SYMBOL || t == STR)
{
mes(); return;
}
else
state = 3;
break;
case 2:
if (str[i] == '\'' || str[i] == '\\' || str[i] == '"' || str[i] == 'n' || str[i] == 't')
{
buffer[j++] = str[i++];
state = 3;
}
else
{
mes(); return;
}
break;
case 3:
t = type(str[i]);
if (t == SYMBOL)
state = 4;
else
{
mes(); return;
}
break;
case 4:
id = 0;
++i;
buffer[j] = 0;
if (countSym == 0)
push(&SymbolConst, buffer, countSym);
else
insert(&SymbolConst, buffer, countSym);
break;
}
}
break;
case STR:
j = 0;
state = 1;
id = 1;
curlex = STR;
++i;
for (; i < N && id;)
{
switch (state)
{
case 1:
if (str[i] == '"')
{
state = 3; break;
}
buffer[j++] = str[i++];
if (str[i-1] == '\\')
{
state = 2; break;
}
t = type(str[i-1]);
if (t == ERROR || t == NEWLINE || t == END || t == SYMBOL || t == STR)
{
mes(); return;
}
break;
case 2:
if (str[i] == '\'' || str[i] == '\\' || str[i] == '"' || str[i] == 'n' || str[i] == 't')
{
buffer[j++] = str[i++];
state = 1;
}
else
{
mes(); return;
}
break;
case 3:
id = 0;
++i;
buffer[j] = 0;
if (countStr == 0)
push(&StringConst, buffer, countStr);
else
insert(&StringConst, buffer, countStr);
break;
}
}
break;
case DIGIT:
j = 1;
buffer[0] = str[i];
state = 1;
id = 1;
curlex = DIGIT;
for (i = i + 1; i < N && id;)
{
switch (state)
{
case 1:
buffer[j++] = str[i];
t = type(str[i]);
if (str[i] == '.')
{
++i; state = 2;
}
else if (t == DIGIT)
++i;
else if (t == SEPARATOR || t == SPACE)
state = 3;
else
{
mes(); return;
}
break;
case 2:
buffer[j++] = str[i];
t = type(str[i]);
if (t == DIGIT)
++i;
else if (t == SEPARATOR || t == SPACE)
state = 3;
else
{
mes(); return;
}
break;
case 3:
id = 0;
buffer[j-1] = 0;
if (countDig == 0)
push(&DigitConst, buffer, countDig);
else
insert(&DigitConst, buffer, countDig);
break;
}
}
break;
case SEPARATOR:
j = 0;
state = 0;
id = 1;
curlex = SEPARATOR;
while (id)
{
switch (state)
{
case 0:
buffer[j++] = str[i];
if (str[i] == '+') state = 1;
else if (str[i] == '-') state = 2;
else if (str[i] == '<' || str[i] == '>' || str[i] == '=' || str[i] == '!') state = 3;
else if (str[i] == '&') state = 4;
else if (str[i] == '|') state = 5;
else state = 6;
++i;
break;
case 1:
if (str[i] == '+')
{
buffer[j++] = str[i++];
state = 7;
}
else if (t == LETTER || t == DIGIT || t == SEPARATOR || t == SPACE || t == NEWLINE || t == END || t == SYMBOL || t == STR)
{
state = 7;
}
else
{
mes(); return;
}
break;
case 2:
if (str[i] == '-')
{
buffer[j++] = str[i++];
state = 7;
}
else if (t == LETTER || t == DIGIT || t == SEPARATOR || t == SPACE || t == NEWLINE || t == END || t == SYMBOL || t == STR)
{
state = 7;
}
else
{
mes(); return;
}
break;
case 3:
t = type(str[i]);
if (str[i] == '=')
{
buffer[j++] = str[i++];
state = 7;
}
else if (t == LETTER || t == DIGIT || t == SEPARATOR || t == SPACE || t == NEWLINE || t == END || t == SYMBOL || t == STR)
{
state = 7;
}
else
{
mes(); return;
}
break;
case 4:
if (str[i] == '&')
{
buffer[j++] = str[i++];
state = 7;
}
else
{
mes(); return;
}
break;
case 5:
if (str[i] == '|')
{
buffer[j++] = str[i++];
state = 7;
}
else
{
mes(); return;
}
break;
case 6:
t = type(str[i]);
if (t == LETTER || t == DIGIT || t == SEPARATOR || t == SPACE || t == NEWLINE || t == END || t == SYMBOL || t == STR)
{
state = 7;
}
else
{
mes(); return;
}
break;
case 7:
id = 0;
buffer[j] = 0;
if (countSep == 0)
push(&Separators, buffer, countSep);
else
insert(&Separators, buffer, countSep);
break;
}
}
}
}
Form1->descr->SetTextBuf(des.c_str());
out(KW, countKW, KeyWords, Form1->IDKW);
out(Id, countId, Identificators, Form1->IDId);
out(Sep, countSep, Separators, Form1->IDSep);
out(Dig, countDig, DigitConst, Form1->IDDig);
out(Str, countStr, StringConst, Form1->IDStr);
out(Sym, countSym, SymbolConst, Form1->IDSym);
}
//---------------------------------------------------------------------------
Результат работы программы
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.