29 if (file_reader_->ReadFile(filename, &contents, &read_err) !=
31 *err =
"loading '" + filename +
"': " + read_err;
33 parent->
Error(
string(*err), err);
37 return Parse(filename, contents, err);
42 if (token != expected) {
46 return lexer_.Error(message, err);
#define METRIC_RECORD_IF(name, condition)
A variant of METRIC_RECORD that doesn't record anything if |condition| is false.
static const char * TokenName(Token t)
Return a human-readable form of a token, used in error messages.
static const char * TokenErrorHint(Token expected)
Return a human-readable token hint, used in error messages.
bool Error(const std::string &message, std::string *err)
Construct an error message with context.
bool Load(const std::string &filename, std::string *err, Lexer *parent=NULL)
Load and parse a file.
bool ExpectToken(Lexer::Token expected, std::string *err)
If the next token is not expected, produce an error string saying "expected foo, got bar".