| Current Path : /var/www/html/venkat/check/file/sec_a/ |
| Current File : /var/www/html/venkat/check/file/sec_a/rit2012049_1.cpp |
# include <fstream>
# include <iostream>
# include <string>
# include <cstdio>
# include <vector>
# include <set>
using namespace std;
bool special_char(char a)
{
if(a >= 48 && a <= 57) return false;
if(a >= 65 && a <= 90) return false;
if(a >= 97 && a <= 122) return false;
return true;
}
int main()
{
fstream fin("1.c");
string str;
vector<string> v;
string check[] = {"auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","int","long","register","return","short","signed","sizeof","static" ,"struct","switch","typedef","union","unsigned","void","volatile","while"};
int size_key = 0;
size_key = sizeof(check) / sizeof(check[0]);
// cout<<"check _ size = " <<size_key<<endl;
while(true) {
fin >> str;
if(str == "int" || str == "void"){
//v.push_back(str);
break;
}
//getchar();
}
int fl = 0;
while(fin)
{
// cout << str << endl;
if(str[0] != '/' || str[1] != '/'){
v.push_back(str);
fin >> str;
}
if(str[0]== '/' && str[1] == '/'){
getline(fin,str);
// cout << str << endl;
fin >> str;
}
if(str == "/*"){
while(true){
getline(fin,str);
if(str[str.size()-2] =='*' && str[str.size()-1] == '/'){
break;
}
}
fin >> str;
}
}
// cout<<v[0]<<endl;
set<string> s;
set<char> s1;
for (int i = 0; i < v.size(); i++){
string str;
// cout<<v[i]<<endl;
for (int j = 0; j < v[i].size(); j++){
if(special_char(v[i][j])){
s.insert(str);
//keywprds
//string pk = "(Keyword,"int"";
//cout<<"(keyword, "<< str << ")" <<endl;
if(str.size() > 2)
{
cout<<"(keyword = "<< str << ")" <<endl;
}
if(str.size() <2 || str !=" " )
{
cout<<"( constant = " <<str<<" )"<<endl;
}
if(str=="break")
{
break;
}
str.clear();
s1.insert(v[i][j]);
char l1 ,l2 ,l3 ,l4 ,l5 ,l6 ,l7;
l1 = '(';
l2 = ')';
l3 = '{';
l4 = '}';
l5 = '+';
l6 = '-';
// cout<<v[i][j]<<endl;
char ch = v[i][j];
// cout<<ch<<endl;
if(ch == '(' || ch ==')' || ch == '}' || ch== '{' || ch=='&' || ch==',' || ch == ':')
{
cout<<"(specific symbol = " <<ch<<")"<<endl;
}else{
cout<<"(operator = "<<ch<<")"<<endl;
}
} else{
str = str + v[i][j];
}
}
s.insert(str);
if(str=="break")
{
break;
}
if(str.size()>2 )
{
cout<<"(keyword = "<<str<<")"<<endl;
}
if(str.size() <2 )
{
cout<<"( constant = " <<str<<" )"<<endl;
}
}
return 0;
}