Remake
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Enumerations | Functions
Token streams

Classes

struct  generator
 
struct  variable_generator
 
struct  input_generator
 
struct  addprefix_generator
 
struct  addsuffix_generator
 

Enumerations

enum  input_status { Success, SyntaxError, Eof }
 

Functions

static generatorget_function (input_generator const &, std::string const &)
 
static bool read_words (input_generator &in, string_list &res)
 
static bool read_words (std::istream &in, string_list &res)
 
 variable_generator::variable_generator (std::string const &, variable_map const *)
 
input_status variable_generator::next (std::string &)
 
input_status input_generator::next (std::string &)
 
 addprefix_generator::addprefix_generator (input_generator const &, bool &)
 
input_status addprefix_generator::next (std::string &)
 
 addsuffix_generator::addsuffix_generator (input_generator const &, bool &)
 
input_status addsuffix_generator::next (std::string &)
 

Detailed Description

Enumeration Type Documentation

Possible results from word producers.

Enumerator
Success 
SyntaxError 
Eof 

Definition at line 1150 of file remake.cpp.

1151 {
1152  Success,
1153  SyntaxError,
1154  Eof
1155 };

Function Documentation

addprefix_generator::addprefix_generator ( input_generator const &  top,
bool &  ok 
)

Definition at line 1296 of file remake.cpp.

1297  : gen(top.in, top.local_variables)
1298 {
1299  if (!read_words(gen, pre)) return;
1300  if (!expect_token(gen.in, Comma)) return;
1301  prej = 0;
1302  prel = pre.size();
1303  ok = true;
1304 }
addsuffix_generator::addsuffix_generator ( input_generator const &  top,
bool &  ok 
)

Definition at line 1352 of file remake.cpp.

1353  : gen(top.in, top.local_variables)
1354 {
1355  if (!read_words(gen, suf)) return;
1356  if (!expect_token(gen.in, Comma)) return;
1357  sufj = 0;
1358  sufl = suf.size();
1359  ok = true;
1360 }
static generator * get_function ( input_generator const &  in,
std::string const &  name 
)
static

Return a generator for function name.

Definition at line 1392 of file remake.cpp.

Referenced by input_generator::next().

1393 {
1394  skip_spaces(in.in);
1395  generator *g = NULL;
1396  bool ok = false;
1397  if (name == "addprefix") g = new addprefix_generator(in, ok);
1398  else if (name == "addsuffix") g = new addsuffix_generator(in, ok);
1399  if (!g || ok) return g;
1400  delete g;
1401  return NULL;
1402 }
input_status variable_generator::next ( std::string &  res)
virtual

Implements generator.

Definition at line 1196 of file remake.cpp.

1197 {
1198  if (vcur != vend)
1199  {
1200  res = *vcur;
1201  ++vcur;
1202  return Success;
1203  }
1204  return Eof;
1205 }
input_status input_generator::next ( std::string &  res)

Definition at line 1224 of file remake.cpp.

Referenced by addprefix_generator::next(), addsuffix_generator::next(), prepare_script(), and read_words().

1225 {
1226  if (nested)
1227  {
1228  restart:
1229  input_status s = nested->next(res);
1230  if (s == Success) return Success;
1231  delete nested;
1232  nested = NULL;
1233  if (s == SyntaxError) return SyntaxError;
1234  }
1235  if (done) return Eof;
1236  if (earliest_exit) done = true;
1237  switch (expect_token(in, Word | Dollarpar))
1238  {
1239  case Word:
1240  res = read_word(in, false);
1241  return Success;
1242  case Dollarpar:
1243  {
1244  std::string name = read_word(in, false);
1245  if (name.empty()) return SyntaxError;
1246  if (expect_token(in, Rightpar))
1248  else
1249  {
1250  nested = get_function(*this, name);
1251  if (!nested) return SyntaxError;
1252  }
1253  goto restart;
1254  }
1255  default:
1256  return Eof;
1257  }
1258 }
input_status addprefix_generator::next ( std::string &  res)
virtual

Implements generator.

Definition at line 1306 of file remake.cpp.

1307 {
1308  if (prej)
1309  {
1310  produce:
1311  if (prej == prel)
1312  {
1313  res = *prei + suf;
1314  prej = 0;
1315  }
1316  else
1317  {
1318  res = *prei++;
1319  ++prej;
1320  }
1321  return Success;
1322  }
1323  switch (gen.next(res))
1324  {
1325  case Success:
1326  if (!prel) return Success;
1327  prei = pre.begin();
1328  prej = 1;
1329  suf = res;
1330  goto produce;
1331  case Eof:
1332  return expect_token(gen.in, Rightpar) ? Eof : SyntaxError;
1333  default:
1334  return SyntaxError;
1335  }
1336 }
input_status addsuffix_generator::next ( std::string &  res)
virtual

Implements generator.

Definition at line 1362 of file remake.cpp.

1363 {
1364  if (sufj)
1365  {
1366  if (sufj != sufl)
1367  {
1368  res = *sufi++;
1369  ++sufj;
1370  return Success;
1371  }
1372  sufj = 0;
1373  }
1374  switch (gen.next(res))
1375  {
1376  case Success:
1377  if (!sufl) return Success;
1378  sufi = suf.begin();
1379  sufj = 1;
1380  res += *sufi++;
1381  return Success;
1382  case Eof:
1383  return expect_token(gen.in, Rightpar) ? Eof : SyntaxError;
1384  default:
1385  return SyntaxError;
1386  }
1387 }
static bool read_words ( input_generator in,
string_list res 
)
static

Read a list of words from an input generator.

Returns
false if a syntax error was encountered.

Definition at line 1264 of file remake.cpp.

Referenced by addprefix_generator::addprefix_generator(), addsuffix_generator::addsuffix_generator(), load_dependencies(), load_rule(), load_rules(), main(), and read_words().

1265 {
1266  while (true)
1267  {
1268  res.push_back(std::string());
1269  input_status s = in.next(res.back());
1270  if (s == Success) continue;
1271  res.pop_back();
1272  return s == Eof;
1273  }
1274 }
static bool read_words ( std::istream &  in,
string_list res 
)
static

Definition at line 1276 of file remake.cpp.

1277 {
1278  input_generator gen(in, NULL);
1279  return read_words(gen, res);
1280 }
variable_generator::variable_generator ( std::string const &  n,
variable_map const *  local_variables 
)

Definition at line 1177 of file remake.cpp.

1178  : name(n)
1179 {
1180  if (local_variables)
1181  {
1182  variable_map::const_iterator i = local_variables->find(name);
1183  if (i != local_variables->end())
1184  {
1185  vcur = i->second.begin();
1186  vend = i->second.end();
1187  return;
1188  }
1189  }
1190  variable_map::const_iterator i = variables.find(name);
1191  if (i == variables.end()) return;
1192  vcur = i->second.begin();
1193  vend = i->second.end();
1194 }