opM[op][0]='"\"';
op++;
}
//output(DIV);
break;
case ':':
i++;
spM[sp]=':';
sp++;
//output(COLON);
break;
case ';':
i++;
spM[sp]=';';
sp++;
//output(SCOLON);
break;
case '?':
i++;
spM[sp]='+';
sp++;
//output(TERNARY);
break;
case '\"':
i++;
spM[sp]=ch;
sp++;
//output(DQ);
break;
case '\'':
i++;
spM[sp]=ch;
sp++;
//output(SQ);
break;
case ',':
i++;
spM[sp]=ch;
sp++;
//output(COMMA);
break;
case '|':
i++;
spM[sp]=ch;
sp++;
//output(PLINE);
break;
case '^':
i++;
spM[sp]=ch;
sp++;
//output(CARAT);
break;
case '[':
i++;
spM[sp]=ch;
sp++;
output(OSB);
break;
case ']':
i++;
spM[sp]=ch;
sp++;
output(CSB);
break;
case '#':
i++;
spM[sp]=ch;
sp++;
output(HSH);
break;
case '%':
i++;
spM[sp]=ch;
sp++;
output(PER);
break;
/* case '!':
i++;
sp++;
output(NOTEQU);
break; */
case '&':
i++;
spM[sp]=ch;
sp++;
output(AND);
break;
case '\\':
i++;
spM[sp]=ch;
sp++;
output(BSH);
break;
case '.':
i++;
spM[sp]=ch;
sp++;
output(DOT);
break;
default:
if (isalpha(store[i]))
{
j = 0;
while(isalpha(store[i]))
lexeme[j++] = store[i++];
lexeme[j] = '\0';
output(search(lexeme));
break;
}
else if(isdigit(store[i]))
{
j = 0;
while (isdigit(store[i]))
lexeme[j++] = store[i++];
lexeme[j] = '\0';
digitM[digit]=store[i];
digit++;
output(DIGIT);
break;
}
else if (store[i]=='\n')
{
i++;
printf("\n Line=%d\n",line++);
printf(" ____\n");
}
else if (store[i]=='\t' || store[i]==' ')
i++;
else
i++, printf("\tInvalid symbol\n");
}
}
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
FILE *fp1; /* Source file pointer */
int ch,i; /* used to store character read */
char store[4000];
int store_len;
char file[15];
/* clrscr(); */
printf("Enter file name with .c as the extension\n");
scanf("%s",file);
//strcat(file, textBox1->Text->);
for(int i=0; iText->Length; i++)// i ni textBox1 ni uzunligigacha 1 tadan oshirish
{ file[i]=textBox1->Text[i]; }
fp1 = fopen(file, "r");
if (fp1 == NULL)
{
//printf("The source file can not be opened for reading\n");
MessageBox::Show("Fayl topilmadi");
/*exit(1); */
}
else {
/* read till end of file is encountered */
i = 0;
while ( (ch = getc(fp1)) != EOF)
{
store[i++] = ch;
}
store_len = i;
/* close the input file */
fclose(fp1);
//printf("NUMBER\tSYMBOL\t\n");
//printf("______\t______\t\t\n\n");
//printf(" Line=1\n");
//printf(" ____\n");
lexical(store, store_len);
label1->Text = "Identifikatorlar= "+ident.ToString();
dataGridView1->RowCount=ident;
for (int i = 0; i < ident; i++)
{
String ^s = gcnew String(identM[i]);
//dataGridView1->Rows->Add();
dataGridView1->Rows[i]->Cells[0]->Value =s;
}
//printf("identifiers=%d",ident);
if( dataGridView1->RowCountRowCount=sp;}
label2->Text = "Maxsus protsessorlar= "+sp.ToString();
for (int i = 0; i < sp; i++)
{
String ^s = Convert::ToString(spM[i]);
//dataGridView1->Rows->Add();
dataGridView1->Rows[i]->Cells[1]->Value =s;
}
//printf("\n\n special operators=%d",sp);
label3->Text = "Aktivr so'zlar= "+key.ToString();
if( dataGridView1->RowCountRowCount=key;}
for (int i = 0; i < key; i++)
{
String ^s = gcnew String(keyM[i]);
//dataGridView1->Rows->Add();
dataGridView1->Rows[i]->Cells[2]->Value =s;
}
//printf("\n\nkeywords=%d",key);
if( dataGridView1->RowCountRowCount=op;}
for (int i = 0; i < op; i++)
{
String ^s = gcnew String(opM[i]);
//dataGridView1->Rows->Add();
dataGridView1->Rows[i]->Cells[3]->Value =s;
}
label4->Text = "Operator bo'lmaganlar= "+op.ToString();
//printf("\n\noperators=%d",op);
if( dataGridView1->RowCountRowCount=digit;}
for (int i = 0; i < op; i++)
{
String ^s = Convert::ToString(digitM[i]);
//dataGridView1->Rows->Add();
dataGridView1->Rows[i]->Cells[4]->Value =s;
}
label5->Text = "Raqamlar= "+digit.ToString();
//printf("\n\ndigit=%d\n",digit);
}
//getch();
}
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void textBox1_Click(System::Object^ sender, System::EventArgs^ e) {
textBox1->Clear();
}
};
}
Do'stlaringiz bilan baham: |