Compiler Design (Exp 1)
Compiler Design (Exp 1) Task - To print the count of the number of keywords, identifiers, operators, and symbols after reading a line of code as input, then store each of these in an array and display them as an output. Logic - Accept STRING input using getline(). Make a function 'to_vector()' to store each element of the input as a vector element. Call each function keyword(), identifier(), operator() and symbols(). Traverse the vector elements for each function call and see if there is a particular match. Increase the count and display as required. Declare global vector variables to store these details separately. #include <bits/stdc++.h> using namespace std ; vector < string > keys; vector < string > oper; vector < string > ident; vector < string > syms; vector < string > to_vector ( string input ) { vector < string > temp; int k = 0 ; for ( int i = 0 ;i < input . length ();i ++ ) { string part