]> git.saurik.com Git - cycript.git/commitdiff
Limit recompilation of files upon changed grammar.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 2 Dec 2015 03:09:29 +0000 (19:09 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 2 Dec 2015 03:09:29 +0000 (19:09 -0800)
Complete.cpp
Console.cpp
Cycript.l.in
Cycript.yy.in
Driver.cpp
Driver.hpp
Handler.cpp
Highlight.cpp
Library.cpp
Makefile.am
Makefile.in

index 3d14193817461c6948b27fc9c34c5c735a1dc72d..c81f90eb15cde39166ce5967b61ead5298679c5e 100644 (file)
@@ -22,7 +22,6 @@
 #include "cycript.hpp"
 
 #include "Driver.hpp"
-#include "Cycript.tab.hh"
 #include "Replace.hpp"
 #include "String.hpp"
 
@@ -30,9 +29,7 @@ static CYExpression *ParseExpression(CYPool &pool, CYUTF8String code) {
     std::stringstream stream;
     stream << '(' << code << ')';
     CYDriver driver(pool, stream);
-
-    cy::parser parser(driver);
-    if (parser.parse() != 0 || !driver.errors_.empty())
+    if (driver.Parse() || !driver.errors_.empty())
         return NULL;
 
     CYOptions options;
@@ -59,8 +56,7 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
 
     driver.auto_ = true;
 
-    cy::parser parser(driver);
-    if (parser.parse() != 0 || !driver.errors_.empty())
+    if (driver.Parse() || !driver.errors_.empty())
         return NULL;
 
     if (driver.mode_ == CYDriver::AutoNone)
index a191fc079eaf864df912b6b0f2c5d4c2f760a493..57f437555c13467b3bae0e7cb222834e4cb7951e 100644 (file)
@@ -69,7 +69,7 @@
 #include "Display.hpp"
 #include "Driver.hpp"
 #include "Highlight.hpp"
-#include "Replace.hpp"
+#include "Parser.hpp"
 
 static volatile enum {
     Working,
index 03f82ce4aaab0034654bc74237ca03571782b155..55502d4361ab9fc1b250fa0cb50ce9f6e7dc8ad7 100644 (file)
@@ -677,6 +677,14 @@ void CYDriver::PopCondition() {
     yy_pop_state(scanner_);
 }
 
+bool CYLexerHighlight(hi::Value &highlight, CYLocation &location, void *scanner) {
+    YYSTYPE value;
+    if (cylex(&value, &location, scanner) == 0)
+        return false;
+    highlight = value.highlight_;
+    return true;
+}
+
 #if defined(__clang__)
 #pragma clang diagnostic pop
 #else
index d8aee240546683919906b6a819632315e00cab44..295fa8104c1f9eddbdbf016a81f566739209b786 100644 (file)
@@ -297,7 +297,7 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %token _case_ "case"
 %token _catch_ "catch"
 %token _class_ "class"
-%token _class__ "!class"
+%token _class__ ";class"
 %token _const_ "const"
 %token _continue_ "continue"
 %token _debugger_ "debugger"
@@ -692,7 +692,7 @@ Word
     | "case" { $$ = CYNew CYWord("case"); }
     | "catch" { $$ = CYNew CYWord("catch"); }
     | "class" { $$ = CYNew CYWord("class"); }
-    | "!class" { $$ = CYNew CYWord("class"); }
+    | ";class" { $$ = CYNew CYWord("class"); }
     | "const" { $$ = CYNew CYWord("const"); }
     | "continue" { $$ = CYNew CYWord("continue"); }
     | "debugger" { $$ = CYNew CYWord("debugger"); }
@@ -962,7 +962,7 @@ TemplateSpans
     ;
 /* }}} */
 
-/* 12.3+ Left-Hand-Side Expressions {{{ */
+/* 12.3 Left-Hand-Side Expressions {{{ */
 MemberAccess
     : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
     | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
@@ -2334,3 +2334,32 @@ PostfixExpression
 /* }}} */
 
 %%
+
+bool CYDriver::Parse(CYMark mark) {
+    mark_ = mark;
+    CYLocal<CYPool> local(&pool_);
+    cy::parser parser(*this);
+#ifdef YYDEBUG
+    parser.set_debug_level(debug_);
+#endif
+    return parser.parse() != 0;
+}
+
+void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
+    if (!strict_)
+        return;
+
+    CYDriver::Error error;
+    error.warning_ = true;
+    error.location_ = location;
+    error.message_ = message;
+    errors_.push_back(error);
+}
+
+void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
+    CYDriver::Error error;
+    error.warning_ = false;
+    error.location_ = location;
+    error.message_ = message;
+    driver.errors_.push_back(error);
+}
index eab0bb90276a89ed09ac3a96eae99325e8bf2416..4bac2c2a920f1092c16e07f179ed0e25da5556ff 100644 (file)
 **/
 /* }}} */
 
-#include "Cycript.tab.hh"
 #include "Driver.hpp"
+#include "Parser.hpp"
+
+bool CYParser(CYPool &pool, bool debug);
 
 CYDriver::CYDriver(CYPool &pool, std::istream &data, const std::string &filename) :
     pool_(pool),
@@ -49,37 +51,8 @@ CYDriver::~CYDriver() {
     ScannerDestroy();
 }
 
-bool CYDriver::Parse(CYMark mark) {
-    mark_ = mark;
-    CYLocal<CYPool> local(&pool_);
-    cy::parser parser(*this);
-#ifdef YYDEBUG
-    parser.set_debug_level(debug_);
-#endif
-    return parser.parse() != 0;
-}
-
 void CYDriver::Replace(CYOptions &options) {
     CYLocal<CYPool> local(&pool_);
     CYContext context(options);
     script_->Replace(context);
 }
-
-void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
-    if (!strict_)
-        return;
-
-    CYDriver::Error error;
-    error.warning_ = true;
-    error.location_ = location;
-    error.message_ = message;
-    errors_.push_back(error);
-}
-
-void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
-    CYDriver::Error error;
-    error.warning_ = false;
-    error.location_ = location;
-    error.message_ = message;
-    driver.errors_.push_back(error);
-}
index 0df39d7dd9242a49f2500b3930a2810daabf3753..fbc96d931a53a672fae24c799f7fa2397992c519 100644 (file)
 #include <vector>
 
 #include "Location.hpp"
