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 &, assign_list 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 1030 of file remake.cpp.

1031 {
1032  Success,
1033  SyntaxError,
1034  Eof
1035 };

Function Documentation

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

Definition at line 1206 of file remake.cpp.

1207  : gen(top.in, top.local_variables)
1208 {
1209  if (!read_words(gen, pre)) return;
1210  if (!expect_token(gen.in, Comma)) return;
1211  prej = 0;
1212  prel = pre.size();
1213  ok = true;
1214 }
addsuffix_generator::addsuffix_generator ( input_generator const &  top,
bool &  ok 
)

Definition at line 1262 of file remake.cpp.

1263  : gen(top.in, top.local_variables)
1264 {
1265  if (!read_words(gen, suf)) return;
1266  if (!expect_token(gen.in, Comma)) return;
1267  sufj = 0;
1268  sufl = suf.size();
1269  ok = true;
1270 }
generator * get_function ( input_generator const &  in,
std::string const &  name 
)
static

Return a generator for function name.

Definition at line 1302 of file remake.cpp.

Referenced by input_generator::next().

1303 {
1304  skip_spaces(in.in);
1305  generator *g = NULL;
1306  bool ok = false;
1307  if (name == "addprefix") g = new addprefix_generator(in, ok);
1308  else if (name == "addsuffix") g = new addsuffix_generator(in, ok);
1309  if (!g || ok) return g;
1310  delete g;
1311  return NULL;
1312 }
input_status variable_generator::next ( std::string &  res)
virtual

Implements generator.

Definition at line 1094 of file remake.cpp.

1095 {
1096  restart:
1097  if (cur1 != end1)
1098  {
1099  res = *cur1;
1100  ++cur1;
1101  return Success;
1102  }
1103  while (cur2 != end2)
1104  {
1105  if (cur2->name == name)
1106  {
1107  cur1 = cur2->value.begin();
1108  end1 = cur2->value.end();
1109  ++cur2;
1110  goto restart;
1111  }
1112  ++cur2;
1113  }
1114  return Eof;
1115 }
input_status input_generator::next ( std::string &  res)

Definition at line 1134 of file remake.cpp.

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

1135 {
1136  if (nested)
1137  {
1138  restart:
1139  input_status s = nested->next(res);
1140  if (s == Success) return Success;
1141  delete nested;
1142  nested = NULL;
1143  if (s == SyntaxError) return SyntaxError;
1144  }
1145  if (done) return Eof;
1146  if (earliest_exit) done = true;
1147  switch (expect_token(in, Word | Dollarpar))
1148  {
1149  case Word:
1150  res = read_word(in);
1151  return Success;
1152  case Dollarpar:
1153  {
1154  std::string name = read_word(in);
1155  if (name.empty()) return SyntaxError;
1156  if (expect_token(in, Rightpar))
1158  else
1159  {
1160  nested = get_function(*this, name);
1161  if (!nested) return SyntaxError;
1162  }
1163  goto restart;
1164  }
1165  default:
1166  return Eof;
1167  }
1168 }
input_status addprefix_generator::next ( std::string &  res)
virtual

Implements generator.

Definition at line 1216 of file remake.cpp.

1217 {
1218  if (prej)
1219  {
1220  produce:
1221  if (prej == prel)
1222  {
1223  res = *prei + suf;
1224  prej = 0;
1225  }
1226  else
1227  {
1228  res = *prei++;
1229  ++prej;
1230  }
1231  return Success;
1232  }
1233  switch (gen.next(res))
1234  {
1235  case Success:
1236  if (!prel) return Success;
1237  prei = pre.begin();
1238  prej = 1;
1239  suf = res;
1240  goto produce;
1241  case Eof:
1242  return expect_token(gen.in, Rightpar) ? Eof : SyntaxError;
1243  default:
1244  return SyntaxError;
1245  }
1246 }
input_status addsuffix_generator::next ( std::string &  res)
virtual

Implements generator.

Definition at line 1272 of file remake.cpp.

1273 {
1274  if (sufj)
1275  {
1276  if (sufj != sufl)
1277  {
1278  res = *sufi++;
1279  ++sufj;
1280  return Success;
1281  }
1282  sufj = 0;
1283  }
1284  switch (gen.next(res))
1285  {
1286  case Success:
1287  if (!sufl) return Success;
1288  sufi = suf.begin();
1289  sufj = 1;
1290  res += *sufi++;
1291  return Success;
1292  case Eof:
1293  return expect_token(gen.in, Rightpar) ? Eof : SyntaxError;
1294  default:
1295  return SyntaxError;
1296  }
1297 }
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 1174 of file remake.cpp.

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

1175 {
1176  while (true)
1177  {
1178  res.push_back(std::string());
1179  input_status s = in.next(res.back());
1180  if (s == Success) continue;
1181  res.pop_back();
1182  return s == Eof;
1183  }
1184 }
static bool read_words ( std::istream &  in,
string_list res 
)
static

Definition at line 1186 of file remake.cpp.

1187 {
1188  input_generator gen(in, NULL);
1189  return read_words(gen, res);
1190 }
variable_generator::variable_generator ( std::string const &  n,
assign_list const *  local_variables 
)

Definition at line 1058 of file remake.cpp.

1059  : name(n)
1060 {
1061  bool append = true;
1062  if (local_variables)
1063  {
1064  // Set cur2 to the last variable overwriter, if any.
1065  cur2 = local_variables->begin();
1066  end2 = local_variables->end();
1067  for (assign_list::const_iterator i = cur2; i != end2; ++i)
1068  {
1069  if (i->name == name && !i->append)
1070  {
1071  append = false;
1072  cur2 = i;
1073  }
1074  }
1075  }
1076  else
1077  {
1078  static assign_list dummy;
1079  cur2 = dummy.begin();
1080  end2 = dummy.end();
1081  }
1082  static string_list dummy;
1083  cur1 = dummy.begin();
1084  end1 = dummy.end();
1085  if (append)
1086  {
1087  variable_map::const_iterator i = variables.find(name);
1088  if (i == variables.end()) return;
1089  cur1 = i->second.begin();
1090  end1 = i->second.end();
1091  }
1092 }