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 1029 of file remake.cpp.

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

Function Documentation

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

Definition at line 1205 of file remake.cpp.

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

Definition at line 1261 of file remake.cpp.

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

Return a generator for function name.

Definition at line 1301 of file remake.cpp.

Referenced by input_generator::next().

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

Implements generator.

Definition at line 1093 of file remake.cpp.

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

Definition at line 1133 of file remake.cpp.

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

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

Implements generator.

Definition at line 1215 of file remake.cpp.

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

Implements generator.

Definition at line 1271 of file remake.cpp.

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

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

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

Definition at line 1185 of file remake.cpp.

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

Definition at line 1057 of file remake.cpp.

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