#include <sys/stat.h>
#include <fcntl.h>
-#include "Cycript.tab.hh"
-
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <dlfcn.h>
-#include "Replace.hpp"
#include "Display.hpp"
+#include "Replace.hpp"
+
+#include "Cycript.tab.hh"
+#include "Driver.hpp"
static volatile enum {
Working,
@if Bison24 }
@if Bison24 %code requires {
+#include "Driver.hpp"
#include "Parser.hpp"
#define CYNew new($pool)
--- /dev/null
+/* Cycript - Optimizing JavaScript Compiler/Runtime
+ * Copyright (C) 2009-2013 Jay Freeman (saurik)
+*/
+
+/* GNU General Public License, Version 3 {{{ */
+/*
+ * Cycript is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * Cycript is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cycript. If not, see <http://www.gnu.org/licenses/>.
+**/
+/* }}} */
+
+#include "Cycript.tab.hh"
+#include "Driver.hpp"
+
+CYDriver::CYDriver(std::istream &data, const std::string &filename) :
+ state_(CYClear),
+ data_(data),
+ strict_(false),
+ commented_(false),
+ filename_(filename),
+ program_(NULL),
+ auto_(false),
+ context_(NULL),
+ mode_(AutoNone)
+{
+ memset(&no_, 0, sizeof(no_));
+ in_.push(false);
+ ScannerInit();
+}
+
+CYDriver::~CYDriver() {
+ ScannerDestroy();
+}
+
+void CYDriver::Warning(const cy::location &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);
+}
--- /dev/null
+/* Cycript - Optimizing JavaScript Compiler/Runtime
+ * Copyright (C) 2009-2013 Jay Freeman (saurik)
+*/
+
+/* GNU General Public License, Version 3 {{{ */
+/*
+ * Cycript is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * Cycript is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cycript. If not, see <http://www.gnu.org/licenses/>.
+**/
+/* }}} */
+
+#ifndef CYCRIPT_DRIVER_HPP
+#define CYCRIPT_DRIVER_HPP
+
+#include <iostream>
+
+#include <stack>
+#include <string>
+#include <vector>
+
+#include "location.hh"
+
+#include "Parser.hpp"
+
+enum CYState {
+ CYClear,
+ CYRestricted,
+ CYNewLine
+};
+
+class CYDriver {
+ public:
+ void *scanner_;
+
+ CYState state_;
+ std::stack<bool> in_;
+
+ struct {
+ bool AtImplementation;
+ bool Function;
+ bool OpenBrace;
+ } no_;
+
+ std::istream &data_;
+
+ bool strict_;
+ bool commented_;
+
+ enum Condition {
+ RegExpCondition,
+ XMLContentCondition,
+ XMLTagCondition,
+ };
+
+ std::string filename_;
+
+ struct Error {
+ bool warning_;
+ cy::location location_;
+ std::string message_;
+ };
+
+ typedef std::vector<Error> Errors;
+
+ CYProgram *program_;
+ Errors errors_;
+
+ bool auto_;
+
+ struct Context {
+ CYExpression *context_;
+
+ Context(CYExpression *context) :
+ context_(context)
+ {
+ }
+
+ typedef std::vector<CYWord *> Words;
+ Words words_;
+ };
+
+ typedef std::vector<Context> Contexts;
+ Contexts contexts_;
+
+ CYExpression *context_;
+
+ enum Mode {
+ AutoNone,
+ AutoPrimary,
+ AutoDirect,
+ AutoIndirect,
+ AutoMessage
+ } mode_;
+
+ private:
+ void ScannerInit();
+ void ScannerDestroy();
+
+ public:
+ CYDriver(std::istream &data, const std::string &filename = "");
+ ~CYDriver();
+
+ Condition GetCondition();
+ void SetCondition(Condition condition);
+
+ void PushCondition(Condition condition);
+ void PopCondition();
+
+ void Warning(const cy::location &location, const char *message);
+};
+
+#endif/*CYCRIPT_DRIVER_HPP*/
#include <cmath>
#include "Parser.hpp"
-#include "Cycript.tab.hh"
#include "Error.hpp"
#include "JavaScript.hpp"
**/
/* }}} */
-#include "cycript.hpp"
-#include "JavaScript.hpp"
-
-#include "Pooling.hpp"
-#include "Parser.hpp"
-
-#include "Cycript.tab.hh"
-
#include <Foundation/Foundation.h>
#include <pthread.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/un.h>
+#include "cycript.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_;
/* }}} */
#include "Highlight.hpp"
+#include "Parser.hpp"
#include "Cycript.tab.hh"
-#include "Parser.hpp"
+#include "Driver.hpp"
static void Skip(const char *data, size_t size, std::ostream &output, size_t &offset, cy::position ¤t, cy::position target) {
while (current.line != target.line || current.column != target.column) {
#include <sstream>
#include <cmath>
-#include "Parser.hpp"
-#include "Cycript.tab.hh"
-
#include "Error.hpp"
-#include "String.hpp"
#include "Execute.hpp"
#include "JavaScript.hpp"
+#include "Parser.hpp"
+#include "String.hpp"
+
+#include "Cycript.tab.hh"
+#include "Driver.hpp"
#include "ConvertUTF.h"
libcycript_la_LDFLAGS = $(CY_LDFLAGS)
libcycript_la_LIBADD = $(LTLIBFFI) -ldl
-libcycript_la_SOURCES = ConvertUTF.c Highlight.cpp Network.cpp Output.cpp Parser.cpp Replace.cpp
+libcycript_la_SOURCES = ConvertUTF.c Driver.cpp Highlight.cpp Network.cpp Output.cpp Parser.cpp Replace.cpp
libcycript_la_SOURCES += Cycript.tab.cc lex.cy.cpp
filters = $(CY_FILTERS)
lex.cy.cpp: Cycript.l
$(FLEX) -t $< | $(SED) -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
-Console.$(OBJEXT) Execute.lo Handler.lo Highlight.lo Library.lo Output.lo Parser.lo lex.cy.lo: Cycript.tab.hh
+Console.$(OBJEXT) Cycript.tab.lo Driver.lo Handler.lo Highlight.lo Library.lo lex.cy.lo: Cycript.tab.hh
CLEANFILES += Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh Cycript.output
Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh Cycript.output: Cycript.yy
@CY_OBJECTIVEC_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1)
libcycript_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_2) $(am__DEPENDENCIES_3)
-am__libcycript_la_SOURCES_DIST = ConvertUTF.c Highlight.cpp \
+am__libcycript_la_SOURCES_DIST = ConvertUTF.c Driver.cpp Highlight.cpp \
Network.cpp Output.cpp Parser.cpp Replace.cpp Cycript.tab.cc \
lex.cy.cpp sig/ffi_type.cpp sig/parse.cpp sig/copy.cpp \
Bridge.cpp Execute.cpp JavaScriptCore.cpp Library.cpp \
@CY_OBJECTIVEC_TRUE@ ObjectiveC/Replace.lo \
@CY_OBJECTIVEC_TRUE@ ObjectiveC/Library.lo
@CY_MACH_TRUE@am__objects_3 = Handler.lo
-am_libcycript_la_OBJECTS = ConvertUTF.lo Highlight.lo Network.lo \
- Output.lo Parser.lo Replace.lo Cycript.tab.lo lex.cy.lo \
- $(am__objects_1) $(am__objects_2) $(am__objects_3)
+am_libcycript_la_OBJECTS = ConvertUTF.lo Driver.lo Highlight.lo \
+ Network.lo Output.lo Parser.lo Replace.lo Cycript.tab.lo \
+ lex.cy.lo $(am__objects_1) $(am__objects_2) $(am__objects_3)
libcycript_la_OBJECTS = $(am_libcycript_la_OBJECTS)
libcycript_la_LINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(OBJCXXLD) $(AM_OBJCXXFLAGS) \
libcycript_la_LDFLAGS = $(CY_LDFLAGS)
libcycript_la_LIBADD = $(LTLIBFFI) -ldl $(am__append_3) \
$(am__append_9)
-libcycript_la_SOURCES = ConvertUTF.c Highlight.cpp Network.cpp \
- Output.cpp Parser.cpp Replace.cpp Cycript.tab.cc lex.cy.cpp \
- $(am__append_2) $(am__append_8) $(am__append_10)
+libcycript_la_SOURCES = ConvertUTF.c Driver.cpp Highlight.cpp \
+ Network.cpp Output.cpp Parser.cpp Replace.cpp Cycript.tab.cc \
+ lex.cy.cpp $(am__append_2) $(am__append_8) $(am__append_10)
filters = $(CY_FILTERS) $(am__append_5) $(am__append_7)
@CY_CONSOLE_TRUE@cycript_SOURCES = Console.cpp Display.cpp \
@CY_CONSOLE_TRUE@ $(am__append_11)
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConvertUTF.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cycript.tab.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Display.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Driver.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Execute.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Handler.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Highlight.Plo@am__quote@
lex.cy.cpp: Cycript.l
$(FLEX) -t $< | $(SED) -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
-Console.$(OBJEXT) Execute.lo Handler.lo Highlight.lo Library.lo Output.lo Parser.lo lex.cy.lo: Cycript.tab.hh
+Console.$(OBJEXT) Cycript.tab.lo Driver.lo Handler.lo Highlight.lo Library.lo lex.cy.lo: Cycript.tab.hh
Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh Cycript.output: Cycript.yy
$(BISON) -v --report=state $<
! grep -n '^ *$$default reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Cycript.output -B 2 | grep 'shift, and go to state [0-9]*$$'
**/
/* }}} */
-#include "Cycript.tab.hh"
#include "Parser.hpp"
CYRange DigitRange_ (0x3ff000000000000LLU, 0x000000000000000LLU); // 0-9
CYRange WordStartRange_(0x000001000000000LLU, 0x7fffffe87fffffeLLU); // A-Za-z_$
CYRange WordEndRange_ (0x3ff001000000000LLU, 0x7fffffe87fffffeLLU); // A-Za-z_$0-9
-
-CYDriver::CYDriver(std::istream &data, const std::string &filename) :
- state_(CYClear),
- data_(data),
- strict_(false),
- commented_(false),
- filename_(filename),
- program_(NULL),
- auto_(false),
- context_(NULL),
- mode_(AutoNone)
-{
- memset(&no_, 0, sizeof(no_));
- in_.push(false);
- ScannerInit();
-}
-
-CYDriver::~CYDriver() {
- ScannerDestroy();
-}
-
-void CYDriver::Warning(const cy::location &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);
-}
#include <iostream>
-#include <stack>
#include <string>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
-#include "location.hh"
-
#include "List.hpp"
#include "Pooling.hpp"
#include "Options.hpp"
virtual void Output(CYOutput &out, CYFlags flags) const;
};
-enum CYState {
- CYClear,
- CYRestricted,
- CYNewLine
-};
-
class CYStream :
public std::istream
{
}
};
-class CYDriver {
- public:
- void *scanner_;
-
- CYState state_;
- std::stack<bool> in_;
-
- struct {
- bool AtImplementation;
- bool Function;
- bool OpenBrace;
- } no_;
-
- std::istream &data_;
-
- bool strict_;
- bool commented_;
-
- enum Condition {
- RegExpCondition,
- XMLContentCondition,
- XMLTagCondition,
- };
-
- std::string filename_;
-
- struct Error {
- bool warning_;
- cy::location location_;
- std::string message_;
- };
-
- typedef std::vector<Error> Errors;
-
- CYProgram *program_;
- Errors errors_;
-
- bool auto_;
-
- struct Context {
- CYExpression *context_;
-
- Context(CYExpression *context) :
- context_(context)
- {
- }
-
- typedef std::vector<CYWord *> Words;
- Words words_;
- };
-
- typedef std::vector<Context> Contexts;
- Contexts contexts_;
-
- CYExpression *context_;
-
- enum Mode {
- AutoNone,
- AutoPrimary,
- AutoDirect,
- AutoIndirect,
- AutoMessage
- } mode_;
-
- private:
- void ScannerInit();
- void ScannerDestroy();
-
- public:
- CYDriver(std::istream &data, const std::string &filename = "");
- ~CYDriver();
-
- Condition GetCondition();
- void SetCondition(Condition condition);
-
- void PushCondition(Condition condition);
- void PopCondition();
-
- void Warning(const cy::location &location, const char *message);
-};
-
struct CYForInitialiser {
virtual ~CYForInitialiser() {
}