Token *Token_create(String *value, int line, int column) { Token *token = calloc(1, sizeof(Token)); check_mem(token); object_value(token) = value; token_line(token) = line; token_column(token) = column; return token; error: return NULL; }
static void tokenize(string fname, vector< vector<string> > & tokens) { ifstream fr(fname.c_str()); string line; while(fr.good()) { getline(fr, line); if(line[0] == '#') continue; istringstream s_line; vector<string> token_line(0); s_line.str(line); string token; while( s_line >> token ) { token_line.push_back(token); } if(token_line.size()==0) continue; tokens.push_back(token_line); } };