X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/5602b1eebd5c9733b58795485c6a592c6e77b4d8..e28525029ea8f7c63494fbb1464c7c5414f4390e:/Parser.hpp
diff --git a/Parser.hpp b/Parser.hpp
index ba896b7..9dbb9b9 100644
--- a/Parser.hpp
+++ b/Parser.hpp
@@ -1,20 +1,20 @@
/* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2012 Jay Freeman (saurik)
+ * Copyright (C) 2009-2013 Jay Freeman (saurik)
*/
-/* GNU Lesser General Public License, Version 3 {{{ */
+/* GNU General Public License, Version 3 {{{ */
/*
- * Cycript is free software: you can redistribute it and/or modify it under
- * the terms of the GNU Lesser 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 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 Lesser General Public
- * License for more details.
+ * 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 Lesser General Public License
+ * You should have received a copy of the GNU General Public License
* along with Cycript. If not, see .
**/
/* }}} */
@@ -39,7 +39,7 @@
#include "Pooling.hpp"
#include "Options.hpp"
-class CYContext;
+struct CYContext;
struct CYThing {
virtual ~CYThing() {
@@ -469,6 +469,27 @@ enum CYState {
CYNewLine
};
+class CYStream :
+ public std::istream
+{
+ private:
+ class CYBuffer :
+ public std::streambuf
+ {
+ public:
+ CYBuffer(const char *start, const char *end) {
+ setg(const_cast(start), const_cast(start), const_cast(end));
+ }
+ } buffer_;
+
+ public:
+ CYStream(const char *start, const char *end) :
+ std::istream(&buffer_),
+ buffer_(start, end)
+ {
+ }
+};
+
class CYDriver {
public:
void *scanner_;
@@ -482,11 +503,10 @@ class CYDriver {
bool OpenBrace;
} no_;
- const char *data_;
- size_t size_;
- FILE *file_;
+ std::istream &data_;
bool strict_;
+ bool commented_;
enum Condition {
RegExpCondition,
@@ -539,7 +559,7 @@ class CYDriver {
void ScannerDestroy();
public:
- CYDriver(const std::string &filename = "");
+ CYDriver(std::istream &data, const std::string &filename = "");
~CYDriver();
Condition GetCondition();