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
|
#include <iostream>
#include <vector>
std::vector<std::vector<std::string> > LoadClasses() {
std::string keywords[] = {"keyword:", "global", "local", "as", "bool", "decimal", "number", "text"};
std::string operators[] = {"operator:", "=", "\\+", "-", "\\*", "\\/", "\\^"};
std::string boolean[] = {"bool:", "true", "false"};
std::string number[] = {"number:", "\\d"};
std::string decimal[] = {"decimal:", "\\d+(\\.\\d)?"};
std::string whitespace[] = {"whitespace:", "\\s"};
std::string identifier[] = {"identifier:", "[a-zA-Z_][a-zA-Z_0-9]*"};
const std::string *ptr[] = {keywords,operators,boolean,number,decimal,whitespace,identifier};
const int size[] = {8,7,3,2,2,2,2};
std::vector<std::vector<std::string> > t_vects;
for(int i = 0; i < 7; ++i){
std::vector<std::string> t_str;
for(int j = 0; j < size[i];++j)
t_str.push_back(ptr[i][j]);
t_vects.push_back(t_str);
}
return t_vects;
}
int main()
{
std::vector<std::vector<std::string> > vect;
vect = LoadClasses();
for(int i=0;i<vect.size();++i)
for(int j=0;j<vect[i].size();++j)
std::cout<<vect[i][j]<<std::endl;
std::cout<<"Console exit >> Press enter: ";
std::cin.get();
return 0;
}
|
keyword:
global
local
as
bool
decimal
number
text
operator:
=
\+
-
\*
\/
\^
bool:
true
false
number:
\d
decimal:
\d+(\.\d)?
whitespace:
\s
identifier:
[a-zA-Z_][a-zA-Z_0-9]*
Console exit >> Press enter: | |