-#include "Parser.hpp"
+#include "Options.hpp"
+#include "Pooling.hpp"
+#include "Standard.hpp"
+
+struct CYExpression;
+struct CYScript;
+struct CYWord;
 
 enum CYMark {
     CYMarkIgnore,
index d048d83f60bade37e25b05bcecf7f0dd7fdca5bb..2a17d61d0d9d4d9b399a71fefa757b03dcca8ae1 100644 (file)
 
 #include "cycript.hpp"
 
+#include "Driver.hpp"
 #include "JavaScript.hpp"
 #include "Parser.hpp"
 #include "Pooling.hpp"
 
-#include "Cycript.tab.hh"
-#include "Driver.hpp"
-
 struct CYExecute_ {
     CYPool &pool_;
     const char * volatile data_;
index 9c95728dd906d81a968c2c9bf5c7a274e772e672..addd757ec19f3cc47e14d02061441cd4626ea493 100644 (file)
 **/
 /* }}} */
 
+#include "Code.hpp"
+#include "Driver.hpp"
 #include "Highlight.hpp"
-#include "Parser.hpp"
 
-#include "Cycript.tab.hh"
-#include "Driver.hpp"
-#include "Code.hpp"
+bool CYLexerHighlight(hi::Value &highlight, CYLocation &location, void *scanner);
 
 static void Skip(const char *data, size_t size, std::ostream &output, size_t &offset, CYPosition &current, CYPosition target) {
     while (current.line != target.line || current.column != target.column) {
@@ -65,13 +64,13 @@ _visible void CYLexerHighlight(const char *data, size_t size, std::ostream &outp
     size_t offset(0);
     CYPosition current;
 
-    YYSTYPE value;
+    hi::Value highlight;
     CYLocation location;
 
-    while (cylex(&value, &location, driver.scanner_) != 0) {
+    while (CYLexerHighlight(highlight, location, driver.scanner_)) {
         CYColor color;
 
-        switch (value.highlight_) {
+        switch (highlight) {
             case hi::Comment: color = CYColor(true, 30); break;
             case hi::Constant: color = CYColor(false, 31); break;
             case hi::Control: color = CYColor(false, 33); break;
index 9ed238dc8892976b5387812977027076031770ab..e8e70d6599eaacaaf9d7a2ade647beab36f0dbb1 100644 (file)
 #include <sstream>
 #include <cmath>
 
+#include "Driver.hpp"
 #include "Error.hpp"
 #include "Execute.hpp"
 #include "Parser.hpp"
 #include "String.hpp"
 
-#include "Cycript.tab.hh"
-#include "Driver.hpp"
-
 #include "ConvertUTF.h"
 
 template <>
@@ -220,9 +218,7 @@ double CYCastDouble(const char *value) {
 CYUTF8String CYPoolCode(CYPool &pool, std::istream &stream) {
     CYLocalPool local;
     CYDriver driver(local, stream);
-
-    cy::parser parser(driver);
-    _assert(parser.parse() == 0);
+    _assert(!driver.Parse());
     _assert(driver.errors_.empty());
 
     CYOptions options;
index 09f002ca0a440b5e58fd5d1f1cc08cb2605da650..d89c83f0e57b80f928d261d7132b49c35c6696c7 100644 (file)
@@ -109,7 +109,7 @@ lex.cy.cpp: Cycript.l
        grep -F 'No backing up.' lex.backup >/dev/null
        ! grep -F ': warning, ' lex.output || true
 
-Console.$(OBJEXT) Cycript.tab.lo Driver.lo Handler.lo Highlight.lo Library.lo lex.cy.lo: Cycript.tab.hh
+lex.cy.lo: Cycript.tab.hh
 
 CLEANFILES += Cycript.tab.cc Cycript.tab.hh stack.hh Cycript.output
 Cycript.tab.cc Cycript.tab.hh stack.hh Cycript.output: Cycript.yy
index 73835063afe3bacad37d1247debdfec36274a34e..ba8d8f51e2a7925fa3a84c034cdf445d94b75064 100644 (file)
@@ -1335,7 +1335,7 @@ lex.cy.cpp: Cycript.l
        grep -F 'No backing up.' lex.backup >/dev/null
        ! grep -F ': warning, ' lex.output || true
 
-Console.$(OBJEXT) Cycript.tab.lo Driver.lo Handler.lo Highlight.lo Library.lo lex.cy.lo: Cycript.tab.hh
+lex.cy.lo: Cycript.tab.hh
 Cycript.tab.cc Cycript.tab.hh stack.hh Cycript.output: Cycript.yy
        $(BISON) -v --report=state -Werror $<
        ! grep -n '^State [0-9]* conflicts:' Cycript.output