From: Jay Freeman (saurik) Date: Thu, 1 Oct 2009 21:30:23 +0000 (+0000) Subject: Support tokenization errors. X-Git-Tag: v0.9.432~388 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/94d55b5c2b4cd5c317891dfbdd6c6186e1759101?ds=sidebyside Support tokenization errors. --- diff --git a/Application.mm b/Application.mm index 1739471..56a3cc1 100644 --- a/Application.mm +++ b/Application.mm @@ -65,7 +65,7 @@ int main(int argc, const char *argv[]) { driver.data_ = command.c_str(); driver.size_ = command.size(); - if (parser.parse() != 0) { + if (parser.parse() != 0 || !driver.errors_.empty()) { for (CYDriver::Errors::const_iterator i(driver.errors_.begin()); i != driver.errors_.end(); ++i) { cy::position begin(i->location_.begin); if (begin.line != lines.size() || begin.column - 1 != lines.back().size()) { diff --git a/Cycript.l b/Cycript.l index 13ae15e..4a54403 100644 --- a/Cycript.l +++ b/Cycript.l @@ -196,7 +196,14 @@ Escape \\[\\'"bfnrtv]|\\0|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4} [ \t] L <> L yyterminate(); -. yyterminate(); + +. { + CYDriver::Error error; + error.location_ = *yylloc; + error.message_ = "syntax error, unknown token"; + yyextra->errors_.push_back(error); + yyterminate(); +} %%