From 066da9f6509588c09b1fd2a9ec6872303af4af3c Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 6 Jun 2012 14:00:59 -0700 Subject: [PATCH] Remove CYDriver::statement_: we always have lookahead. --- Cycript.l.in | 7 +++---- Cycript.yy.in | 24 ++++++++++-------------- Parser.cpp | 1 - Parser.hpp | 1 - 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/Cycript.l.in b/Cycript.l.in index e109ca9..b53159c 100644 --- a/Cycript.l.in +++ b/Cycript.l.in @@ -30,7 +30,6 @@ typedef cy::parser::token tk; #define F(value) do { \ int token(value); \ - yyextra->statement_ = false; \ return token; \ } while (false) @@ -238,7 +237,7 @@ XMLName {XMLNameStart}{XMLNamePart}* "(" L C F(tk::OpenParen); ")" L C F(tk::CloseParen); -"{" L C F(yyextra->statement_ ? tk::OpenBrace__ : yylval->newline_ ? tk::OpenBrace_ : tk::OpenBrace); +"{" L C F(yylval->newline_ ? tk::OpenBrace_ : tk::OpenBrace); "}" L C F(tk::CloseBrace); "[" L C F(tk::OpenBracket); @@ -250,7 +249,7 @@ XMLName {XMLNameStart}{XMLNamePart}* @begin ObjectiveC "@end" L C F(tk::AtEnd); -"@implementation" L C F(yyextra->statement_ ? tk::AtImplementation_ : tk::AtImplementation); +"@implementation" L C F(tk::AtImplementation); "@import" L C F(tk::AtImport); "@selector" L C F(tk::AtSelector); @end @@ -269,7 +268,7 @@ XMLName {XMLNameStart}{XMLNamePart}* "else" L C I(word, Word("else"), tk::Else); "finally" L C I(word, Word("finally"), tk::Finally); "for" L C I(word, Word("for"), tk::For); -"function" L C I(word, Word("function"), yyextra->statement_ ? tk::Function_ : tk::Function); +"function" L C I(word, Word("function"), tk::Function); "if" L C I(word, Word("if"), tk::If); "in" L C I(word, Word("in"), yyextra->in_.top() ? tk::In_ : tk::In); "instanceof" L C I(word, Word("instanceof"), tk::InstanceOf); diff --git a/Cycript.yy.in b/Cycript.yy.in index 803cffb..f65cfd5 100644 --- a/Cycript.yy.in +++ b/Cycript.yy.in @@ -525,20 +525,16 @@ LexSetRegExp ; LexSetStatement - : { - if (yychar == 0) - driver.statement_ = true; - else switch (yychar) { - case token::Function: - yychar = token::Function_; - break; - - case token::OpenBrace: - case token::OpenBrace_: - yychar = token::OpenBrace__; - break; - } - } + : { switch (yychar) { + case token::Function: + yychar = token::Function_; + break; + + case token::OpenBrace: + case token::OpenBrace_: + yychar = token::OpenBrace__; + break; + } } ; /* }}} */ diff --git a/Parser.cpp b/Parser.cpp index 2e951f3..fae6bf3 100644 --- a/Parser.cpp +++ b/Parser.cpp @@ -28,7 +28,6 @@ CYRange WordEndRange_ (0x3ff001000000000LLU, 0x7fffffe87fffffeLLU); // A-Za-z_$ CYDriver::CYDriver(const std::string &filename) : state_(CYClear), - statement_(false), data_(NULL), size_(0), file_(NULL), diff --git a/Parser.hpp b/Parser.hpp index d809e77..53320a3 100644 --- a/Parser.hpp +++ b/Parser.hpp @@ -451,7 +451,6 @@ class CYDriver { void *scanner_; CYState state_; - bool statement_; std::stack in_; const char *data_; -- 2.45.2