Professional Documents
Culture Documents
Lab 04 - Lexemes, Identifiers, Keywords TASK 01:: Source Code
Lab 04 - Lexemes, Identifiers, Keywords TASK 01:: Source Code
Lab 04 - Lexemes, Identifiers, Keywords TASK 01:: Source Code
Source code:
#include <iostream>
#include <string>
#include <vector>
int main()
{
cout << "Enter a string seperated by whitespace" << '\n';
string input;
getline(cin, input);
cin.get();
return 0;
}
return word_list;
Malik Hamza Ali Nasir 02-134191-099
TASK 02: Use task one code to split input stream and then write a method to recognize valid identifiers
of C++.
Source code:
#include <iostream>
#include <string>
#include <vector>
#include <regex>
int main()
{
cout << "Enter a string of identifiers seperated by whitespace" << '\n';
string input;
getline(cin, input);
cin.get();
return 0;
}
if (is_valid_identifier(tmp))
{
word_list.push_back(tmp);
}
return word_list;
}
int main()
{
cout << "Enter a string to identify valid keywords and identifiers" << '\n';
string in;
getline(cin, in);
{
if (is_valid_keyword(s))
{
cout << s << " is a valid keyword" << '\n';
}
else
{
if (is_valid_identifier(s))
{
cout << s << " is a valid identifier" << '\n';
}
else
{
cout << s << " is an invalid identifier" << '\n';
}
}
}
cin.get();
return 0;
}
return false;
}
return words;
}