Cycript.tab.*
Cycript.output
Bridge.gperf
-location.hh
-position.hh
stack.hh
sysroot.ios
sysroot.sim
if (parser.parse() != 0 || !driver.errors_.empty()) {
for (CYDriver::Errors::const_iterator error(driver.errors_.begin()); error != driver.errors_.end(); ++error) {
- cy::position begin(error->location_.begin);
+ CYPosition begin(error->location_.begin);
if (begin.line != lines.size() || begin.column < lines.back().size() || error->warning_) {
- cy::position end(error->location_.end);
+ CYPosition end(error->location_.end);
if (begin.line != lines.size()) {
std::cerr << " | ";
#pragma clang diagnostic ignored "-Wdeprecated-register"
#endif
-#define YYLTYPE cy::location
+#define YYLTYPE CYLocation
#include "Cycript.tab.hh"
typedef cy::parser::token tk;
#define L { \
yylloc->step(); \
- yylloc->columns(yyleng); \
+ yylloc->end.columns(yyleng); \
}
#define M { \
}
%code provides {
-int cylex(YYSTYPE *, cy::location *, void *);
+int cylex(YYSTYPE *, CYLocation *, void *);
}
%name-prefix "cy"
%locations
%defines
+%define api.location.type { CYLocation }
+
//%glr-parser
//%expect 1
ScannerDestroy();
}
-void CYDriver::Warning(const cy::location &location, const char *message) {
+void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
if (!strict_)
return;
#include <string>
#include <vector>
-#include "location.hh"
-
+#include "Location.hpp"
#include "Parser.hpp"
enum CYState {
struct Error {
bool warning_;
- cy::location location_;
+ CYLocation location_;
std::string message_;
};
void PushCondition(Condition condition);
void PopCondition();
- void Warning(const cy::location &location, const char *message);
+ void Warning(const CYLocation &location, const char *message);
};
#endif/*CYCRIPT_DRIVER_HPP*/
#include "Driver.hpp"
#include "Code.hpp"
-static void Skip(const char *data, size_t size, std::ostream &output, size_t &offset, cy::position ¤t, cy::position target) {
+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) {
_assert(offset != size);
char next(data[offset++]);
driver.commented_ = true;
size_t offset(0);
- cy::position current;
+ CYPosition current;
CYLocalPool pool;
YYSTYPE value;
- cy::location location;
+ CYLocation location;
while (cylex(&value, &location, driver.scanner_) != 0) {
CYColor color;
--- /dev/null
+/* Cycript - Optimizing JavaScript Compiler/Runtime
+ * Copyright (C) 2009-2014 Jay Freeman (saurik)
+*/
+
+/* GNU Affero General Public License, Version 3 {{{ */
+/*
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * This program 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 Affero General Public License for more details.
+
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+**/
+/* }}} */
+
+#ifndef CYCRIPT_LOCATION_HPP
+#define CYCRIPT_LOCATION_HPP
+
+#include <iostream>
+
+class CYPosition {
+ public:
+ std::string *filename;
+ unsigned int line;
+ unsigned int column;
+
+ CYPosition() :
+ filename(NULL),
+ line(1),
+ column(0)
+ {
+ }
+
+ void lines(unsigned count = 1) {
+ column = 0;
+ line += count;
+ }
+
+ void columns(unsigned count = 1) {
+ column += count;
+ }
+};
+
+inline std::ostream &operator <<(std::ostream &out, const CYPosition &position) {
+ if (position.filename != NULL)
+ out << *position.filename << ":";
+ out << position.line << "." << position.column;
+ return out;
+}
+
+class CYLocation {
+ public:
+ CYPosition begin;
+ CYPosition end;
+
+ void step() {
+ begin = end;
+ }
+};
+
+inline std::ostream &operator <<(std::ostream &out, const CYLocation &location) {
+ const CYPosition &begin(location.begin);
+ const CYPosition &end(location.end);
+
+ out << begin;
+ if (end.filename != NULL && (begin.filename == NULL || *begin.filename != *end.filename))
+ out << '-' << *end.filename << ':' << end.line << '.' << end.column;
+ else if (begin.line != end.line)
+ out << '-' << end.line << '.' << end.column;
+ else if (begin.column != end.column)
+ out << '-' << end.column;
+ return out;
+}
+
+#endif/*CYCRIPT_LOCATION_HPP*/
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
+CLEANFILES += Cycript.tab.cc Cycript.tab.hh stack.hh Cycript.output
+Cycript.tab.cc Cycript.tab.hh stack.hh Cycript.output: Cycript.yy
$(BISON) -v --report=state $<
! grep -n '^State [0-9]* conflicts:' Cycript.output
! grep -n '^ *$$default reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Cycript.output -B 2 | grep 'shift, and go to state [0-9]*$$'
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = subdir-objects
CLEANFILES = $(am__append_5) Cycript.yy Cycript.l lex.cy.cpp \
- Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh \
- Cycript.output
+ Cycript.tab.cc Cycript.tab.hh stack.hh Cycript.output
SUBDIRS =
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = -I$(srcdir)/include -DYYDEBUG=1 -include config.h \
$(FLEX) -t $< | $(SED) -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
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
+Cycript.tab.cc Cycript.tab.hh stack.hh Cycript.output: Cycript.yy
$(BISON) -v --report=state $<
! grep -n '^State [0-9]* conflicts:' Cycript.output
! grep -n '^ *$$default reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Cycript.output -B 2 | grep 'shift, and go to state [0-9]*$$'