#include "cycript.hpp"
#include "Driver.hpp"
-#include "Cycript.tab.hh"
#include "Replace.hpp"
#include "String.hpp"
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;
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)
#include "Display.hpp"
#include "Driver.hpp"
#include "Highlight.hpp"
-#include "Replace.hpp"
+#include "Parser.hpp"
static volatile enum {
Working,
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
%token _case_ "case"
%token _catch_ "catch"
%token _class_ "class"
-%token _class__ "!class"
+%token _class__ ";class"
%token _const_ "const"
%token _continue_ "continue"
%token _debugger_ "debugger"
| "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"); }
;
/* }}} */
-/* 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)); }
/* }}} */
%%
+
+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);
+}
**/
/* }}} */
-#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),
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);
-}
#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,
#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_;
**/
/* }}} */
+#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 ¤t, CYPosition target) {
while (current.line != target.line || current.column != target.column) {
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;
#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 <>
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;
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
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