From 94d55b5c2b4cd5c317891dfbdd6c6186e1759101 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 1 Oct 2009 21:30:23 +0000 Subject: [PATCH] Support tokenization errors. --- Application.mm | 2 +- Cycript.l | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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(); +} %% -- 2.45.2