1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
enum TokenType
{
ID=0,
KeyWord=1,
Operator=2,
Expression=3,
String=4,
Number=5,
Integer=5,
Float=6,
Char=7
};
friend ostream &operator << ( ostream& strm, TokenType tt )
{
const string nameTT[] = { "ID", "KeyWord", "Operator", "Expression", "String", "Integer", "Float", "Char" };
return strm << nameTT[tt];
}
string &operator = (const TokenType &tt )
{
const string nameTT[] = { "ID", "KeyWord", "Operator", "Expression", "String", "Integer", "Float", "Char" };
string resulted=nameTT[tt];
return resulted;
}
struct TokensType
{
string Token="";
TokenType Type;
friend ostream & operator<<(ostream &os, TokensType &err )
{
os << "Token: " << err.Token << "\n";
os << "Token Type: " << err.Type << "\n";
return os;
}
friend ostream & operator<<(ostream &os, vector<TokensType> &err )
{
for (unsigned int i=0; i<err.size(); i++)
{
os << "Token: " << err[i].Token << "\n";
os << "Token Type: " << err[i].Type << "\n";
if(i<err.size()-1)
os << "\n";
}
return os;
}
};
//........
void RulesMath(vector<TokensType> CodeLine, unsigned int intCodeLine)
{
int VarNameIndex = IsVarName(CodeLine[0].Token);
string VarType=CodeLine[0].Type;//is what i need, but the 'Type' it's TokenType enum
|