From d8258c35d5ca21f08beceadd365816353f5695b8 Mon Sep 17 00:00:00 2001 From: Marty R Date: Wed, 15 Oct 2014 21:30:25 -0700 Subject: [PATCH 01/27] nut: New package for Network UPS Tools An older version of nut is in oldpackages. This commit is based on that package and bumps the version to the latest release along with unifying the server and client packages. More build options are provided for any custom configuration but the defaults provide a working client and server install which only needs a UPS driver. Drivers still build as individual packages to minimise bloat. SSL support has also been added. Signed-off-by: Martin Rowe --- net/nut/Config.in | 107 +++++++ net/nut/Makefile | 279 ++++++++++++++++++ net/nut/files/nut-monitor.init | 21 ++ net/nut/files/nut-server.init | 23 ++ .../001-fix-missing-libmath-flags.patch | 22 ++ .../patches/010-ignore_automake_k_bug.patch | 28 ++ 6 files changed, 480 insertions(+) create mode 100644 net/nut/Config.in create mode 100644 net/nut/Makefile create mode 100755 net/nut/files/nut-monitor.init create mode 100755 net/nut/files/nut-server.init create mode 100644 net/nut/patches/001-fix-missing-libmath-flags.patch create mode 100644 net/nut/patches/010-ignore_automake_k_bug.patch diff --git a/net/nut/Config.in b/net/nut/Config.in new file mode 100644 index 000000000..b37dbca01 --- /dev/null +++ b/net/nut/Config.in @@ -0,0 +1,107 @@ + config NUT_SERVER + depends on PACKAGE_nut + bool "Include server components (upsd)" + help + upsd is responsible for serving the data from the drivers to the + clients. It connects to each driver and maintains a local cache of the + current state. Queries from the clients are served from this cache, so + delays are minimal. This program is essential, and must be running at + all times to actually make any use out of the drivers and clients. + default y + + config NUT_CLIENTS_UPSC + depends on PACKAGE_nut + bool "Include command line client (upsc)" + help + upsc is provided as a quick way to poll the status of a UPS server. It + can be used inside shell scripts and other programs that need UPS data + but don't want to include the full interface. + default y + + config NUT_CLIENTS_UPSLOG + depends on PACKAGE_nut + bool "Include logging client (upslog)" + help + upslog is a daemon that will poll a UPS at periodic intervals, fetch the + variables that interest you, format them, and write them to a file. + default n + + config NUT_CLIENTS_UPSCMD + depends on PACKAGE_nut + bool "Include UPS controller (upscmd)" + help + upscmd allows you to invoke "instant commands" in your UPS hardware. Not + all hardware supports this, so check the list with -l to see if anything + will work on your equipment. On hardware that supports it, you can use + this program to start and stop battery tests, invoke a front panel test + (beep!), turn the load on or off, and more. + default n + + config NUT_CLIENTS_UPSRW + depends on PACKAGE_nut + bool "Include UPS variable editor (upsrw)" + help + upsrw allows you to view and change the read/write variables inside your + UPS. It sends commands via the upsd to your driver, which configures the + hardware for you. The list of variables that allow you to change their + values is based on the capabilities of your UPS equipment. Not all + models support this feature. Typically, cheaper hardware does not + support any of them. + default n + + config NUT_CLIENTS_UPSMON + depends on PACKAGE_nut + bool "Include monitor and shutdown controller (upsmon)" + help + upsmon is the client process that is responsible for the most important + part of UPS monitoring--shutting down the system when the power goes + out. It can call out to other helper programs for notification purposes + during power events. upsmon can monitor multiple systems using a single + process. Every UPS that is defined in the upsmon.conf configuration file + is assigned a power value and a type (slave or master). + default y + + config NUT_CLIENTS_UPSSCHED + depends on NUT_CLIENTS_UPSMON + bool "Include helper for triggering events from upsmon (upssched)" + help + upssched was created to allow users to execute programs at times relative + to events being monitored by upsmon. The original purpose was to allow + for a shutdown to occur after some fixed period on battery, but there are + other uses that are possible. + You can alternatively write your own script and save some space. + default n + + config NUT_SSL + depends on PACKAGE_nut + bool "Build with support for OpenSSL" + help + SSL allows sessions between upsd and clients to be encrypted and can + also be used to authenticate servers. This means that stealing port + 3493 from upsd will no longer net you interesting passwords. SSL is + available via OpenSSL on OpenWRT (NSS doesn't seem to work). If you + are happy with using passwords to authenticate clients, you can save + some space and build NUT without SSL support. + default n + + config NUT_DRIVER_SERIAL + depends on PACKAGE_nut + bool "Build with support for serial drivers" + help + If you have a UPS connected via serial, select this. + default n + + config NUT_DRIVER_USB + depends on PACKAGE_nut + bool "Build with support for USB drivers" + help + If you have a UPS connected via USB, select this. + default y + + config NUT_DRIVER_SNMP + depends on PACKAGE_nut + bool "Build with support for SNMP drivers" + help + If you have a UPS you can connect to via SNMP, select this. + default n + diff --git a/net/nut/Makefile b/net/nut/Makefile new file mode 100644 index 000000000..41e00b719 --- /dev/null +++ b/net/nut/Makefile @@ -0,0 +1,279 @@ +# +# Copyright (C) 2006 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=nut +PKG_VERSION:=2.7.2 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.networkupstools.org/source/2.7/ +PKG_MD5SUM:=c3568b42e058cfc385b46d25140dced4 +PKG_MAINTAINER:=Martin Rowe +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:=LICENSE-GPL2 + +PKG_BUILD_DIR:=$(BUILD_DIR)/nut-$(PKG_VERSION) +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/nut/Default + SECTION:=net + CATEGORY:=Network + URL:=http://www.networkupstools.org/ + DEPENDS:=nut +endef + +define Package/nut/description +Network UPS Tools (NUT) is a client/server monitoring system that +allows computers to share uninterruptible power supply (UPS) and +power distribution unit (PDU) hardware. Clients access the hardware +through the server, and are notified whenever the power status +changes. +endef + +define Package/nut + $(call Package/nut/Default) + TITLE:=Network UPS Tools + DEPENDS:= \ + +NUT_DRIVER_SNMP:libnetsnmp \ + +NUT_DRIVER_USB:libusb-compat \ + +NUT_SSL:libopenssl + MENU:=1 +endef + +define Package/nut/config + source "$(SOURCE)/Config.in" +endef + +define Package/nut/conffiles + /etc/nut/nut.conf + $(if $(CONFIG_NUT_CLIENTS_UPSMON),/etc/nut/upsmon.conf) + $(if $(CONFIG_NUT_CLIENTS_UPSSCHED),/etc/nut/upssched.conf) + $(if $(CONFIG_NUT_SERVER),/etc/nut/ups.conf) + $(if $(CONFIG_NUT_SERVER),/etc/nut/upsd.conf) + $(if $(CONFIG_NUT_SERVER),/etc/nut/upsd.users) +endef + +define Package/nut/install + $(INSTALL_DIR) $(1)/etc/nut + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/nut.conf.sample $(1)/etc/nut/nut.conf + $(if $(or $(CONFIG_NUT_CLIENTS_UPSC),\ + $(CONFIG_NUT_CLIENTS_UPSCMD),\ + $(CONFIG_NUT_CLIENTS_LOG),\ + $(CONFIG_NUT_CLIENTS_UPSRW),\ + $(CONFIG_NUT_CLIENTS_UPSMON),\ + $(CONFIG_NUT_CLIENTS_UPSSCHED)),$(CP) $(PKG_INSTALL_DIR)/usr/lib/libupsclient.so* $(1)/usr/lib/) + $(if $(or $(CONFIG_NUT_SERVER),\ + $(CONFIG_NUT_CLIENTS_UPSMON)),$(INSTALL_DIR) $(1)/etc/init.d) + $(if $(CONFIG_NUT_SERVER),$(INSTALL_DIR) $(1)/lib/nut) + $(if $(CONFIG_NUT_SERVER),$(INSTALL_DIR) $(1)/usr/share/nut) + $(if $(CONFIG_NUT_SERVER),$(CP) ./files/nut-server.init $(1)/etc/init.d/) + $(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upsd $(1)/usr/sbin) + $(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upsdrvctl $(1)/usr/sbin) + $(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/share/nut/cmdvartab $(1)/usr/share/nut/) + $(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/share/nut/driver.list $(1)/usr/share/nut/) + $(if $(CONFIG_NUT_SERVER),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/ups.conf.sample $(1)/etc/nut/ups.conf) + $(if $(CONFIG_NUT_SERVER),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsd.conf.sample $(1)/etc/nut/upsd.conf) + $(if $(CONFIG_NUT_SERVER),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsd.users.sample $(1)/etc/nut/upsd.users) + $(if $(CONFIG_NUT_CLIENTS_UPSC),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upsc $(1)/usr/bin/) + $(if $(CONFIG_NUT_CLIENTS_UPSCMD),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upscmd $(1)/usr/bin/) + $(if $(CONFIG_NUT_CLIENTS_LOG),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upslog $(1)/usr/bin/) + $(if $(CONFIG_NUT_CLIENTS_UPSRW),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upsrw $(1)/usr/bin/) + $(if $(CONFIG_NUT_CLIENTS_UPSMON),$(CP) ./files/nut-monitor.init $(1)/etc/init.d/) + $(if $(CONFIG_NUT_CLIENTS_UPSMON),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upsmon $(1)/usr/sbin/) + $(if $(CONFIG_NUT_CLIENTS_UPSMON),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsmon.conf.sample $(1)/etc/nut/upsmon.conf) + $(if $(CONFIG_NUT_CLIENTS_UPSSCHED),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upssched-cmd $(1)/usr/bin/) + $(if $(CONFIG_NUT_CLIENTS_UPSSCHED),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upssched $(1)/usr/sbin/) + $(if $(CONFIG_NUT_CLIENTS_UPSSCHED),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upssched.conf.sample $(1)/etc/nut/upssched.conf) +endef + +# Dealing with all of the drivers is very repetitive, but the previous +# maintainer had a neat solution which just needed some tweaking. +define DriverPackage + define Package/nut-driver-$(2) + $(call Package/nut/Default) + TITLE:=$(2) (NUT $(1) driver) + $(if $(filter $(1),serial),DEPENDS+= @NUT_DRIVER_SERIAL) + $(if $(filter $(1),snmp),DEPENDS+= @NUT_DRIVER_SNMP) + $(if $(filter $(1),usb),DEPENDS+= @NUT_DRIVER_USB) + endef + # Deliberately empty description in order to trigger a build failure. + # It should be overridden by the list below, and when updating to a + # new version of nut we will need to provide descriptions for any new + # drivers. + define Package/nut-driver-$(2)/description + + endef + define Package/nut-driver-$(2)/install + $(INSTALL_DIR) $$(1)/lib/nut + $(CP) $$(PKG_INSTALL_DIR)/lib/nut/$(2) $$(1)/lib/nut/ + $(if $(filter $(2),clone),$(CP) $$(PKG_INSTALL_DIR)/lib/nut/$(2)-outlet $$(1)/lib/nut/) + endef +endef +define DriverDescription + define Package/nut-driver-$(2)/description + $(3) + endef +endef +# These lists are lifted *directly* from drivers/Makefile.am in the nut +# source tree. This it to make it simpler to keep in sync when updating +# to a newer version of nut. Do not edit this manually. +# +# DO NOT EDIT (except to update with a fresh cut/paste)! +SERIAL_DRIVERLIST = al175 bcmxcp belkin belkinunv bestfcom \ + bestfortress bestuferrups bestups dummy-ups etapro everups \ + gamatronic genericups isbmex liebert liebert-esp2 masterguard metasys \ + oldmge-shut mge-utalk microdowell mge-shut oneac optiups powercom rhino \ + safenet skel solis tripplite tripplitesu upscode2 victronups powerpanel \ + blazer_ser clone clone-outlet ivtscd apcsmart apcsmart-old apcupsd-ups riello_ser \ + nutdrv_qx +SNMP_DRIVERLIST = snmp-ups +USB_LIBUSB_DRIVERLIST = usbhid-ups bcmxcp_usb tripplite_usb \ + blazer_usb richcomm_usb riello_usb \ + nutdrv_atcl_usb \ + nutdrv_qx +# END: DO NOT EDIT! +SERIAL_DRIVERLIST_IGNORE:=skel clone-outlet nutdrv_qx +# nutdrv_qx can be either USB or serial. Given most routers have USB +# instead of serial ports, and not wanting two identical packages with +# different names that conflict with each other, only the option for the +# driver with USB bindings is provided. If you really want to save that +# tiny bit of space and build it without USB support, remove nutdrv_qx +# from the previous line. + +$(foreach d,$(filter-out $(SERIAL_DRIVERLIST_IGNORE),$(SERIAL_DRIVERLIST)),$(eval $(call DriverPackage,serial,$(d)))) +$(foreach d,$(SNMP_DRIVERLIST),$(eval $(call DriverPackage,snmp,$(d)))) +$(foreach d,$(USB_LIBUSB_DRIVERLIST),$(eval $(call DriverPackage,usb,$(d)))) + +$(eval $(call DriverDescription,serial,al175,\ + Driver for Eltek UPS models with AL175 alarm module)) +$(eval $(call DriverDescription,serial,bcmxcp,\ + Driver for UPSes supporting the serial BCM/XCP protocol)) +$(eval $(call DriverDescription,serial,belkin,\ + Driver for Belkin serial UPS equipment)) +$(eval $(call DriverDescription,serial,belkinunv,\ + Driver for Belkin "Universal UPS" and compatible)) +$(eval $(call DriverDescription,serial,bestfcom,\ + Driver for Best Power Fortress/Ferrups)) +$(eval $(call DriverDescription,serial,bestfortress,\ + Driver for old Best Fortress UPS equipment)) +$(eval $(call DriverDescription,serial,bestuferrups,\ + Driver for Best Power Micro-Ferrups)) +$(eval $(call DriverDescription,serial,bestups,\ + Driver for Best Power / SOLA (Phoenixtec protocol) UPS equipment)) +$(eval $(call DriverDescription,serial,dummy-ups,\ + Driver for multi-purpose UPS emulation)) +$(eval $(call DriverDescription,serial,etapro,\ + Driver for ETA UPS equipment)) +$(eval $(call DriverDescription,serial,everups,\ + Driver for Ever UPS models)) +$(eval $(call DriverDescription,serial,gamatronic,\ + Driver for Gamatronic UPS equipment)) +$(eval $(call DriverDescription,serial,genericups,\ + Driver for contact-closure UPS equipment)) +$(eval $(call DriverDescription,serial,isbmex,\ + Driver for ISBMEX UPS equipment)) +$(eval $(call DriverDescription,serial,liebert,\ + Driver for Liebert contact-closure UPS equipment)) +$(eval $(call DriverDescription,serial,liebert-esp2,\ + Driver for Liebert UPS, using the ESP-II serial protocol)) +$(eval $(call DriverDescription,serial,masterguard,\ + Driver for Masterguard UPS equipment)) +$(eval $(call DriverDescription,serial,metasys,\ + Driver for Meta System UPS equipment)) +$(eval $(call DriverDescription,serial,oldmge-shut,\ + Driver for SHUT Protocol UPS equipment, deprecated, use mge-shut)) +$(eval $(call DriverDescription,serial,mge-utalk,\ + Driver for MGE UPS SYSTEMS UTalk protocol equipment)) +$(eval $(call DriverDescription,serial,microdowell,\ + Driver for Microdowell Enterprise UPS series)) +$(eval $(call DriverDescription,serial,mge-shut,\ + Driver for SHUT Protocol UPS equipment)) +$(eval $(call DriverDescription,serial,oneac,\ + Driver for Oneac UPS equipment)) +$(eval $(call DriverDescription,serial,optiups,\ + Driver for Opti-UPS (Viewsonic) UPS and Zinto D (ONLINE-USV) equipment)) +$(eval $(call DriverDescription,serial,powercom,\ + Driver for serial Powercom/Trust/Advice UPS equipment)) +$(eval $(call DriverDescription,serial,rhino,\ + Driver for Brazilian Microsol RHINO UPS equipment)) +$(eval $(call DriverDescription,serial,safenet,\ + Driver for SafeNet compatible UPS equipment)) +$(eval $(call DriverDescription,serial,solis,\ + Driver for Brazilian Microsol SOLIS UPS equipment)) +$(eval $(call DriverDescription,serial,tripplite,\ + Driver for Tripp-Lite SmartPro UPS equipment)) +$(eval $(call DriverDescription,serial,tripplitesu,\ + Driver for Tripp-Lite SmartOnline (SU) UPS equipment)) +$(eval $(call DriverDescription,serial,upscode2,\ + Driver for UPScode II compatible UPS equipment)) +$(eval $(call DriverDescription,serial,victronups,\ + Driver for IMV/Victron UPS unit Match, Match Lite, NetUps)) +$(eval $(call DriverDescription,serial,powerpanel,\ + Driver for PowerPanel Plus compatible UPS equipment)) +$(eval $(call DriverDescription,serial,blazer_ser,\ + Driver for Megatec/Q1 protocol serial based UPS equipment)) +$(eval $(call DriverDescription,serial,clone,\ + UPS driver clone)) +$(eval $(call DriverDescription,serial,ivtscd,\ + Driver for the IVT Solar Controller Device)) +$(eval $(call DriverDescription,serial,apcsmart,\ + Driver for American Power Conversion Smart Protocol UPS equipment)) +$(eval $(call DriverDescription,serial,apcsmart-old,\ + Driver for American Power Conversion Smart Protocol UPS equipment)) +$(eval $(call DriverDescription,serial,apcupsd-ups,\ + Driver for apcupsd client access)) +$(eval $(call DriverDescription,serial,riello_ser,\ + Driver for Riello UPS Protocol UPS equipment)) +$(eval $(call DriverDescription,snmp,snmp-ups,\ + Multi-MIB Driver for SNMP UPS equipment)) +$(eval $(call DriverDescription,usb,usbhid-ups,\ + Driver for USB/HID UPS equipment)) +$(eval $(call DriverDescription,usb,bcmxcp_usb,\ + Experimental driver for UPSes supporting the BCM/XCP protocol over USB)) +$(eval $(call DriverDescription,usb,tripplite_usb,\ + Driver for older Tripp Lite USB UPSes (not PDC HID))) +$(eval $(call DriverDescription,usb,blazer_usb,\ + Driver for Megatec/Q1 protocol USB based UPS equipment)) +$(eval $(call DriverDescription,usb,richcomm_usb,\ + Driver for UPS equipment using Richcomm dry-contact to USB solution)) +$(eval $(call DriverDescription,usb,riello_usb,\ + Driver for Riello UPS Protocol UPS equipment via USB)) +$(eval $(call DriverDescription,usb,nutdrv_atcl_usb,\ + Driver for ATCL FOR UPS equipment)) +$(eval $(call DriverDescription,usb,nutdrv_qx,\ + Driver for Q* protocol serial and USB based UPS equipment)) + +CONFIGURE_ARGS += \ + --$(if $(CONFIG_NUT_DRIVER_SERIAL),with,without)-serial \ + --$(if $(CONFIG_NUT_DRIVER_USB),with,without)-usb \ + --$(if $(CONFIG_NUT_DRIVER_SNMP),with,without)-snmp \ + --without-neon \ + --without-powerman \ + --without-ipmi \ + --without-freeipmi \ + --$(if $(CONFIG_NUT_SSL),with,without)-ssl $(if $(CONFIG_NUT_SSL),--with-openssl) \ + --without-avahi \ + --without-libltdl \ + --with-user=root \ + --with-group=root \ + --sysconfdir=/etc/nut \ + --with-drvpath=/lib/nut \ + --with-statepath=/var/run \ + --datadir=/usr/share/nut + +$(eval $(call BuildPackage,nut)) +$(foreach d,$(filter-out $(SERIAL_DRIVERLIST_IGNORE),$(SERIAL_DRIVERLIST)),$(eval $(call BuildPackage,nut-driver-$(d)))) +$(foreach d,$(SNMP_DRIVERLIST),$(eval $(call BuildPackage,nut-driver-$(d)))) +$(foreach d,$(USB_LIBUSB_DRIVERLIST),$(eval $(call BuildPackage,nut-driver-$(d)))) diff --git a/net/nut/files/nut-monitor.init b/net/nut/files/nut-monitor.init new file mode 100755 index 000000000..e9fdb336d --- /dev/null +++ b/net/nut/files/nut-monitor.init @@ -0,0 +1,21 @@ +#!/bin/sh /etc/rc.common + +START=60 +USE_PROCD=1 + +restart() { + stop_service + start_service +} + +start_service() { + upsmon -p +} + +stop_service() { + upsmon -c stop +} + +reload_service() { + upsmon -c reload +} diff --git a/net/nut/files/nut-server.init b/net/nut/files/nut-server.init new file mode 100755 index 000000000..f9971be44 --- /dev/null +++ b/net/nut/files/nut-server.init @@ -0,0 +1,23 @@ +#!/bin/sh /etc/rc.common + +START=50 +USE_PROCD=1 + +restart() { + stop_service + start_service +} + +start_service() { + upsdrvctl start + upsd +} + +stop_service() { + upsd -c stop + upsdrvctl stop +} + +reload_service() { + upsd -c reload +} diff --git a/net/nut/patches/001-fix-missing-libmath-flags.patch b/net/nut/patches/001-fix-missing-libmath-flags.patch new file mode 100644 index 000000000..88996be6e --- /dev/null +++ b/net/nut/patches/001-fix-missing-libmath-flags.patch @@ -0,0 +1,22 @@ +--- a/drivers/Makefile.am ++++ b/drivers/Makefile.am +@@ -171,7 +171,7 @@ tripplite_usb_SOURCES = tripplite_usb.c + tripplite_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm + + bcmxcp_usb_SOURCES = bcmxcp_usb.c bcmxcp.c usb-common.c +-bcmxcp_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) ++bcmxcp_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm + + blazer_usb_SOURCES = blazer.c blazer_usb.c libusb.c usb-common.c + blazer_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm +--- a/drivers/Makefile.in ++++ b/drivers/Makefile.in +@@ -785,7 +785,7 @@ usbhid_ups_LDADD = $(LDADD_DRIVERS) $(LI + tripplite_usb_SOURCES = tripplite_usb.c libusb.c usb-common.c + tripplite_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm + bcmxcp_usb_SOURCES = bcmxcp_usb.c bcmxcp.c usb-common.c +-bcmxcp_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) ++bcmxcp_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm + blazer_usb_SOURCES = blazer.c blazer_usb.c libusb.c usb-common.c + blazer_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm + nutdrv_atcl_usb_SOURCES = nutdrv_atcl_usb.c usb-common.c diff --git a/net/nut/patches/010-ignore_automake_k_bug.patch b/net/nut/patches/010-ignore_automake_k_bug.patch new file mode 100644 index 000000000..8d3645d09 --- /dev/null +++ b/net/nut/patches/010-ignore_automake_k_bug.patch @@ -0,0 +1,28 @@ +--- a/Makefile.in ++++ b/Makefile.in +@@ -431,12 +431,6 @@ distclean-libtool: + # (2) otherwise, pass the desired values on the `make' command line. + $(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ +- for f in x $$MAKEFLAGS; do \ +- case $$f in \ +- *=* | --[!k]*);; \ +- *k*) failcom='fail=yes';; \ +- esac; \ +- done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ +@@ -456,12 +450,6 @@ $(RECURSIVE_TARGETS): + + $(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ +- for f in x $$MAKEFLAGS; do \ +- case $$f in \ +- *=* | --[!k]*);; \ +- *k*) failcom='fail=yes';; \ +- esac; \ +- done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ From d2e5a9896cedfb8b5a43f416f177233e631328af Mon Sep 17 00:00:00 2001 From: cyanidium Date: Wed, 15 Oct 2014 22:09:29 -0700 Subject: [PATCH 02/27] Remove placeholder maintainer email address --- net/nut/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/nut/Makefile b/net/nut/Makefile index 41e00b719..0666dd0ee 100644 --- a/net/nut/Makefile +++ b/net/nut/Makefile @@ -14,7 +14,7 @@ PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://www.networkupstools.org/source/2.7/ PKG_MD5SUM:=c3568b42e058cfc385b46d25140dced4 -PKG_MAINTAINER:=Martin Rowe +PKG_MAINTAINER:=Martin Rowe PKG_LICENSE:=GPL-2.0 PKG_LICENSE_FILES:=LICENSE-GPL2 From 445653707786f56d70481a1ec55c7f0379f8bed7 Mon Sep 17 00:00:00 2001 From: Marcel Denia Date: Sat, 11 Oct 2014 16:53:38 +0200 Subject: [PATCH 03/27] perl: Make I8/I16/I32 types explicitly signed for PPC Type signedness is undefined for char. char may actually be unsigned for some CPUs. This fixes various bugs on PPC, like negative array indices. Signed-off-by: Marcel Denia --- lang/perl/files/config.sh-powerpc.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lang/perl/files/config.sh-powerpc.in b/lang/perl/files/config.sh-powerpc.in index 39b595516..ec935dd7c 100644 --- a/lang/perl/files/config.sh-powerpc.in +++ b/lang/perl/files/config.sh-powerpc.in @@ -600,13 +600,13 @@ html1direxp='' html3dir=' ' html3direxp='' i16size='2' -i16type='short' +i16type='signed short' i32size='4' -i32type='long' +i32type='signed long' i64size='8' -i64type='long long' +i64type='signed long long' i8size='1' -i8type='char' +i8type='signed char' i_arpainet='define' i_bsdioctl='' i_crypt='define' From ef3ac53da2b8caea33e0421c2707233d211648b6 Mon Sep 17 00:00:00 2001 From: Marcel Denia Date: Tue, 14 Oct 2014 21:16:47 +0200 Subject: [PATCH 04/27] perl: Don't try to link against libnsl And also remove all other references to avoid confusion. libnsl isn't really needed. Removing it allows glibc based toolchains to build perl. Signed-off-by: Marcel Denia --- lang/perl/files/config.sh-arm.in | 12 ++++++------ lang/perl/files/config.sh-armeb.in | 12 ++++++------ lang/perl/files/config.sh-avr32.in | 12 ++++++------ lang/perl/files/config.sh-i486.in | 12 ++++++------ lang/perl/files/config.sh-mips.in | 12 ++++++------ lang/perl/files/config.sh-mipsel.in | 12 ++++++------ lang/perl/files/config.sh-powerpc.in | 12 ++++++------ lang/perl/files/config.sh-x86_64.in | 12 ++++++------ 8 files changed, 48 insertions(+), 48 deletions(-) diff --git a/lang/perl/files/config.sh-arm.in b/lang/perl/files/config.sh-arm.in index a23a6fdc6..523fef409 100644 --- a/lang/perl/files/config.sh-arm.in +++ b/lang/perl/files/config.sh-arm.in @@ -740,12 +740,12 @@ lib_ext='.a' libc='' libperl='libperl.so' libpth='%%LIBDIRS%%' -libs='-lgdbm -ldb -lnsl -ldl -lm -lcrypt -lutil -lc' +libs='-lgdbm -ldb -ldl -lm -lcrypt -lutil -lc' libsdirs='%%LIBDIRS%%' -libsfiles=' libnsl.so libdl.so libm.so libcrypt.so libutil.so libc.so' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +libsfiles=' libdl.so libm.so libcrypt.so libutil.so libc.so' +#libsfound=' /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' libspath='%%LIBDIRS%%' -libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' +libswanted='sfio socket inet nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' libswanted_uselargefiles='' line='' lint='' @@ -829,7 +829,7 @@ perl5='' perl='' perl_patchlevel='' perladmin='root@maia.dev.null' -perllibs='-lnsl -ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' +perllibs='-ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' perlpath='/usr/bin/perl' pg='pg' phostname='hostname' @@ -1108,7 +1108,7 @@ i_stdbool='define' i_syspoll='define' #incpth='/usr/lib/gcc/i486-slackware-linux/4.8.2/include /usr/local/include /usr/lib/gcc/i486-slackware-linux/4.8.2/include-fixed /usr/include' ld_can_script='define' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +#libsfound=' /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' nv_overflows_integers_at='0' perl_static_inline='static __inline__' sGMTIME_max='2147483647' diff --git a/lang/perl/files/config.sh-armeb.in b/lang/perl/files/config.sh-armeb.in index aee8b2af6..34520fd19 100644 --- a/lang/perl/files/config.sh-armeb.in +++ b/lang/perl/files/config.sh-armeb.in @@ -740,12 +740,12 @@ lib_ext='.a' libc='' libperl='libperl.so' libpth='%%LIBDIRS%%' -libs='-lgdbm -ldb -lnsl -ldl -lm -lcrypt -lutil -lc' +libs='-lgdbm -ldb -ldl -lm -lcrypt -lutil -lc' libsdirs='%%LIBDIRS%%' -libsfiles=' libnsl.so libdl.so libm.so libcrypt.so libutil.so libc.so' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +libsfiles=' libdl.so libm.so libcrypt.so libutil.so libc.so' +#libsfound=' /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' libspath='%%LIBDIRS%%' -libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' +libswanted='sfio socket inet nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' libswanted_uselargefiles='' line='' lint='' @@ -829,7 +829,7 @@ perl5='' perl='' perl_patchlevel='' perladmin='root@maia.dev.null' -perllibs='-lnsl -ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' +perllibs='-ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' perlpath='/usr/bin/perl' pg='pg' phostname='hostname' @@ -1108,7 +1108,7 @@ i_stdbool='define' i_syspoll='define' #incpth='/usr/lib/gcc/i486-slackware-linux/4.8.2/include /usr/local/include /usr/lib/gcc/i486-slackware-linux/4.8.2/include-fixed /usr/include' ld_can_script='define' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +#libsfound=' /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' nv_overflows_integers_at='0' perl_static_inline='static __inline__' sGMTIME_max='2147483647' diff --git a/lang/perl/files/config.sh-avr32.in b/lang/perl/files/config.sh-avr32.in index 64542e8af..37a5d6c04 100644 --- a/lang/perl/files/config.sh-avr32.in +++ b/lang/perl/files/config.sh-avr32.in @@ -742,12 +742,12 @@ lib_ext='.a' libc='' libperl='libperl.so' libpth='%%LIBDIRS%%' -libs='-lgdbm -ldb -lnsl -ldl -lm -lcrypt -lutil -lc' +libs='-lgdbm -ldb -ldl -lm -lcrypt -lutil -lc' libsdirs='%%LIBDIRS%%' -libsfiles=' libnsl.so libdl.so libm.so libcrypt.so libutil.so libc.so' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +libsfiles=' libdl.so libm.so libcrypt.so libutil.so libc.so' +#libsfound=' /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' libspath='%%LIBDIRS%%' -libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' +libswanted='sfio socket inet nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' libswanted_uselargefiles='' line='' lint='' @@ -831,7 +831,7 @@ perl5='' perl='' perl_patchlevel='' perladmin='root@maia.dev.null' -perllibs='-lnsl -ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' +perllibs='-ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' perlpath='/usr/bin/perl' pg='pg' phostname='hostname' @@ -1110,7 +1110,7 @@ i_stdbool='define' i_syspoll='define' #incpth='/usr/lib/gcc/i486-slackware-linux/4.8.2/include /usr/local/include /usr/lib/gcc/i486-slackware-linux/4.8.2/include-fixed /usr/include' ld_can_script='define' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +#libsfound=' /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' nv_overflows_integers_at='0' perl_static_inline='static __inline__' sGMTIME_max='2147483647' diff --git a/lang/perl/files/config.sh-i486.in b/lang/perl/files/config.sh-i486.in index f915fd84c..f4566367a 100644 --- a/lang/perl/files/config.sh-i486.in +++ b/lang/perl/files/config.sh-i486.in @@ -733,12 +733,12 @@ lib_ext='.a' libc='' libperl='libperl.so' libpth='%%LIBDIRS%%' -libs='-lgdbm -ldb -lnsl -ldl -lm -lcrypt -lutil -lc' +libs='-lgdbm -ldb -ldl -lm -lcrypt -lutil -lc' libsdirs='%%LIBDIRS%%' -libsfiles=' libnsl.so libdl.so libm.so libcrypt.so libutil.so libc.so' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +libsfiles=' libdl.so libm.so libcrypt.so libutil.so libc.so' +#libsfound=' /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' libspath='%%LIBDIRS%%' -libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' +libswanted='sfio socket inet nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' libswanted_uselargefiles='' line='' lint='' @@ -820,7 +820,7 @@ perl5='' perl='' perl_patchlevel='' perladmin='root@maia.dev.null' -perllibs='-lnsl -ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' +perllibs='-ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' perlpath='/usr/bin/perl' pg='pg' phostname='hostname' @@ -1093,7 +1093,7 @@ i_stdbool='define' i_syspoll='define' #incpth='/usr/lib/gcc/i486-slackware-linux/4.8.2/include /usr/local/include /usr/lib/gcc/i486-slackware-linux/4.8.2/include-fixed /usr/include' ld_can_script='define' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +#libsfound=' /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' nv_overflows_integers_at='0' perl_static_inline='static __inline__' sGMTIME_max='2147483647' diff --git a/lang/perl/files/config.sh-mips.in b/lang/perl/files/config.sh-mips.in index b0eb0fe06..cb313b1e8 100644 --- a/lang/perl/files/config.sh-mips.in +++ b/lang/perl/files/config.sh-mips.in @@ -740,12 +740,12 @@ lib_ext='.a' libc='' libperl='libperl.so' libpth='%%LIBDIRS%%' -libs='-lgdbm -ldb -lnsl -ldl -lm -lcrypt -lutil -lc' +libs='-lgdbm -ldb -ldl -lm -lcrypt -lutil -lc' libsdirs='%%LIBDIRS%%' -libsfiles=' libnsl.so libdl.so libm.so libcrypt.so libutil.so libc.so' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +libsfiles=' libdl.so libm.so libcrypt.so libutil.so libc.so' +#libsfound=' /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' libspath='%%LIBDIRS%%' -libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' +libswanted='sfio socket inet nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' libswanted_uselargefiles='' line='' lint='' @@ -829,7 +829,7 @@ perl5='' perl='' perl_patchlevel='' perladmin='root@merope.dev.null' -perllibs='-lnsl -ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' +perllibs='-ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' perlpath='/usr/bin/perl' pg='pg' phostname='hostname' @@ -1108,7 +1108,7 @@ i_stdbool='define' i_syspoll='define' #incpth='/usr/lib/gcc/i486-slackware-linux/4.8.2/include /usr/local/include /usr/lib/gcc/i486-slackware-linux/4.8.2/include-fixed /usr/include' ld_can_script='define' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +#libsfound=' /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' nv_overflows_integers_at='0' perl_static_inline='static __inline__' sGMTIME_max='2147483647' diff --git a/lang/perl/files/config.sh-mipsel.in b/lang/perl/files/config.sh-mipsel.in index 557d9a199..a3e841613 100644 --- a/lang/perl/files/config.sh-mipsel.in +++ b/lang/perl/files/config.sh-mipsel.in @@ -733,12 +733,12 @@ lib_ext='.a' libc='' libperl='libperl.so' libpth='%%LIBDIRS%%' -libs='-lgdbm -ldb -lnsl -ldl -lm -lcrypt -lutil -lc' +libs='-lgdbm -ldb -ldl -lm -lcrypt -lutil -lc' libsdirs='%%LIBDIRS%%' -libsfiles=' libnsl.so libdl.so libm.so libcrypt.so libutil.so libc.so' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +libsfiles=' libdl.so libm.so libcrypt.so libutil.so libc.so' +#libsfound=' /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' libspath='%%LIBDIRS%%' -libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' +libswanted='sfio socket inet nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' libswanted_uselargefiles='' line='' lint='' @@ -820,7 +820,7 @@ perl5='' perl='' perl_patchlevel='' perladmin='root@merope.dev.null' -perllibs='-lnsl -ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' +perllibs='-ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' perlpath='/usr/bin/perl' pg='pg' phostname='hostname' @@ -1093,7 +1093,7 @@ i_stdbool='define' i_syspoll='define' #incpth='/usr/lib/gcc/i486-slackware-linux/4.8.2/include /usr/local/include /usr/lib/gcc/i486-slackware-linux/4.8.2/include-fixed /usr/include' ld_can_script='define' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +#libsfound=' /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' nv_overflows_integers_at='0' perl_static_inline='static __inline__' sGMTIME_max='2147483647' diff --git a/lang/perl/files/config.sh-powerpc.in b/lang/perl/files/config.sh-powerpc.in index ec935dd7c..acd62b7ae 100644 --- a/lang/perl/files/config.sh-powerpc.in +++ b/lang/perl/files/config.sh-powerpc.in @@ -740,12 +740,12 @@ lib_ext='.a' libc='' libperl='libperl.so' libpth='%%LIBDIRS%%' -libs='-lgdbm -ldb -lnsl -ldl -lm -lcrypt -lutil -lc' +libs='-lgdbm -ldb -ldl -lm -lcrypt -lutil -lc' libsdirs='%%LIBDIRS%%' -libsfiles=' libnsl.so libdl.so libm.so libcrypt.so libutil.so libc.so' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +libsfiles=' libdl.so libm.so libcrypt.so libutil.so libc.so' +#libsfound=' /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' libspath='%%LIBDIRS%%' -libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' +libswanted='sfio socket inet nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' libswanted_uselargefiles='' line='' lint='' @@ -829,7 +829,7 @@ perl5='' perl='' perl_patchlevel='' perladmin='root@maia.dev.null' -perllibs='-lnsl -ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' +perllibs='-ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' perlpath='/usr/bin/perl' pg='pg' phostname='hostname' @@ -1108,7 +1108,7 @@ i_stdbool='define' i_syspoll='define' #incpth='/usr/lib/gcc/i486-slackware-linux/4.8.2/include /usr/local/include /usr/lib/gcc/i486-slackware-linux/4.8.2/include-fixed /usr/include' ld_can_script='define' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +#libsfound=' /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' nv_overflows_integers_at='0' perl_static_inline='static __inline__' sGMTIME_max='2147483647' diff --git a/lang/perl/files/config.sh-x86_64.in b/lang/perl/files/config.sh-x86_64.in index 6ec080f58..c7bb86ca4 100644 --- a/lang/perl/files/config.sh-x86_64.in +++ b/lang/perl/files/config.sh-x86_64.in @@ -733,12 +733,12 @@ lib_ext='.a' libc='' libperl='libperl.so' libpth='%%LIBDIRS%%' -libs='-lgdbm -ldb -lnsl -ldl -lm -lcrypt -lutil -lc' +libs='-lgdbm -ldb -ldl -lm -lcrypt -lutil -lc' libsdirs='%%LIBDIRS%%' -libsfiles=' libnsl.so libdl.so libm.so libcrypt.so libutil.so libc.so' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +libsfiles=' libdl.so libm.so libcrypt.so libutil.so libc.so' +#libsfound=' /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' libspath='%%LIBDIRS%%' -libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' +libswanted='sfio socket inet nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util c cposix posix ucb BSD' libswanted_uselargefiles='' line='' lint='' @@ -820,7 +820,7 @@ perl5='' perl='' perl_patchlevel='' perladmin='root@maia.dev.null' -perllibs='-lnsl -ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' +perllibs='-ldl -lm -lcrypt -lutil -lc %%EXTRA_PERLLIBS%%' perlpath='/usr/bin/perl' pg='pg' phostname='hostname' @@ -1093,7 +1093,7 @@ i_stdbool='define' i_syspoll='define' #incpth='/usr/lib/gcc/i486-slackware-linux/4.8.2/include /usr/local/include /usr/lib/gcc/i486-slackware-linux/4.8.2/include-fixed /usr/include' ld_can_script='define' -#libsfound=' /usr/lib/libnsl.so /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' +#libsfound=' /usr/lib/libgdbm.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libcrypt.so /usr/lib/libutil.so /usr/lib/libc.so' nv_overflows_integers_at='0' perl_static_inline='static __inline__' sGMTIME_max='67768036191676799' From 4715296a794bd42c4017594382e0546b6f5988f4 Mon Sep 17 00:00:00 2001 From: Marcel Denia Date: Thu, 16 Oct 2014 00:36:38 +0200 Subject: [PATCH 05/27] perl: Bump PKG_RELEASE Signed-off-by: Marcel Denia --- lang/perl/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/perl/Makefile b/lang/perl/Makefile index edf3e4534..bef6c211d 100644 --- a/lang/perl/Makefile +++ b/lang/perl/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=perl PKG_VERSION:=5.20.0 -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_SOURCE_URL:=ftp://ftp.cpan.org/pub/CPAN/src/5.0 \ http://www.cpan.org/src/5.0/perl-5.20.0.tar.gz \ From 714b1247b70b8b2c185aa30ae914fd90de826f41 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 16 Oct 2014 08:46:32 +0300 Subject: [PATCH 06/27] python: reduce bloat by removing *.pyo and *.pyc files Seems that if you add a package folder this would also include the compiled python files which increases fw size. Signed-off-by: Alexandru Ardelean --- lang/python/files/python-package.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/lang/python/files/python-package.mk b/lang/python/files/python-package.mk index 0196beeb6..6ac6051fa 100644 --- a/lang/python/files/python-package.mk +++ b/lang/python/files/python-package.mk @@ -32,6 +32,7 @@ define PyPackage $(call shexport,PyPackage/$(1)/filespec) define Package/$(1)/install + find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f @$(SH_FUNC) getvar $$(call shvar,PyPackage/$(1)/filespec) | ( \ IFS='|'; \ while read fop fspec fperm; do \ From 09c02844e497998dde3850fe231a3cc2d42f8125 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 16 Oct 2014 16:15:56 +0300 Subject: [PATCH 07/27] python: enforce the existence of files in the filespecs Seems that this allows some goofs, because some files silently do not get copied and the build succeeds, even though it shouldn't. Signed-off-by: Alexandru Ardelean --- lang/python/files/python-package.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lang/python/files/python-package.mk b/lang/python/files/python-package.mk index 6ac6051fa..dc30494fe 100644 --- a/lang/python/files/python-package.mk +++ b/lang/python/files/python-package.mk @@ -37,6 +37,10 @@ define PyPackage IFS='|'; \ while read fop fspec fperm; do \ if [ "$$$$$$$$fop" = "+" ]; then \ + if [ ! -e "$(PKG_INSTALL_DIR)$$$$$$$$fspec" ]; then \ + echo "File not found '$(PKG_INSTALL_DIR)$$$$$$$$fspec'"; \ + exit 1; \ + fi; \ dpath=`dirname "$$$$$$$$fspec"`; \ if [ -n "$$$$$$$$fperm" ]; then \ dperm="-m$$$$$$$$fperm"; \ From aafbac886eb7ebcad876c1a49c8e085b059727e6 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 17 Oct 2014 16:34:12 +0300 Subject: [PATCH 08/27] python: patch setup.py so that it does not include system include dirs Seems that the Python C extensions were being (or at least trying to be) build using '/usr/include' as the first include folder. Seems this issue was already fixed on MacOS X and now we've extended it for our case. Signed-off-by: Alexandru Ardelean --- ...not-add-include-dirs-when-cross-compiling.patch | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lang/python/patches/120-do-not-add-include-dirs-when-cross-compiling.patch diff --git a/lang/python/patches/120-do-not-add-include-dirs-when-cross-compiling.patch b/lang/python/patches/120-do-not-add-include-dirs-when-cross-compiling.patch new file mode 100644 index 000000000..fb2fe8a77 --- /dev/null +++ b/lang/python/patches/120-do-not-add-include-dirs-when-cross-compiling.patch @@ -0,0 +1,14 @@ +diff --git a/setup.py b/setup.py +index cbdeaf3..5154412 100644 +--- a/setup.py ++++ b/setup.py +@@ -480,7 +480,8 @@ class PyBuildExt(build_ext): + add_dir_to_list(dir_list, directory) + + if os.path.normpath(sys.prefix) != '/usr' \ +- and not sysconfig.get_config_var('PYTHONFRAMEWORK'): ++ and not sysconfig.get_config_var('PYTHONFRAMEWORK') \ ++ and not cross_compiling: + # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework + # (PYTHONFRAMEWORK is set) to avoid # linking problems when + # building a framework with different architectures than From 8122954aff030b1048b6149168aca812ef5f51ee Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 17 Oct 2014 16:39:25 +0300 Subject: [PATCH 09/27] python: add ac_cv_buggy_getaddrinfo=no to config.site file Required when IPv6 support gets enabled. Signed-off-by: Alexandru Ardelean --- lang/python/files/config.site | 1 + 1 file changed, 1 insertion(+) diff --git a/lang/python/files/config.site b/lang/python/files/config.site index 8f7a3f981..cfa56b89b 100644 --- a/lang/python/files/config.site +++ b/lang/python/files/config.site @@ -8,4 +8,5 @@ ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no +ac_cv_buggy_getaddrinfo=no From d05c846e69c75ab661b1e1c83b0e1df0a4b99639 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 17 Oct 2014 17:04:26 +0300 Subject: [PATCH 10/27] python: add patch to disable package compiles/tests during cross-builts Signed-off-by: Alexandru Ardelean --- .../130-do-not-run-distutils-tests.patch | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lang/python/patches/130-do-not-run-distutils-tests.patch diff --git a/lang/python/patches/130-do-not-run-distutils-tests.patch b/lang/python/patches/130-do-not-run-distutils-tests.patch new file mode 100644 index 000000000..4fdd2bb4b --- /dev/null +++ b/lang/python/patches/130-do-not-run-distutils-tests.patch @@ -0,0 +1,37 @@ +diff --git a/Makefile.pre.in b/Makefile.pre.in +index bcd83bf..c4dcc6d 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -1005,32 +1005,6 @@ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c + done; \ + done + $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt +- if test -d $(DESTDIR)$(LIBDEST)/distutils/tests; then \ +- $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \ +- $(DESTDIR)$(LIBDEST)/distutils/tests ; \ +- fi +- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ +- $(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ +- -d $(LIBDEST) -f \ +- -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ +- $(DESTDIR)$(LIBDEST) +- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ +- $(PYTHON_FOR_BUILD) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \ +- -d $(LIBDEST) -f \ +- -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ +- $(DESTDIR)$(LIBDEST) +- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ +- $(PYTHON_FOR_BUILD) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \ +- -d $(LIBDEST)/site-packages -f \ +- -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages +- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ +- $(PYTHON_FOR_BUILD) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \ +- -d $(LIBDEST)/site-packages -f \ +- -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages +- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ +- $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt +- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ +- $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt + + # Create the PLATDIR source directory, if one wasn't distributed.. + $(srcdir)/Lib/$(PLATDIR): From 15111b3ccfab71c2a97c446a817e93eb22e3845f Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 17 Oct 2014 17:05:24 +0300 Subject: [PATCH 11/27] python: _md5 + _sha libs are now grouped under _hashlibs Signed-off-by: Alexandru Ardelean --- lang/python/Makefile | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lang/python/Makefile b/lang/python/Makefile index 58b11a196..ba1162a42 100644 --- a/lang/python/Makefile +++ b/lang/python/Makefile @@ -239,14 +239,11 @@ define PyPackage/python-full/filespec -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/grp.so -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/itertools.so -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/math.so --|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_md5.so +-|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_hashlib.so -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/operator.so -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_random.so -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline.so -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/select.so --|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_sha.so --|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_sha256.so --|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_sha512.so -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_socket.so -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/strop.so -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_struct.so @@ -328,13 +325,10 @@ define PyPackage/python/filespec +|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/grp.so +|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/itertools.so +|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/math.so -+|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_md5.so ++|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_hashlib.so +|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/operator.so +|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_random.so +|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/select.so -+|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_sha.so -+|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_sha256.so -+|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_sha512.so +|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_socket.so +|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/strop.so +|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_struct.so From 6862f1d8e637f68ec22d64acf20a459a107d8421 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 17 Oct 2014 17:08:27 +0300 Subject: [PATCH 12/27] python: add libopenssl and libcrypto as package deps Signed-off-by: Alexandru Ardelean --- lang/python/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/python/Makefile b/lang/python/Makefile index ba1162a42..9e6282f08 100644 --- a/lang/python/Makefile +++ b/lang/python/Makefile @@ -53,7 +53,7 @@ endef define Package/python $(call Package/python/Default) - DEPENDS:=+libpthread +zlib +libffi + DEPENDS:=+libpthread +zlib +libffi +libopenssl +libcrypto endef define Package/python/description From 00cfd790067037df36374077f96217b79bf754f9 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 18 Sep 2014 17:03:25 +0300 Subject: [PATCH 13/27] openvswitch: add openvswitch-python subpackage Requires python package. Required by other openvswitch subpackages (like openvswitch-python). Signed-off-by: Alexandru Ardelean --- net/openvswitch/Makefile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/net/openvswitch/Makefile b/net/openvswitch/Makefile index 710e89845..bf4873704 100644 --- a/net/openvswitch/Makefile +++ b/net/openvswitch/Makefile @@ -26,6 +26,7 @@ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/kernel.mk +$(call include_mk, python-package.mk) PKG_FIXUP=libtool @@ -56,6 +57,16 @@ define Package/openvswitch/description Provides the main userspace components required for Open vSwitch to function. endef +define Package/openvswitch-python + $(call Package/openvswitch/Default) + TITLE:=Open vSwitch Python Support + DEPENDS:=@PACKAGE_openvswitch +PACKAGE_openvswitch:openvswitch +python +endef + +define Package/openvswitch-python/description + Provides bindings and libraries for using Python to manipulate/work with Open vSwitch. +endef + define Package/openvswitch-benchmark $(call Package/openvswitch/Default) TITLE:=Open vSwitch Userspace Package @@ -141,6 +152,11 @@ define Package/openvswitch/install $(INSTALL_CONF) $(PKG_BUILD_DIR)/vswitchd/vswitch.ovsschema $(1)/usr/share/openvswitch/ endef +define Package/openvswitch-python/install + $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/ + $(CP) $(PKG_BUILD_DIR)/python/ovs/ $(1)/usr/lib/python$(PYTHON_VERSION)/ +endef + define Package/openvswitch-benchmark/install $(INSTALL_DIR) $(1)/usr/bin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/utilities/.libs/ovs-benchmark $(1)/usr/bin/ @@ -152,6 +168,7 @@ define Package/openvswitch/postinst endef $(eval $(call BuildPackage,openvswitch)) +$(eval $(call BuildPackage,openvswitch-python)) $(eval $(call BuildPackage,openvswitch-benchmark)) $(eval $(call KernelPackage,openvswitch)) From cfa1b5e17bf46271caed831cf3096a54e9b645d5 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 18 Sep 2014 17:13:13 +0300 Subject: [PATCH 14/27] openvswitch: add openvswitch-ipsesc package back Signed-off-by: Alexandru Ardelean --- net/openvswitch/Makefile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/net/openvswitch/Makefile b/net/openvswitch/Makefile index bf4873704..bb5b268dd 100644 --- a/net/openvswitch/Makefile +++ b/net/openvswitch/Makefile @@ -67,6 +67,17 @@ define Package/openvswitch-python/description Provides bindings and libraries for using Python to manipulate/work with Open vSwitch. endef +define Package/openvswitch-ipsec + $(call Package/openvswitch/Default) + TITLE:=Open vSwitch Userspace Package + DEPENDS:=@PACKAGE_openvswitch +PACKAGE_openvswitch:openvswitch-python +endef + +define Package/openvswitch-ipsec/description + The ovs-monitor-ipsec script provides support for encrypting GRE tunnels with + IPsec. +endef + define Package/openvswitch-benchmark $(call Package/openvswitch/Default) TITLE:=Open vSwitch Userspace Package @@ -157,6 +168,11 @@ define Package/openvswitch-python/install $(CP) $(PKG_BUILD_DIR)/python/ovs/ $(1)/usr/lib/python$(PYTHON_VERSION)/ endef +define Package/openvswitch-ipsec/install + $(INSTALL_DIR) $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/debian/ovs-monitor-ipsec $(1)/usr/sbin/ +endef + define Package/openvswitch-benchmark/install $(INSTALL_DIR) $(1)/usr/bin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/utilities/.libs/ovs-benchmark $(1)/usr/bin/ @@ -169,6 +185,7 @@ endef $(eval $(call BuildPackage,openvswitch)) $(eval $(call BuildPackage,openvswitch-python)) +$(eval $(call BuildPackage,openvswitch-ipsec)) $(eval $(call BuildPackage,openvswitch-benchmark)) $(eval $(call KernelPackage,openvswitch)) From 16d96ec143ea2627441e63a082a53fddee0cc01d Mon Sep 17 00:00:00 2001 From: Hannu Nyman Date: Sat, 18 Oct 2014 13:25:46 +0300 Subject: [PATCH 15/27] sqm-scripts: Fix a minor bug, add copyrights, improve logging Changes committed to the cerowrt original repo after the initial import here: - Better license & copyright statements, as requested - Fixed a minor bug in stopping sqm - Logging improvements - Dead code removed - Typos corrected Signed-off-by: Hannu Nyman --- net/sqm-scripts/Makefile | 2 +- .../files/usr/lib/sqm/functions.sh | 51 +++---------------- net/sqm-scripts/files/usr/lib/sqm/run.sh | 15 ++++-- net/sqm-scripts/files/usr/lib/sqm/simple.qos | 11 ++-- .../files/usr/lib/sqm/simple_pppoe.qos | 7 ++- .../files/usr/lib/sqm/simplest.qos | 7 ++- net/sqm-scripts/files/usr/lib/sqm/stop.sh | 15 ++++-- 7 files changed, 46 insertions(+), 62 deletions(-) diff --git a/net/sqm-scripts/Makefile b/net/sqm-scripts/Makefile index 95fc5e72e..ea296f1b4 100644 --- a/net/sqm-scripts/Makefile +++ b/net/sqm-scripts/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sqm-scripts -PKG_VERSION:=6 +PKG_VERSION:=7 PKG_RELEASE:=1 PKG_LICENSE:=GPLv2 diff --git a/net/sqm-scripts/files/usr/lib/sqm/functions.sh b/net/sqm-scripts/files/usr/lib/sqm/functions.sh index 63a67e358..f2ed44bbe 100644 --- a/net/sqm-scripts/files/usr/lib/sqm/functions.sh +++ b/net/sqm-scripts/files/usr/lib/sqm/functions.sh @@ -1,3 +1,9 @@ +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# Copyright (C) 2012-4 Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller + #improve the logread output sqm_logger() { logger -t SQM -s ${1} @@ -74,42 +80,6 @@ get_ifb_associated_with_if() { echo ${CUR_IFB} } -# what is the lowest-index currently not used ifb device -#sm: hopefully this is not required any longer, and can be deleted after a bit more testing... -get_lowest_unused_ifb() { - LOWEST_FREE_IFB= - # this just returns a list of currently existing IFBs, these need not be associated with any interface - CUR_UP_IFBS=$( ifconfig | grep -o -e ifb'[[:digit:]]\+' ) - # the possible IFBs (N in insmod ifb numifbs=N) - here=$( pwd ) - cd /sys/devices/virtual/net/ - CUR_ALLOWED_IFBS=$( ls -d ifb* ) - sqm_logger "Currently allowed IFBs: ${CUR_ALLOWED_IFBS}" - cd ${here} - # this is the sorted list of the active ifbs - # note for 3.10.32 unused and even down IFBs linger on in the tc output, so take $CUR_UP_IFBS instead - # a better test might be to check for each allowed IFB whether it is in use - # but the only way I figured out doing this means interating over all interfaces and that sounds costly - # so instead we rely on stop.sh actually calling ifconfig ${LAST_USED_IFB} down - CUR_USED_IFBS=$( tc -d qdisc | grep -o -e ifb'[[:digit:]]\+' | sort -u) - sqm_logger "Currently used IFBs: ${CUR_USED_IFBS}" - # now find the lowest index not in the sorted list - local CUR_IDX=0 - while [ -z "$LOWEST_FREE_IFB" ] - do - #TMP=$( echo "${CUR_USED_IFBS}" | grep -o -e ifb${CUR_IDX} ) - TMP=$( echo "${CUR_UP_IFBS}" | grep -o -e ifb${CUR_IDX} ) - [ -z "$TMP" ] && LOWEST_FREE_IFB="ifb"${CUR_IDX} - CUR_IDX=$(( $CUR_IDX + 1 )) - done - # check whether the number is in the allowed range - LOWEST_FREE_IFB=$( echo "${CUR_ALLOWED_IFBS}" | grep -o -e ${LOWEST_FREE_IFB} ) - [ -z "${LOWEST_FREE_IFB}" ] && sqm_logger "The IFB candidate ifb$(( ${CUR_IDX} - 1 )) is not in the range of allowed IFBs, bailing out..." - sqm_logger "selected ifb index: ${LOWEST_FREE_IFB}" - echo ${LOWEST_FREE_IFB} -} - -# instead of playing around with indices just create a named IFB # ATTENTION, IFB names can only be 15 chararcters, so we chop of excessive characters at the start of the interface name # if required create_new_ifb_for_if() { @@ -134,8 +104,6 @@ get_ifb_for_if() { CUR_IF=$1 # if an ifb is already associated return that CUR_IFB=$( get_ifb_associated_with_if ${CUR_IF} ) - # otherwise find the lowest unused ifb device - #[ -z "$CUR_IFB" ] && CUR_IFB=$( get_lowest_unused_ifb ) [ -z "$CUR_IFB" ] && CUR_IFB=$( create_new_ifb_for_if ${CUR_IF} ) [ -z "$CUR_IFB" ] && sqm_logger "Could not find existing IFB for ${CUR_IF}, nor create a new IFB instead..." echo ${CUR_IFB} @@ -145,13 +113,6 @@ get_ifb_for_if() { [ -z "$DEV" ] && DEV=$( get_ifb_for_if ${IFACE} ) # automagically get the right IFB device for the IFACE" - -#sqm_logger "iqdisc opts: ${iqdisc_opts}" -#sqm_logger "eqdisc opts: ${eqdisc_opts}" - -#sqm_logger "LLAM: ${LLAM}" -#sqm_logger "LINKLAYER: ${LINKLAYER}" - get_htb_adsll_string() { ADSLL="" if [ "$LLAM" = "htb_private" -a "$LINKLAYER" != "none" ]; diff --git a/net/sqm-scripts/files/usr/lib/sqm/run.sh b/net/sqm-scripts/files/usr/lib/sqm/run.sh index 5453bea3f..d7b86a220 100755 --- a/net/sqm-scripts/files/usr/lib/sqm/run.sh +++ b/net/sqm-scripts/files/usr/lib/sqm/run.sh @@ -1,5 +1,12 @@ #!/bin/sh +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# Copyright (C) 2012-4 Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller + + . /lib/functions.sh STOP=$1 @@ -17,7 +24,7 @@ for STATE_FILE in ${PROTO_STATE_FILE_LIST} ; do then STATE_FILE_BASE_NAME=$( basename ${STATE_FILE} ) CURRENT_INTERFACE=${STATE_FILE_BASE_NAME:${#ACTIVE_STATE_PREFIX}:$(( ${#STATE_FILE_BASE_NAME} - ${#ACTIVE_STATE_PREFIX} ))} - logger -t SQM -s "Stopping SQM on interface: ${CURRENT_INTERFACE}" + logger -t SQM -s "${0} Stopping SQM on interface: ${CURRENT_INTERFACE}" /usr/lib/sqm/stop.sh ${CURRENT_INTERFACE} rm ${STATE_FILE} # well, we stop it so it is not running anymore and hence no active state file needed... fi @@ -38,7 +45,7 @@ run_simple_qos() { # this should not be possible, delete after testing local SECTION_STOP="stop" # it seems the user just de-selected enable, so stop the active SQM else - logger -t SQM -s "SQM for interface ${IFACE} is not enabled, skipping over..." + logger -t SQM -s "${0} SQM for interface ${IFACE} is not enabled, skipping over..." return 0 # since SQM is not active on the current interface nothing to do here fi fi @@ -72,10 +79,10 @@ run_simple_qos() { # /usr/lib/sqm/stop.sh # [ -f ${ACTIVE_STATE_FILE_FQN} ] && rm ${ACTIVE_STATE_FILE_FQN} # conditional to avoid errors ACTIVE_STATE_FILE_FQN does not exist anymore # $(config_set "$section" enabled 0) # this does not save to the config file only to the loaded memory representation -# logger -t SQM -s "SQM qdiscs on ${IFACE} removed" + logger -t SQM -s "${0} SQM qdiscs on ${IFACE} removed" return 0 fi - logger -t SQM -s "Queue Setup Script: ${SCRIPT}" + logger -t SQM -s "${0} Queue Setup Script: ${SCRIPT}" [ -x "$SCRIPT" ] && { $SCRIPT ; touch ${ACTIVE_STATE_FILE_FQN}; } } diff --git a/net/sqm-scripts/files/usr/lib/sqm/simple.qos b/net/sqm-scripts/files/usr/lib/sqm/simple.qos index efafada4c..c752660bb 100755 --- a/net/sqm-scripts/files/usr/lib/sqm/simple.qos +++ b/net/sqm-scripts/files/usr/lib/sqm/simple.qos @@ -3,8 +3,11 @@ # A 3 bin tc_codel and ipv6 enabled shaping script for # ethernet gateways -# Copyright (C) 2012 Michael D Taht -# GPLv2 +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# Copyright (C) 2012-4 Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller # Compared to the complexity that debloat had become # this cleanly shows a means of going from diffserv marking @@ -36,10 +39,10 @@ ipt -t mangle -A QOS_MARK_${IFACE} -m tos --tos Minimize-Delay -j MARK --set-ma if [ "$SQUASH_DSCP" = "1" ] then -sqm_logger "Squashing differentiad services code points (DSCP) from ingress." +sqm_logger "Squashing differentiated services code points (DSCP) from ingress." ipt -t mangle -I PREROUTING -i $IFACE -m dscp ! --dscp 0 -j DSCP --set-dscp-class be else -sqm_logger "Keeping differentiad services code points (DSCP) from ingress." +sqm_logger "Keeping differentiated services code points (DSCP) from ingress." ipt -t mangle -A PREROUTING -i $IFACE -m mark --mark 0x00 -g QOS_MARK_${IFACE} fi diff --git a/net/sqm-scripts/files/usr/lib/sqm/simple_pppoe.qos b/net/sqm-scripts/files/usr/lib/sqm/simple_pppoe.qos index 4a47d4676..2e84fab9e 100755 --- a/net/sqm-scripts/files/usr/lib/sqm/simple_pppoe.qos +++ b/net/sqm-scripts/files/usr/lib/sqm/simple_pppoe.qos @@ -3,8 +3,11 @@ # A 3 bin tc_codel and ipv6 enabled shaping script for # ethernet gateways -# Copyright (C) 2012 Michael D Taht -# GPLv2 +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# Copyright (C) 2012-4 Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller # Compared to the complexity that debloat had become # this cleanly shows a means of going from diffserv marking diff --git a/net/sqm-scripts/files/usr/lib/sqm/simplest.qos b/net/sqm-scripts/files/usr/lib/sqm/simplest.qos index e82bcff5c..f06c25211 100755 --- a/net/sqm-scripts/files/usr/lib/sqm/simplest.qos +++ b/net/sqm-scripts/files/usr/lib/sqm/simplest.qos @@ -3,8 +3,11 @@ # A 1 bin tc_codel and ipv6 enabled shaping script for # ethernet gateways. This is nearly the simplest possible -# Copyright (C) 2013 Michael D Taht -# GPLv2 +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# Copyright (C) 2012-4 Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller . /usr/lib/sqm/functions.sh sqm_logger "Starting simplest.qos" diff --git a/net/sqm-scripts/files/usr/lib/sqm/stop.sh b/net/sqm-scripts/files/usr/lib/sqm/stop.sh index f7323e8b9..29e213b69 100755 --- a/net/sqm-scripts/files/usr/lib/sqm/stop.sh +++ b/net/sqm-scripts/files/usr/lib/sqm/stop.sh @@ -1,10 +1,17 @@ #!/bin/sh -. /usr/lib/sqm/functions.sh +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# Copyright (C) 2012-4 Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller # allow passing in the IFACE as first command line argument [ ! -z ${1} ] && IFACE=${1} -sqm_logger "${0} Stopping ${IFACE}" +# now IFACE is defined so we can source functions.sh without creating a spurious ifb4ge00 +. /usr/lib/sqm/functions.sh +# sqm_logger is defined in functions.sh... +sqm_logger "${0}: Stopping ${IFACE}" # make sure to only delete the ifb associated with the current interface CUR_IFB=$( get_ifb_associated_with_if ${IFACE} ) @@ -13,7 +20,7 @@ sqm_stop() { tc qdisc del dev $IFACE ingress 2> /dev/null tc qdisc del dev $IFACE root 2> /dev/null [ ! -z "$CUR_IFB" ] && tc qdisc del dev $CUR_IFB root 2> /dev/null - [ ! -z "$CUR_IFB" ] && sqm_logger "${CUR_IFB} shaper deleted" + [ ! -z "$CUR_IFB" ] && sqm_logger "${0}: ${CUR_IFB} shaper deleted" } ipt_stop() { @@ -30,6 +37,6 @@ sqm_stop ipt_stop [ ! -z "$CUR_IFB" ] && ifconfig ${CUR_IFB} down [ ! -z "$CUR_IFB" ] && ip link delete ${CUR_IFB} type ifb -[ ! -z "$CUR_IFB" ] && sqm_logger "${CUR_IFB} interface deleted" +[ ! -z "$CUR_IFB" ] && sqm_logger "${0}: ${CUR_IFB} interface deleted" exit 0 \ No newline at end of file From ad4da82a8eca9d33b94edc600af7cba093c4f244 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Sat, 18 Oct 2014 15:34:22 +0200 Subject: [PATCH 16/27] nfs-kernel-server: update to 1.3.1 Signed-off-by: Peter Wagner --- net/nfs-kernel-server/Makefile | 4 +-- .../patches/100-nfs_utils_uclibc.patch | 36 ------------------- ...o_malloc_h.patch => 100-no_malloc_h.patch} | 0 3 files changed, 2 insertions(+), 38 deletions(-) delete mode 100644 net/nfs-kernel-server/patches/100-nfs_utils_uclibc.patch rename net/nfs-kernel-server/patches/{101-no_malloc_h.patch => 100-no_malloc_h.patch} (100%) diff --git a/net/nfs-kernel-server/Makefile b/net/nfs-kernel-server/Makefile index b5cfcd757..1a3468f4a 100644 --- a/net/nfs-kernel-server/Makefile +++ b/net/nfs-kernel-server/Makefile @@ -7,9 +7,9 @@ include $(TOPDIR)/rules.mk PKG_NAME:=nfs-kernel-server -PKG_VERSION:=1.3.0 +PKG_VERSION:=1.3.1 PKG_RELEASE:=1 -PKG_MD5SUM:=3ac3726eda563946d1f44ac3e5b61d56 +PKG_MD5SUM:=97f157f954edb6d4d4385a0c5986f36f PKG_SOURCE_URL:=@SF/nfs PKG_SOURCE:=nfs-utils-$(PKG_VERSION).tar.bz2 diff --git a/net/nfs-kernel-server/patches/100-nfs_utils_uclibc.patch b/net/nfs-kernel-server/patches/100-nfs_utils_uclibc.patch deleted file mode 100644 index 5e4877ef4..000000000 --- a/net/nfs-kernel-server/patches/100-nfs_utils_uclibc.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/support/nfs/svc_socket.c -+++ b/support/nfs/svc_socket.c -@@ -40,10 +40,13 @@ int getservport(u_long number, const cha - char rpcdata[1024], servdata[1024]; - struct rpcent rpcbuf, *rpcp; - struct servent servbuf, *servp = NULL; -- int ret; -- -+ int ret=0; -+#ifndef __UCLIBC__ - ret = getrpcbynumber_r(number, &rpcbuf, rpcdata, sizeof rpcdata, - &rpcp); -+#else -+ rpcp = getrpcbynumber (number); -+#endif - if (ret == 0 && rpcp != NULL) { - /* First try name. */ - ret = getservbyname_r(rpcp->r_name, proto, &servbuf, servdata, ---- a/utils/mountd/cache.c -+++ b/utils/mountd/cache.c -@@ -166,6 +166,7 @@ static void auth_unix_gid(FILE *f) - pw = getpwuid(uid); - if (!pw) - rv = -1; -+#ifndef __UCLIBC__ - else { - rv = getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups); - if (rv == -1 && ngroups >= groups_len) { -@@ -180,6 +181,7 @@ static void auth_unix_gid(FILE *f) - } - } - } -+#endif - qword_printuint(f, uid); - qword_printtimefrom(f, DEFAULT_TTL); - if (rv >= 0) { diff --git a/net/nfs-kernel-server/patches/101-no_malloc_h.patch b/net/nfs-kernel-server/patches/100-no_malloc_h.patch similarity index 100% rename from net/nfs-kernel-server/patches/101-no_malloc_h.patch rename to net/nfs-kernel-server/patches/100-no_malloc_h.patch From d15d70f6933a6e2333e151cb8f7c56f1961347c8 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Thu, 16 Oct 2014 23:24:10 +0200 Subject: [PATCH 17/27] libantlr3c: add version 3.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Espen Jürgensen --- libs/libantlr3c/Makefile | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 libs/libantlr3c/Makefile diff --git a/libs/libantlr3c/Makefile b/libs/libantlr3c/Makefile new file mode 100644 index 000000000..bd1e51e04 --- /dev/null +++ b/libs/libantlr3c/Makefile @@ -0,0 +1,55 @@ +# +# Copyright (C) 2006-2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libantlr3c +PKG_VERSION:=3.2 +PKG_RELEASE:=1 +PKG_MD5SUM:=674646e1d1bf5c6015435480cead725a + +PKG_SOURCE_URL:=http://www.antlr3.org/download/C +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_INSTALL:=1 + +PKG_MAINTAINER:=Espen Jürgensen +PKG_LICENSE:=BSD-2-Clause +PKG_LICENSE_FILES:=COPYING + +include $(INCLUDE_DIR)/package.mk + +define Package/libantlr3c + SECTION:=libs + CATEGORY:=Libraries + TITLE:=libantlr3c + URL:=http://www.antlr3.org/ +endef + +define Package/libantlr3c/description + ANother Tool for Language Recognition, is a language tool that provides a framework for constructing recognizers, + interpreters, compilers, and translators from grammatical descriptions containing actions in a variety of target languages. +endef + +TARGET_CFLAGS += $(FPIC) + +CONFIGURE_ARGS += \ + --enable-shared \ + --enable-static + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libantlr3c.{a,so} $(1)/usr/lib/ +endef + +define Package/libantlr3c/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libantlr3c.so $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libantlr3c)) From 8365b52b2087a22c85cf7afc06f27cf6132904b7 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Thu, 16 Oct 2014 23:25:54 +0200 Subject: [PATCH 18/27] libavl: add version 0.3.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Espen Jürgensen --- libs/libavl/Makefile | 55 +++++++++++++++++++ .../patches/010-update_GNUmakefile.patch | 45 +++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 libs/libavl/Makefile create mode 100644 libs/libavl/patches/010-update_GNUmakefile.patch diff --git a/libs/libavl/Makefile b/libs/libavl/Makefile new file mode 100644 index 000000000..0ff2385ac --- /dev/null +++ b/libs/libavl/Makefile @@ -0,0 +1,55 @@ +# +# Copyright (C) 2006-2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libavl +PKG_VERSION:=0.3.5 +PKG_RELEASE:=1 +PKG_MD5SUM:=882c68ea7f71876ca110f3b84d7ab12d + +PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz +PKG_SOURCE_URL:=http://ftp.debian.org/debian/pool/main/liba/libavl +PKG_BUILD_DIR:=$(BUILD_DIR)/avl-$(PKG_VERSION) +PKG_INSTALL:=1 + +PKG_MAINTAINER:=Espen Jürgensen +PKG_LICENSE:=LGPL-2.0+ +PKG_LICENSE_FILES:=COPYING + +include $(INCLUDE_DIR)/package.mk + +define Package/libavl + SECTION:=libs + CATEGORY:=Libraries + TITLE:=AVLTree (this is not GNU libavl) + URL:=https://packages.debian.org/wheezy/libavl1 +endef + +define Package/libavl/description + AVLTree is a small implementation of AVL trees for the C programming language. +endef + +TARGET_CFLAGS += $(FPIC) + +CONFIGURE_ARGS += \ + --enable-shared \ + --enable-static + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/avl.h $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libavl.so* $(1)/usr/lib/ +endef + +define Package/libavl/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libavl.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libavl)) diff --git a/libs/libavl/patches/010-update_GNUmakefile.patch b/libs/libavl/patches/010-update_GNUmakefile.patch new file mode 100644 index 000000000..301394915 --- /dev/null +++ b/libs/libavl/patches/010-update_GNUmakefile.patch @@ -0,0 +1,45 @@ +--- a/GNUmakefile 2002-11-15 19:57:48.000000000 +0100 ++++ a/GNUmakefile 2014-10-02 16:03:02.864803002 +0200 +@@ -6,7 +6,7 @@ + LDCONFIG ?= /sbin/ldconfig + + # Some suggestions: (-mcpu= generates i386 compatible code) +-CFLAGS ?= -O2 -fomit-frame-pointer -pipe -mcpu=i686 -w ++CFLAGS ?= -O2 -pipe -Wall -Werror + #CFLAGS = -O2 -fomit-frame-pointer -pipe -march=i586 -Wall -g + #CFLAGS = -O6 -fomit-frame-pointer -pipe -march=i586 -Wall -ansi -pedantic + #CFLAGS = -O6 -fomit-frame-pointer -pipe -march=i686 -Wall -ansi -pedantic +@@ -15,10 +15,9 @@ + #CFLAGS = -g -pg -a -pipe -march=i686 -Wall + #LDFLAGS = -s + +-prefix ?= /usr/local ++prefix ?= /usr + libdir ?= $(prefix)/lib + includedir ?= $(prefix)/include +-includedir ?= /usr/include + + PROGRAMS = avlsort setdiff + LIBRARY = libavl.so.1.5 +@@ -34,16 +33,17 @@ + $(CC) $(LDFLAGS) $^ -o $@ $(LIBS) + + $(LIBRARY): avl.o +- $(CC) -nostdlib -shared -Wl,-soname,libavl.so.1 $^ -o $@ -lc ++ $(CC) -shared -Wl,-soname,libavl.so.1 $^ -o $@ -lc + + clean: + $(RM) *.o $(PROGRAMS) libavl.* + + install: all + $(INSTALL) -d $(DESTDIR)$(libdir) +- $(INSTALL) avl.h $(DESTDIR)$(includedir) +- $(INSTALL) $(LIBRARIES) $(DESTDIR)$(libdir) +- for i in $(LIBRARIES); do\ ++ $(INSTALL) -d $(DESTDIR)$(includedir) ++ $(INSTALL) -m 644 avl.h $(DESTDIR)$(includedir) ++ $(INSTALL) -m 644 $(LIBRARY) $(DESTDIR)$(libdir) ++ for i in $(LIBRARY); do\ + $(LN) -sf $$i $(DESTDIR)$(libdir)/$${i%.*};\ + $(LN) -sf $${i%.*} $(DESTDIR)$(libdir)/$${i%.*.*};\ + done From 560598ca2299247aa142a4c11b655e0717f59796 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Thu, 16 Oct 2014 23:27:04 +0200 Subject: [PATCH 19/27] libunistring: add version 0.9.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Espen Jürgensen --- libs/libunistring/Makefile | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 libs/libunistring/Makefile diff --git a/libs/libunistring/Makefile b/libs/libunistring/Makefile new file mode 100644 index 000000000..6d69b57d8 --- /dev/null +++ b/libs/libunistring/Makefile @@ -0,0 +1,59 @@ +# +# Copyright (C) 2006-2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libunistring +PKG_VERSION:=0.9.4 +PKG_RELEASE:=1 +PKG_MD5SUM:=c24a6a3838d9ad4a41a62549312c4226 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://ftp.gnu.org/gnu/libunistring +PKG_BUILD_PARALLEL:=1 +PKG_INSTALL:=1 + +PKG_MAINTAINER:=Espen Jürgensen +PKG_LICENSE:=GPL-3.0 +PKG_LICENSE_FILES:=COPYING + +include $(INCLUDE_DIR)/package.mk + +define Package/libunistring + SECTION:=libs + CATEGORY:=Libraries + TITLE:=libunistring + URL:=http://www.gnu.org/software/libunistring/ +endef + +define Package/libunistring/description + This library provides functions for manipulating Unicode strings and for manipulating C strings according to the Unicode standard. +endef + +TARGET_CFLAGS += $(FPIC) + +CONFIGURE_ARGS += \ + --enable-shared \ + --enable-static \ + --without-libiconv-prefix \ + --without-libpth-prefix + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/include/unistring + $(CP) $(PKG_INSTALL_DIR)/usr/include/unistring/*.h $(1)/usr/include/unistring/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libunistring.{a,so*} $(1)/usr/lib/ +endef + +define Package/libunistring/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libunistring.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libunistring)) From c606a0a040dc02af29e3a14dc4daa359a76c5835 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Thu, 16 Oct 2014 23:28:24 +0200 Subject: [PATCH 20/27] mxml: copy from oldpackages and update Makefile slightly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Espen Jürgensen --- libs/mxml/Makefile | 56 +++++++++++++++++++++++++++++ libs/mxml/patches/001-targets.patch | 11 ++++++ 2 files changed, 67 insertions(+) create mode 100644 libs/mxml/Makefile create mode 100644 libs/mxml/patches/001-targets.patch diff --git a/libs/mxml/Makefile b/libs/mxml/Makefile new file mode 100644 index 000000000..74cff413b --- /dev/null +++ b/libs/mxml/Makefile @@ -0,0 +1,56 @@ +# +# Copyright (C) 2006-2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=mxml +PKG_VERSION:=2.8 +PKG_RELEASE:=1 +PKG_MD5SUM:=d85ee6d30de053581242c4a86e79a5d2 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.msweet.org/files/project3/ +PKG_FIXUP:=autoreconf + +PKG_MAINTAINER:=Espen Jürgensen +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:=COPYING + +include $(INCLUDE_DIR)/package.mk + +define Package/mxml + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Mini-XML + URL:=http://www.minixml.org/ +endef + +define Package/mxml/description + A small xml library. +endef + +TARGET_CFLAGS += $(FPIC) + +CONFIGURE_ARGS += \ + --enable-shared \ + --enable-static + +define Build/InstallDev + mkdir -p $(1)/usr/include + $(CP) $(PKG_BUILD_DIR)/mxml.h $(1)/usr/include/ + mkdir -p $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/libmxml.so* $(1)/usr/lib/ + mkdir -p $(1)/usr/lib/pkgconfig + $(CP) $(PKG_BUILD_DIR)/mxml.pc $(1)/usr/lib/pkgconfig/ +endef + +define Package/mxml/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/libmxml.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,mxml)) diff --git a/libs/mxml/patches/001-targets.patch b/libs/mxml/patches/001-targets.patch new file mode 100644 index 000000000..86379f02a --- /dev/null +++ b/libs/mxml/patches/001-targets.patch @@ -0,0 +1,11 @@ +--- a/Makefile.in ++++ b/Makefile.in +@@ -88,7 +88,7 @@ PUBLIBOBJS = mxml-attr.o mxml-entity.o m + mxml-index.o mxml-node.o mxml-search.o mxml-set.o + LIBOBJS = $(PUBLIBOBJS) mxml-private.o mxml-string.o + OBJS = mxmldoc.o testmxml.o $(LIBOBJS) +-TARGETS = $(LIBMXML) mxmldoc testmxml mxml.xml doc/mxml.man ++TARGETS = $(LIBMXML) + + + # From 9ab6894c2f438751d22a278850184cf260f3822b Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Thu, 16 Oct 2014 23:34:24 +0200 Subject: [PATCH 21/27] forked-daapd: add version 22.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Espen Jürgensen --- sound/forked-daapd/Makefile | 66 + sound/forked-daapd/files/forked-daapd.conf | 139 + sound/forked-daapd/files/forked-daapd.init | 15 + .../patches/010-include_pregen.patch | 14782 ++++++++++++++++ 4 files changed, 15002 insertions(+) create mode 100644 sound/forked-daapd/Makefile create mode 100644 sound/forked-daapd/files/forked-daapd.conf create mode 100644 sound/forked-daapd/files/forked-daapd.init create mode 100644 sound/forked-daapd/patches/010-include_pregen.patch diff --git a/sound/forked-daapd/Makefile b/sound/forked-daapd/Makefile new file mode 100644 index 000000000..585fa4fe1 --- /dev/null +++ b/sound/forked-daapd/Makefile @@ -0,0 +1,66 @@ +# +# Copyright (C) 2006-2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=forked-daapd +PKG_VERSION:=22.0 +PKG_RELEASE:=20141016 +PKG_REV:=61a4da215c05b621951aa3903d7d390fd1839537 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=git://github.com/ejurgensen/forked-daapd.git +PKG_SOURCE_VERSION:=$(PKG_REV) +PKG_FIXUP:=autoreconf +PKG_USE_MIPS16:=0 +PKG_INSTALL:=1 + +PKG_MAINTAINER:=Espen Jürgensen +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:=COPYING + +include $(INCLUDE_DIR)/package.mk + +define Package/forked-daapd +SECTION:=sound +CATEGORY:=Sound +TITLE:=Improved iTunes (DAAP) server. Support for Apple Remote and AirPlay. +URL:=https://github.com/ejurgensen/forked-daapd +DEPENDS:=+libgpg-error +libgcrypt +libgdbm +zlib +libexpat +libunistring \ + +libevent +libdaemon +libantlr3c +confuse +glib2 +alsa-lib +libffmpeg-full \ + +mxml +libavl +avahi-daemon +libavahi-client +sqlite3-cli +libplist +endef + +define Package/forked-daapd/conffiles +/etc/forked-daapd.conf +endef + +CONFIGURE_ARGS += \ + --enable-itunes + +# Fix for libevent +TARGET_CPPFLAGS += -I$(STAGING_DIR)/usr/include/libevent +TARGET_LDFLAGS += -L$(STAGING_DIR)/usr/lib/libevent + +TARGET_CFLAGS += $(FPIC) +TARGET_LDFLAGS += -Wl,-rpath-link,$(STAGING_DIR)/usr/lib + +define Package/forked-daapd/install + $(INSTALL_DIR) $(1)/etc + $(INSTALL_DATA) ./files/forked-daapd.conf $(1)/etc/ + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_DIR) $(1)/usr/lib/forked-daapd + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/forked-daapd/* $(1)/usr/lib/forked-daapd/ + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/forked-daapd $(1)/usr/sbin/ + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/forked-daapd.init $(1)/etc/init.d/forked-daapd +endef + +$(eval $(call BuildPackage,forked-daapd)) diff --git a/sound/forked-daapd/files/forked-daapd.conf b/sound/forked-daapd/files/forked-daapd.conf new file mode 100644 index 000000000..e0b3c0ccb --- /dev/null +++ b/sound/forked-daapd/files/forked-daapd.conf @@ -0,0 +1,139 @@ +# A quick guide to configuring forked-daapd: +# +# For regular use, the most important setting to configure is "directories", +# which should be the location of your media. Whatever user you have set as +# "uid" must have read access to this location. Also make sure to add the user. +# If the location is a network mount, please see the README. +# +# In all likelihood, that's all you need to do! + +general { + # Username + uid = "daapd" + logfile = "/var/log/forked-daapd.log" + # Database location + db_path = "/var/run/forked-daapd.db" + # Available levels: fatal, log, warning, info, debug, spam + loglevel = log + # Admin password for the non-existent web interface + admin_password = "unused" + # Enable/disable IPv6 + ipv6 = no + # Location of DAAP cache + daapcache_path = "/var/run/daapcache.db" + # DAAP requests that take longer than this threshold (in msec) get their + # replies cached for next time. Set to 0 to disable caching. +# daapcache_threshold = 1000 +} + +# Library configuration +library { + # Name of the library as displayed by the clients + # %h: hostname, %v: version + name = "My Music on %h" + # TCP port to listen on. Default port is 3689 (daap) + port = 3689 + # Password for the library. Optional. +# password = "" + + # Directories to index + directories = { "/srv/music" } + + # Directories containing podcasts + # For each directory that is indexed the path is matched against these + # names. If there is a match all items in the directory are marked as + # podcasts. Eg. if you index /srv/music, and your podcasts are in + # /srv/music/Podcasts, you can set this to "/Podcasts". + # (changing this setting only takes effect after rescan, see the README) + podcasts = { "/Podcasts" } + + # Directories containing audiobooks + # For each directory that is indexed the path is matched against these + # names. If there is a match all items in the directory are marked as + # audiobooks. + # (changing this setting only takes effect after rescan, see the README) + audiobooks = { "/Audiobooks" } + + # Directories containing compilations (eg soundtracks) + # For each directory that is indexed the path is matched against these + # names. If there is a match all items in the directory are marked as + # compilations. + # (changing this setting only takes effect after rescan, see the README) + compilations = { "/Compilations" } + + # Compilations usually have many artists, and if you don't want every + # artist to be listed when artist browsing in Remote, you can set + # a single name which will be used for all music in the compilation dir + # (changing this setting only takes effect after rescan, see the README) + compilation_artist = "Various artists" + + # There are 5 default playlists: "Library", "Music", "Movies", "TV Shows" + # and "Podcasts". Here you can change the names of these playlists. +# name_library = "Library" +# name_music = "Music" +# name_movies = "Movies" +# name_tvshows = "TV Shows" +# name_podcasts = "Podcasts" +# name_audiobooks = "Audiobooks" + + # Artwork file names (without file type extension) + # forked-daapd will look for jpg and png files with these base names +# artwork_basenames = { "artwork", "cover", "Folder" } + + # File types the scanner should ignore + # Non-audio files will never be added to the database, but here you + # can prevent the scanner from even probing them. This might improve + # scan time. By default .db and .ini are ignored. +# filetypes_ignore = { ".db", ".ini" } + + # Disable startup file scanning + # When forked-daapd starts it will do an initial file scan of your + # library (and then watch it for changes). If you are sure your library + # never changes while forked-daapd is not running, you can disable the + # initial file scan and save some system ressources. Disabling this scan + # may lead to forked-daapd's database coming out of sync with the + # library. If that happens read the instructions in the README on how + # to trigger a full rescan. +# filescan_disable = false + + # Should iTunes metadata override ours? +# itunes_overrides = false + + # Formats: mp4a, mp4v, mpeg, alac, flac, mpc, ogg, wma, wmal, wmav, aif, wav + # Formats that should never be transcoded +# no_transcode = { "alac", "mp4a" } + # Formats that should always be transcoded +# force_transcode = { "ogg", "flac" } +} + +# Local audio output +audio { + # Name - used in the speaker list in Remote + nickname = "OpenWrt" + # Audio device name for local audio output +# card = "default" + # Mixer channel to use for volume control - ALSA/Linux only + # If not set, PCM will be used if available, otherwise Master. +# mixer = "" +} + +# AirPlay/Airport Express device settings +# (make sure you get the capitalization of the device name right) +#airplay "My AirPlay device" { + # forked-daapd's volume goes to 11! If that's more than you can handle + # you can set a lower value here +# max_volume = 11 + # AirPlay password +# password = "s1kr3t" +#} + +# Spotify settings (only have effect if Spotify enabled - see README/INSTALL) +spotify { + # Directory where user settings should be stored (credentials) +# settings_dir = "/var/cache/forked-daapd/libspotify" + # Cache directory +# cache_dir = "/tmp" + # Set preferred bitrate for music streaming + # 0: No preference (default), 1: 96kbps, 2: 160kbps, 3: 320kbps +# bitrate = 0 +} diff --git a/sound/forked-daapd/files/forked-daapd.init b/sound/forked-daapd/files/forked-daapd.init new file mode 100644 index 000000000..3ae38f9ab --- /dev/null +++ b/sound/forked-daapd/files/forked-daapd.init @@ -0,0 +1,15 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2014 OpenWrt.org + +START=99 +BIN=/usr/sbin/forked-daapd +PID=/var/run/forked-daapd.pid +SSD=start-stop-daemon + +start() { + $SSD -p $PID -S -x $BIN -- -P $PID +} + +stop() { + $SSD -p $PID -K -s SIGINT +} diff --git a/sound/forked-daapd/patches/010-include_pregen.patch b/sound/forked-daapd/patches/010-include_pregen.patch new file mode 100644 index 000000000..2518ddae1 --- /dev/null +++ b/sound/forked-daapd/patches/010-include_pregen.patch @@ -0,0 +1,14782 @@ +diff --git a/src/pregen/DAAP.u b/src/pregen/DAAP.u +new file mode 100644 +index 0000000..3de527b +--- /dev/null ++++ b/src/pregen/DAAP.u +@@ -0,0 +1,6 @@ ++DAAPParser.c : DAAP.g ++./DAAP.tokens : DAAP.g ++DAAPParser.h : DAAP.g ++DAAPLexer.c : DAAP.g ++DAAPLexer.h : DAAP.g ++ANTLR_PRODUCTS += DAAPParser.c ./DAAP.tokens DAAPParser.h DAAPLexer.c DAAPLexer.h +\ No newline at end of file +diff --git a/src/pregen/DAAP2SQL.c b/src/pregen/DAAP2SQL.c +new file mode 100644 +index 0000000..3f94589 +--- /dev/null ++++ b/src/pregen/DAAP2SQL.c +@@ -0,0 +1,929 @@ ++/** \file ++ * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3 ++ * ++ * - From the grammar source file : DAAP2SQL.g ++ * - On : 2014-09-30 21:42:43 ++ * - for the tree parser : DAAP2SQLTreeParser * ++ * Editing it, at least manually, is not wise. ++ * ++ * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. ++ * ++ * ++*/ ++// [The "BSD licence"] ++// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC ++// http://www.temporal-wave.com ++// http://www.linkedin.com/in/jimidle ++// ++// All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions ++// are met: ++// 1. Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// 2. Redistributions in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// 3. The name of the author may not be used to endorse or promote products ++// derived from this software without specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++ ++/* ============================================================================= ++ * This is what the grammar programmer asked us to put at the top of every file. ++ */ ++ ++ #include ++ #include ++ #include ++ #include ++ #include ++ ++ #include "logger.h" ++ #include "db.h" ++ #include "daap_query.h" ++ ++/* End of Header action. ++ * ============================================================================= ++ */ ++/* ----------------------------------------- ++ * Include the ANTLR3 generated header file. ++ */ ++#include "DAAP2SQL.h" ++/* ----------------------------------------- */ ++ ++ ++ ++ ++ ++/* MACROS that hide the C interface implementations from the ++ * generated code, which makes it a little more understandable to the human eye. ++ * I am very much against using C pre-processor macros for function calls and bits ++ * of code as you cannot see what is happening when single stepping in debuggers ++ * and so on. The exception (in my book at least) is for generated code, where you are ++ * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() ++ * hides some indirect calls, but is always referring to the input stream. This is ++ * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig ++ * the runtime interfaces without changing the generated code too often, without ++ * confusing the reader of the generated output, who may not wish to know the gory ++ * details of the interface inheritance. ++ */ ++ ++#define CTX ctx ++ ++/* Aids in accessing scopes for grammar programmers ++ */ ++#undef SCOPE_TYPE ++#undef SCOPE_STACK ++#undef SCOPE_TOP ++#define SCOPE_TYPE(scope) pDAAP2SQL_##scope##_SCOPE ++#define SCOPE_STACK(scope) pDAAP2SQL_##scope##Stack ++#define SCOPE_TOP(scope) ctx->pDAAP2SQL_##scope##Top ++#define SCOPE_SIZE(scope) ctx->pDAAP2SQL_##scope##Stack_limit ++#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) ++ ++/* Macros for accessing things in the parser ++ */ ++ ++#undef PARSER ++#undef RECOGNIZER ++#undef HAVEPARSEDRULE ++#undef INPUT ++#undef STRSTREAM ++#undef HASEXCEPTION ++#undef EXCEPTION ++#undef MATCHT ++#undef MATCHANYT ++#undef FOLLOWSTACK ++#undef FOLLOWPUSH ++#undef FOLLOWPOP ++#undef PRECOVER ++#undef PREPORTERROR ++#undef LA ++#undef LT ++#undef CONSTRUCTEX ++#undef CONSUME ++#undef MARK ++#undef REWIND ++#undef REWINDLAST ++#undef PERRORRECOVERY ++#undef HASFAILED ++#undef FAILEDFLAG ++#undef RECOVERFROMMISMATCHEDSET ++#undef RECOVERFROMMISMATCHEDELEMENT ++#undef BACKTRACKING ++#undef ADAPTOR ++#undef RULEMEMO ++#undef SEEK ++#undef INDEX ++#undef DBG ++ ++#define PARSER ctx->pTreeParser ++#define RECOGNIZER PARSER->rec ++#define PSRSTATE RECOGNIZER->state ++#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) ++#define INPUT PARSER->ctnstream ++#define ISTREAM INPUT->tnstream->istream ++#define STRSTREAM INPUT->tnstream ++#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE) ++#define EXCEPTION PSRSTATE->exception ++#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs) ++#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER) ++#define FOLLOWSTACK PSRSTATE->following ++#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL) ++#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK) ++#define PRECOVER() RECOGNIZER->recover(RECOGNIZER) ++#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER) ++#define LA(n) ISTREAM->_LA(ISTREAM, n) ++#define LT(n) INPUT->tnstream->_LT(INPUT->tnstream, n) ++#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) ++#define CONSUME() ISTREAM->consume(ISTREAM) ++#define MARK() ISTREAM->mark(ISTREAM) ++#define REWIND(m) ISTREAM->rewind(ISTREAM, m) ++#define REWINDLAST() ISTREAM->rewindLast(ISTREAM) ++#define PERRORRECOVERY PSRSTATE->errorRecovery ++#define FAILEDFLAG PSRSTATE->failed ++#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE) ++#define BACKTRACKING PSRSTATE->backtracking ++#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s) ++#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s) ++#define ADAPTOR INPUT->adaptor ++#define RULEMEMO PSRSTATE->ruleMemo ++#define SEEK(n) ISTREAM->seek(ISTREAM, n) ++#define INDEX() ISTREAM->index(ISTREAM) ++#define DBG RECOGNIZER->debugger ++ ++ ++#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt ++ ++/* The 4 tokens defined below may well clash with your own #defines or token types. If so ++ * then for the present you must use different names for your defines as these are hard coded ++ * in the code generator. It would be better not to use such names internally, and maybe ++ * we can change this in a forthcoming release. I deliberately do not #undef these ++ * here as this will at least give you a redefined error somewhere if they clash. ++ */ ++#define UP ANTLR3_TOKEN_UP ++#define DOWN ANTLR3_TOKEN_DOWN ++#define EOR ANTLR3_TOKEN_EOR ++#define INVALID ANTLR3_TOKEN_INVALID ++ ++ ++/* ============================================================================= ++ * Functions to create and destroy scopes. First come the rule scopes, followed ++ * by the global declared scopes. ++ */ ++ ++ ++ ++/* ============================================================================= */ ++ ++/* ============================================================================= ++ * Start of recognizer ++ */ ++ ++ ++ ++/** \brief Table of all token names in symbolic order, mainly used for ++ * error reporting. ++ */ ++pANTLR3_UINT8 DAAP2SQLTokenNames[8+4] ++ = { ++ (pANTLR3_UINT8) "", /* String to print to indicate an invalid token */ ++ (pANTLR3_UINT8) "", ++ (pANTLR3_UINT8) "", ++ (pANTLR3_UINT8) "", ++ (pANTLR3_UINT8) "NEWLINE", ++ (pANTLR3_UINT8) "OPOR", ++ (pANTLR3_UINT8) "OPAND", ++ (pANTLR3_UINT8) "LPAR", ++ (pANTLR3_UINT8) "RPAR", ++ (pANTLR3_UINT8) "STR", ++ (pANTLR3_UINT8) "QUOTE", ++ (pANTLR3_UINT8) "ESCAPED" ++ }; ++ ++ ++ ++// Forward declare the locally static matching functions we have generated. ++// ++static pANTLR3_STRING query (pDAAP2SQL ctx); ++static DAAP2SQL_expr_return expr (pDAAP2SQL ctx); ++static void DAAP2SQLFree(pDAAP2SQL ctx); ++/* For use in tree output where we are accumulating rule labels via label += ruleRef ++ * we need a function that knows how to free a return scope when the list is destroyed. ++ * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro. ++ */ ++static void ANTLR3_CDECL freeScope(void * scope) ++{ ++ ANTLR3_FREE(scope); ++} ++ ++/** \brief Name of the grammar file that generated this code ++ */ ++static const char fileName[] = "DAAP2SQL.g"; ++ ++/** \brief Return the name of the grammar file that generated this code. ++ */ ++static const char * getGrammarFileName() ++{ ++ return fileName; ++} ++/** \brief Create a new DAAP2SQL parser and return a context for it. ++ * ++ * \param[in] instream Pointer to an input stream interface. ++ * ++ * \return Pointer to new parser context upon success. ++ */ ++ANTLR3_API pDAAP2SQL ++DAAP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream) ++{ ++ // See if we can create a new parser with the standard constructor ++ // ++ return DAAP2SQLNewSSD(instream, NULL); ++} ++ ++/** \brief Create a new DAAP2SQL parser and return a context for it. ++ * ++ * \param[in] instream Pointer to an input stream interface. ++ * ++ * \return Pointer to new parser context upon success. ++ */ ++ANTLR3_API pDAAP2SQL ++DAAP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) ++{ ++ pDAAP2SQL ctx; /* Context structure we will build and return */ ++ ++ ctx = (pDAAP2SQL) ANTLR3_CALLOC(1, sizeof(DAAP2SQL)); ++ ++ if (ctx == NULL) ++ { ++ // Failed to allocate memory for parser context ++ // ++ return NULL; ++ } ++ ++ /* ------------------------------------------------------------------- ++ * Memory for basic structure is allocated, now to fill in ++ * the base ANTLR3 structures. We initialize the function pointers ++ * for the standard ANTLR3 parser function set, but upon return ++ * from here, the programmer may set the pointers to provide custom ++ * implementations of each function. ++ * ++ * We don't use the macros defined in DAAP2SQL.h here, in order that you can get a sense ++ * of what goes where. ++ */ ++ ++ /* Create a base Tree parser/recognizer, using the supplied tree node stream ++ */ ++ ctx->pTreeParser = antlr3TreeParserNewStream(ANTLR3_SIZE_HINT, instream, state); ++ /* Install the implementation of our DAAP2SQL interface ++ */ ++ ctx->query = query; ++ ctx->expr = expr; ++ ctx->free = DAAP2SQLFree; ++ ctx->getGrammarFileName = getGrammarFileName; ++ ++ /* Install the scope pushing methods. ++ */ ++ ++ ++ ++ ++ ++ /* Install the token table ++ */ ++ PSRSTATE->tokenNames = DAAP2SQLTokenNames; ++ ++ ++ /* Return the newly built parser to the caller ++ */ ++ return ctx; ++} ++ ++/** Free the parser resources ++ */ ++ static void ++ DAAP2SQLFree(pDAAP2SQL ctx) ++ { ++ /* Free any scope memory ++ */ ++ ++ ++ // Free this parser ++ // ++ ctx->pTreeParser->free(ctx->pTreeParser); ++ ANTLR3_FREE(ctx); ++ ++ /* Everything is released, so we can return ++ */ ++ return; ++ } ++ ++/** Return token names used by this tree parser ++ * ++ * The returned pointer is used as an index into the token names table (using the token ++ * number as the index). ++ * ++ * \return Pointer to first char * in the table. ++ */ ++static pANTLR3_UINT8 *getTokenNames() ++{ ++ return DAAP2SQLTokenNames; ++} ++ ++ ++ struct dmap_query_field_map { ++ char *dmap_field; ++ char *db_col; ++ int as_int; ++ }; ++ ++ /* gperf static hash, daap_query.gperf */ ++ #include "daap_query_hash.c" ++ ++ ++/* Declare the bitsets ++ */ ++ ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query70 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_query70_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_query70 = { FOLLOW_expr_in_query70_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPAND_in_expr95 */ ++static ANTLR3_BITWORD FOLLOW_OPAND_in_expr95_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; ++static ANTLR3_BITSET_LIST FOLLOW_OPAND_in_expr95 = { FOLLOW_OPAND_in_expr95_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr101 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_expr101_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000260) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr101 = { FOLLOW_expr_in_expr101_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr107 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_expr107_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr107 = { FOLLOW_expr_in_expr107_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPOR_in_expr118 */ ++static ANTLR3_BITWORD FOLLOW_OPOR_in_expr118_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; ++static ANTLR3_BITSET_LIST FOLLOW_OPOR_in_expr118 = { FOLLOW_OPOR_in_expr118_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr124 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_expr124_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000260) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr124 = { FOLLOW_expr_in_expr124_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr130 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_expr130_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr130 = { FOLLOW_expr_in_expr130_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_expr140 */ ++static ANTLR3_BITWORD FOLLOW_STR_in_expr140_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_STR_in_expr140 = { FOLLOW_STR_in_expr140_bits, 1 }; ++ ++ ++ ++ ++/* ============================================== ++ * Parsing rules ++ */ ++/** ++ * $ANTLR start query ++ * DAAP2SQL.g:50:1: query returns [ pANTLR3_STRING result ] : e= expr ; ++ */ ++static pANTLR3_STRING ++query(pDAAP2SQL ctx) ++{ ++ pANTLR3_STRING result = NULL; ++ ++ DAAP2SQL_expr_return e; ++ #undef RETURN_TYPE_e ++ #define RETURN_TYPE_e DAAP2SQL_expr_return ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ result= NULL; ++ { ++ // DAAP2SQL.g:52:2: (e= expr ) ++ // DAAP2SQL.g:52:4: e= expr ++ { ++ FOLLOWPUSH(FOLLOW_expr_in_query70); ++ e=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto rulequeryEx; ++ } ++ ++ { ++ ++ if (!e.valid) ++ { ++ result= NULL; ++ } ++ else ++ { ++ result= e.result->factory->newRaw(e.result->factory); ++ result->append8(result, "("); ++ result->appendS(result, e.result); ++ result->append8(result, ")"); ++ } ++ ++ } ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto rulequeryEx; /* Prevent compiler warnings */ ++ rulequeryEx: ; ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ } ++ ++ ++ return result; ++} ++/* $ANTLR end query */ ++ ++/** ++ * $ANTLR start expr ++ * DAAP2SQL.g:68:1: expr returns [ pANTLR3_STRING result, int valid ] : ( ^( OPAND a= expr b= expr ) | ^( OPOR a= expr b= expr ) | STR ); ++ */ ++static DAAP2SQL_expr_return ++expr(pDAAP2SQL ctx) ++{ ++ DAAP2SQL_expr_return retval; ++ ++ pANTLR3_BASE_TREE STR1; ++ DAAP2SQL_expr_return a; ++ #undef RETURN_TYPE_a ++ #define RETURN_TYPE_a DAAP2SQL_expr_return ++ ++ DAAP2SQL_expr_return b; ++ #undef RETURN_TYPE_b ++ #define RETURN_TYPE_b DAAP2SQL_expr_return ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ retval.result= NULL; retval.valid= 1; ++ STR1 = NULL; ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ { ++ { ++ // DAAP2SQL.g:70:2: ( ^( OPAND a= expr b= expr ) | ^( OPOR a= expr b= expr ) | STR ) ++ ++ ANTLR3_UINT32 alt1; ++ ++ alt1=3; ++ ++ switch ( LA(1) ) ++ { ++ case OPAND: ++ { ++ alt1=1; ++ } ++ break; ++ case OPOR: ++ { ++ alt1=2; ++ } ++ break; ++ case STR: ++ { ++ alt1=3; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 1; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleexprEx; ++ } ++ ++ switch (alt1) ++ { ++ case 1: ++ // DAAP2SQL.g:70:4: ^( OPAND a= expr b= expr ) ++ { ++ MATCHT(OPAND, &FOLLOW_OPAND_in_expr95); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_DOWN, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ FOLLOWPUSH(FOLLOW_expr_in_expr101); ++ a=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ FOLLOWPUSH(FOLLOW_expr_in_expr107); ++ b=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_UP, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ { ++ ++ if (!a.valid || !b.valid) ++ { ++ retval.valid= 0; ++ } ++ else ++ { ++ retval.result= a.result->factory->newRaw(a.result->factory); ++ retval.result->append8(retval.result, "("); ++ retval.result->appendS(retval.result, a.result); ++ retval.result->append8(retval.result, " AND "); ++ retval.result->appendS(retval.result, b.result); ++ retval.result->append8(retval.result, ")"); ++ } ++ ++ } ++ ++ } ++ break; ++ case 2: ++ // DAAP2SQL.g:86:4: ^( OPOR a= expr b= expr ) ++ { ++ MATCHT(OPOR, &FOLLOW_OPOR_in_expr118); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_DOWN, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ FOLLOWPUSH(FOLLOW_expr_in_expr124); ++ a=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ FOLLOWPUSH(FOLLOW_expr_in_expr130); ++ b=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_UP, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ { ++ ++ if (!a.valid || !b.valid) ++ { ++ retval.valid= 0; ++ } ++ else ++ { ++ retval.result= a.result->factory->newRaw(a.result->factory); ++ retval.result->append8(retval.result, "("); ++ retval.result->appendS(retval.result, a.result); ++ retval.result->append8(retval.result, " OR "); ++ retval.result->appendS(retval.result, b.result); ++ retval.result->append8(retval.result, ")"); ++ } ++ ++ } ++ ++ } ++ break; ++ case 3: ++ // DAAP2SQL.g:102:4: STR ++ { ++ STR1 = (pANTLR3_BASE_TREE) MATCHT(STR, &FOLLOW_STR_in_expr140); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ { ++ ++ pANTLR3_STRING str; ++ pANTLR3_UINT8 field; ++ pANTLR3_UINT8 val; ++ pANTLR3_UINT8 escaped; ++ ANTLR3_UINT8 op; ++ int neg_op; ++ const struct dmap_query_field_map *dqfm; ++ char *end; ++ long long llval; ++ ++ escaped = NULL; ++ ++ retval.result= (STR1->getText(STR1))->factory->newRaw((STR1->getText(STR1))->factory); ++ ++ str = (STR1->getText(STR1))->toUTF8((STR1->getText(STR1))); ++ ++ /* NOTE: the lexer delivers the string without quotes ++ which may not be obvious from the grammar due to embedded code ++ */ ++ ++ /* Make daap.songalbumid:0 a no-op */ ++ if (strcmp((char *)str->chars, "daap.songalbumid:0") == 0) ++ { ++ retval.result->append8(retval.result, "1 = 1"); ++ ++ goto STR_out; ++ } ++ ++ field = str->chars; ++ ++ val = field; ++ while ((*val != '\0') && ((*val == '.') ++ || (*val == '-') ++ || ((*val >= 'a') && (*val <= 'z')) ++ || ((*val >= 'A') && (*val <= 'Z')) ++ || ((*val >= '0') && (*val <= '9')))) ++ { ++ val++; ++ } ++ ++ if (*field == '\0') ++ { ++ DPRINTF(E_LOG, L_DAAP, "No field name found in clause '%s'\n", field); ++ retval.valid= 0; ++ goto STR_result_valid_0; /* ABORT */ ++ } ++ ++ if (*val == '\0') ++ { ++ DPRINTF(E_LOG, L_DAAP, "No operator found in clause '%s'\n", field); ++ retval.valid= 0; ++ goto STR_result_valid_0; /* ABORT */ ++ } ++ ++ op = *val; ++ *val = '\0'; ++ val++; ++ ++ if (op == '!') ++ { ++ if (*val == '\0') ++ { ++ DPRINTF(E_LOG, L_DAAP, "Negation found but operator missing in clause '%s%c'\n", field, op); ++ retval.valid= 0; ++ goto STR_result_valid_0; /* ABORT */ ++ } ++ ++ neg_op = 1; ++ op = *val; ++ val++; ++ } ++ else ++ neg_op = 0; ++ ++ /* Lookup DMAP field in the query field map */ ++ dqfm = daap_query_field_lookup((char *)field, strlen((char *)field)); ++ if (!dqfm) ++ { ++ DPRINTF(E_LOG, L_DAAP, "DMAP field '%s' is not a valid field in queries\n", field); ++ retval.valid= 0; ++ goto STR_result_valid_0; /* ABORT */ ++ } ++ ++ /* Empty values OK for string fields, NOK for integer */ ++ if (*val == '\0') ++ { ++ if (dqfm->as_int) ++ { ++ DPRINTF(E_LOG, L_DAAP, "No value given in clause '%s%s%c'\n", field, (neg_op) ? "!" : "", op); ++ retval.valid= 0; ++ goto STR_result_valid_0; /* ABORT */ ++ } ++ ++ /* Need to check against NULL too */ ++ if (op == ':') ++ retval.result->append8(retval.result, "("); ++ } ++ ++ retval.result->append8(retval.result, dqfm->db_col); ++ ++ /* Int field: check integer conversion */ ++ if (dqfm->as_int) ++ { ++ errno = 0; ++ llval = strtoll((const char *)val, &end, 10); ++ ++ if (((errno == ERANGE) && ((llval == LLONG_MAX) || (llval == LLONG_MIN))) ++ || ((errno != 0) && (llval == 0))) ++ { ++ DPRINTF(E_LOG, L_DAAP, "Value '%s' in clause '%s%s%c%s' does not convert to an integer type\n", ++ val, field, (neg_op) ? "!" : "", op, val); ++ retval.valid= 0; ++ goto STR_result_valid_0; /* ABORT */ ++ } ++ ++ if (end == (char *)val) ++ { ++ DPRINTF(E_LOG, L_DAAP, "Value '%s' in clause '%s%s%c%s' does not represent an integer value\n", ++ val, field, (neg_op) ? "!" : "", op, val); ++ retval.valid= 0; ++ goto STR_result_valid_0; /* ABORT */ ++ } ++ ++ *end = '\0'; /* Cut out potential garbage - we're being kind */ ++ } ++ /* String field: escape string, check for '*' */ ++ else ++ { ++ if (op != ':') ++ { ++ DPRINTF(E_LOG, L_DAAP, "Operation '%c' not valid for string values\n", op); ++ retval.valid= 0; ++ goto STR_result_valid_0; /* ABORT */ ++ } ++ ++ escaped = (pANTLR3_UINT8)db_escape_string((char *)val); ++ if (!escaped) ++ { ++ DPRINTF(E_LOG, L_DAAP, "Could not escape value\n"); ++ retval.valid= 0; ++ goto STR_result_valid_0; /* ABORT */ ++ } ++ ++ val = escaped; ++ ++ if (val[0] == '*') ++ { ++ op = '%'; ++ val[0] = '%'; ++ } ++ ++ if (val[strlen((char *)val) - 1] == '*') ++ { ++ op = '%'; ++ val[strlen((char *)val) - 1] = '%'; ++ } ++ } ++ ++ switch(op) ++ { ++ case ':': ++ if (neg_op) ++ retval.result->append8(retval.result, " <> "); ++ else ++ retval.result->append8(retval.result, " = "); ++ break; ++ ++ case '+': ++ if (neg_op) ++ retval.result->append8(retval.result, " <= "); ++ else ++ retval.result->append8(retval.result, " > "); ++ break; ++ ++ case '-': ++ if (neg_op) ++ retval.result->append8(retval.result, " >= "); ++ else ++ retval.result->append8(retval.result, " < "); ++ break; ++ ++ case '%': ++ retval.result->append8(retval.result, " LIKE "); ++ break; ++ ++ default: ++ if (neg_op) ++ DPRINTF(E_LOG, L_DAAP, "Missing or unknown operator '%c' in clause '%s!%c%s'\n", op, field, op, val); ++ else ++ DPRINTF(E_LOG, L_DAAP, "Unknown operator '%c' in clause '%s%c%s'\n", op, field, op, val); ++ retval.valid= 0; ++ goto STR_result_valid_0; /* ABORT */ ++ break; ++ } ++ ++ if (!dqfm->as_int) ++ retval.result->append8(retval.result, "'"); ++ ++ retval.result->append8(retval.result, (const char *)val); ++ ++ if (!dqfm->as_int) ++ retval.result->append8(retval.result, "'"); ++ ++ /* For empty string value, we need to check against NULL too */ ++ if ((*val == '\0') && (op == ':')) ++ { ++ if (neg_op) ++ retval.result->append8(retval.result, " AND "); ++ else ++ retval.result->append8(retval.result, " OR "); ++ ++ retval.result->append8(retval.result, dqfm->db_col); ++ ++ if (neg_op) ++ retval.result->append8(retval.result, " IS NOT NULL"); ++ else ++ retval.result->append8(retval.result, " IS NULL"); ++ ++ retval.result->append8(retval.result, ")"); ++ } ++ ++ STR_result_valid_0: /* bail out label */ ++ ; ++ ++ if (escaped) ++ free(escaped); ++ ++ STR_out: /* get out of here */ ++ ; ++ ++ } ++ ++ } ++ break; ++ ++ } ++ } ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleexprEx; /* Prevent compiler warnings */ ++ ruleexprEx: ; ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end expr */ ++/* End of parsing rules ++ * ============================================== ++ */ ++ ++/* ============================================== ++ * Syntactic predicates ++ */ ++/* End of syntactic predicates ++ * ============================================== ++ */ ++ ++ ++ ++ ++ ++ ++/* End of code ++ * ============================================================================= ++ */ +diff --git a/src/pregen/DAAP2SQL.h b/src/pregen/DAAP2SQL.h +new file mode 100644 +index 0000000..e170f6c +--- /dev/null ++++ b/src/pregen/DAAP2SQL.h +@@ -0,0 +1,195 @@ ++/** \file ++ * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3 ++ * ++ * - From the grammar source file : DAAP2SQL.g ++ * - On : 2014-09-30 21:42:43 ++ * - for the tree parser : DAAP2SQLTreeParser * ++ * Editing it, at least manually, is not wise. ++ * ++ * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. ++ * ++ * ++ * The tree parser DAAP2SQL has the callable functions (rules) shown below, ++ * which will invoke the code for the associated rule in the source grammar ++ * assuming that the input stream is pointing to a token/text stream that could begin ++ * this rule. ++ * ++ * For instance if you call the first (topmost) rule in a parser grammar, you will ++ * get the results of a full parse, but calling a rule half way through the grammar will ++ * allow you to pass part of a full token stream to the parser, such as for syntax checking ++ * in editors and so on. ++ * ++ * The parser entry points are called indirectly (by function pointer to function) via ++ * a parser context typedef pDAAP2SQL, which is returned from a call to DAAP2SQLNew(). ++ * ++ * The methods in pDAAP2SQL are as follows: ++ * ++ * - pANTLR3_STRING pDAAP2SQL->query(pDAAP2SQL) ++ * - DAAP2SQL_expr_return pDAAP2SQL->expr(pDAAP2SQL) ++ * ++ * The return type for any particular rule is of course determined by the source ++ * grammar file. ++ */ ++// [The "BSD licence"] ++// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC ++// http://www.temporal-wave.com ++// http://www.linkedin.com/in/jimidle ++// ++// All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions ++// are met: ++// 1. Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// 2. Redistributions in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// 3. The name of the author may not be used to endorse or promote products ++// derived from this software without specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++#ifndef _DAAP2SQL_H ++#define _DAAP2SQL_H ++/* ============================================================================= ++ * Standard antlr3 C runtime definitions ++ */ ++#include ++ ++/* End of standard antlr 3 runtime definitions ++ * ============================================================================= ++ */ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++// Forward declare the context typedef so that we can use it before it is ++// properly defined. Delegators and delegates (from import statements) are ++// interdependent and their context structures contain pointers to each other ++// C only allows such things to be declared if you pre-declare the typedef. ++// ++typedef struct DAAP2SQL_Ctx_struct DAAP2SQL, * pDAAP2SQL; ++ ++ ++ ++ #include ++ #include ++ #include ++ #include ++ #include ++ ++ #include "logger.h" ++ #include "db.h" ++ #include "daap_query.h" ++ ++ ++#ifdef ANTLR3_WINDOWS ++// Disable: Unreferenced parameter, - Rules with parameters that are not used ++// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) ++// initialized but unused variable - tree rewrite variables declared but not needed ++// Unreferenced local variable - lexer rule declares but does not always use _type ++// potentially unitialized variable used - retval always returned from a rule ++// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns ++// ++// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at ++// and the codegen must generate some of these warnings by necessity, apart from 4100, which is ++// usually generated when a parser rule is given a parameter that it does not use. Mostly though ++// this is a matter of orthogonality hence I disable that one. ++// ++#pragma warning( disable : 4100 ) ++#pragma warning( disable : 4101 ) ++#pragma warning( disable : 4127 ) ++#pragma warning( disable : 4189 ) ++#pragma warning( disable : 4505 ) ++#pragma warning( disable : 4701 ) ++#endif ++typedef struct DAAP2SQL_expr_return_struct ++{ ++ pANTLR3_BASE_TREE start; ++ pANTLR3_BASE_TREE stop; ++ pANTLR3_STRING result; ++ int valid; ++} ++ DAAP2SQL_expr_return; ++ ++ ++ ++/** Context tracking structure for DAAP2SQL ++ */ ++struct DAAP2SQL_Ctx_struct ++{ ++ /** Built in ANTLR3 context tracker contains all the generic elements ++ * required for context tracking. ++ */ ++ pANTLR3_TREE_PARSER pTreeParser; ++ ++ ++ pANTLR3_STRING (*query) (struct DAAP2SQL_Ctx_struct * ctx); ++ DAAP2SQL_expr_return (*expr) (struct DAAP2SQL_Ctx_struct * ctx); ++ // Delegated rules ++ const char * (*getGrammarFileName)(); ++ void (*free) (struct DAAP2SQL_Ctx_struct * ctx); ++ ++}; ++ ++// Function protoypes for the constructor functions that external translation units ++// such as delegators and delegates may wish to call. ++// ++ANTLR3_API pDAAP2SQL DAAP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream); ++ANTLR3_API pDAAP2SQL DAAP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); ++ ++/** Symbolic definitions of all the tokens that the tree parser will work with. ++ * \{ ++ * ++ * Antlr will define EOF, but we can't use that as it it is too common in ++ * in C header files and that would be confusing. There is no way to filter this out at the moment ++ * so we just undef it here for now. That isn't the value we get back from C recognizers ++ * anyway. We are looking for ANTLR3_TOKEN_EOF. ++ */ ++#ifdef EOF ++#undef EOF ++#endif ++#ifdef Tokens ++#undef Tokens ++#endif ++#define STR 9 ++#define QUOTE 10 ++#define NEWLINE 4 ++#define LPAR 7 ++#define OPOR 5 ++#define RPAR 8 ++#define ESCAPED 11 ++#define OPAND 6 ++#define EOF -1 ++#ifdef EOF ++#undef EOF ++#define EOF ANTLR3_TOKEN_EOF ++#endif ++ ++#ifndef TOKENSOURCE ++#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource ++#endif ++ ++/* End of token definitions for DAAP2SQL ++ * ============================================================================= ++ */ ++/** \} */ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif ++ ++/* END - Note:Keep extra line feed to satisfy UNIX systems */ +diff --git a/src/pregen/DAAP2SQL.u b/src/pregen/DAAP2SQL.u +new file mode 100644 +index 0000000..385d80b +--- /dev/null ++++ b/src/pregen/DAAP2SQL.u +@@ -0,0 +1,5 @@ ++DAAP2SQL.g: DAAP.tokens ++DAAP2SQL.c : DAAP2SQL.g ++./DAAP2SQL.tokens : DAAP2SQL.g ++DAAP2SQL.h : DAAP2SQL.g ++ANTLR_PRODUCTS += DAAP2SQL.c ./DAAP2SQL.tokens DAAP2SQL.h +\ No newline at end of file +diff --git a/src/pregen/DAAPLexer.c b/src/pregen/DAAPLexer.c +new file mode 100644 +index 0000000..12e7ef3 +--- /dev/null ++++ b/src/pregen/DAAPLexer.c +@@ -0,0 +1,1101 @@ ++/** \file ++ * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3 ++ * ++ * - From the grammar source file : DAAP.g ++ * - On : 2014-09-30 21:42:40 ++ * - for the lexer : DAAPLexerLexer * ++ * Editing it, at least manually, is not wise. ++ * ++ * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. ++ * ++ * ++*/ ++// [The "BSD licence"] ++// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC ++// http://www.temporal-wave.com ++// http://www.linkedin.com/in/jimidle ++// ++// All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions ++// are met: ++// 1. Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// 2. Redistributions in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// 3. The name of the author may not be used to endorse or promote products ++// derived from this software without specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++/* ----------------------------------------- ++ * Include the ANTLR3 generated header file. ++ */ ++#include "DAAPLexer.h" ++/* ----------------------------------------- */ ++ ++ ++ ++ ++ ++/* MACROS that hide the C interface implementations from the ++ * generated code, which makes it a little more understandable to the human eye. ++ * I am very much against using C pre-processor macros for function calls and bits ++ * of code as you cannot see what is happening when single stepping in debuggers ++ * and so on. The exception (in my book at least) is for generated code, where you are ++ * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() ++ * hides some indirect calls, but is always referring to the input stream. This is ++ * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig ++ * the runtime interfaces without changing the generated code too often, without ++ * confusing the reader of the generated output, who may not wish to know the gory ++ * details of the interface inheritance. ++ */ ++ ++#define CTX ctx ++ ++/* Aids in accessing scopes for grammar programmers ++ */ ++#undef SCOPE_TYPE ++#undef SCOPE_STACK ++#undef SCOPE_TOP ++#define SCOPE_TYPE(scope) pDAAPLexer_##scope##_SCOPE ++#define SCOPE_STACK(scope) pDAAPLexer_##scope##Stack ++#define SCOPE_TOP(scope) ctx->pDAAPLexer_##scope##Top ++#define SCOPE_SIZE(scope) ctx->pDAAPLexer_##scope##Stack_limit ++#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) ++ ++ ++/* Macros for accessing things in a lexer ++ */ ++#undef LEXER ++#undef RECOGNIZER ++#undef RULEMEMO ++#undef GETCHARINDEX ++#undef GETLINE ++#undef GETCHARPOSITIONINLINE ++#undef EMIT ++#undef EMITNEW ++#undef MATCHC ++#undef MATCHS ++#undef MATCHRANGE ++#undef LTOKEN ++#undef HASFAILED ++#undef FAILEDFLAG ++#undef INPUT ++#undef STRSTREAM ++#undef LA ++#undef HASEXCEPTION ++#undef EXCEPTION ++#undef CONSTRUCTEX ++#undef CONSUME ++#undef LRECOVER ++#undef MARK ++#undef REWIND ++#undef REWINDLAST ++#undef BACKTRACKING ++#undef MATCHANY ++#undef MEMOIZE ++#undef HAVEPARSEDRULE ++#undef GETTEXT ++#undef INDEX ++#undef SEEK ++#undef PUSHSTREAM ++#undef POPSTREAM ++#undef SETTEXT ++#undef SETTEXT8 ++ ++#define LEXER ctx->pLexer ++#define RECOGNIZER LEXER->rec ++#define LEXSTATE RECOGNIZER->state ++#define TOKSOURCE LEXSTATE->tokSource ++#define GETCHARINDEX() LEXER->getCharIndex(LEXER) ++#define GETLINE() LEXER->getLine(LEXER) ++#define GETTEXT() LEXER->getText(LEXER) ++#define GETCHARPOSITIONINLINE() LEXER->getCharPositionInLine(LEXER) ++#define EMIT() LEXSTATE->type = _type; LEXER->emit(LEXER) ++#define EMITNEW(t) LEXER->emitNew(LEXER, t) ++#define MATCHC(c) LEXER->matchc(LEXER, c) ++#define MATCHS(s) LEXER->matchs(LEXER, s) ++#define MATCHRANGE(c1,c2) LEXER->matchRange(LEXER, c1, c2) ++#define MATCHANY() LEXER->matchAny(LEXER) ++#define LTOKEN LEXSTATE->token ++#define HASFAILED() (LEXSTATE->failed == ANTLR3_TRUE) ++#define BACKTRACKING LEXSTATE->backtracking ++#define FAILEDFLAG LEXSTATE->failed ++#define INPUT LEXER->input ++#define STRSTREAM INPUT ++#define ISTREAM INPUT->istream ++#define INDEX() ISTREAM->index(ISTREAM) ++#define SEEK(n) ISTREAM->seek(ISTREAM, n) ++#define EOF_TOKEN &(LEXSTATE->tokSource->eofToken) ++#define HASEXCEPTION() (LEXSTATE->error == ANTLR3_TRUE) ++#define EXCEPTION LEXSTATE->exception ++#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) ++#define LRECOVER() LEXER->recover(LEXER) ++#define MARK() ISTREAM->mark(ISTREAM) ++#define REWIND(m) ISTREAM->rewind(ISTREAM, m) ++#define REWINDLAST() ISTREAM->rewindLast(ISTREAM) ++#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si) ++#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) ++#define PUSHSTREAM(str) LEXER->pushCharStream(LEXER, str) ++#define POPSTREAM() LEXER->popCharStream(LEXER) ++#define SETTEXT(str) LEXSTATE->text = str ++#define SKIP() LEXSTATE->token = &(TOKSOURCE->skipToken) ++#define USER1 LEXSTATE->user1 ++#define USER2 LEXSTATE->user2 ++#define USER3 LEXSTATE->user3 ++#define CUSTOM LEXSTATE->custom ++#define RULEMEMO LEXSTATE->ruleMemo ++#define DBG RECOGNIZER->debugger ++ ++/* If we have been told we can rely on the standard 8 bit or 16 bit input ++ * stream, then we can define our macros to use the direct pointers ++ * in the input object, which is much faster than indirect calls. This ++ * is really only significant to lexers with a lot of fragment rules (which ++ * do not place LA(1) in a temporary at the moment) and even then ++ * only if there is a lot of input (order of say 1M or so). ++ */ ++#if defined(ANTLR3_INLINE_INPUT_ASCII) || defined(ANTLR3_INLINE_INPUT_UTF16) ++ ++# ifdef ANTLR3_INLINE_INPUT_ASCII ++ ++/* 8 bit "ASCII" (actually any 8 bit character set) */ ++ ++# define NEXTCHAR ((pANTLR3_UINT8)(INPUT->nextChar)) ++# define DATAP ((pANTLR3_UINT8)(INPUT->data)) ++ ++# else ++ ++# define NEXTCHAR ((pANTLR3_UINT16)(INPUT->nextChar)) ++# define DATAP ((pANTLR3_UINT16)(INPUT->data)) ++ ++# endif ++ ++# define LA(n) ((NEXTCHAR + n) > (DATAP + INPUT->sizeBuf) ? ANTLR3_CHARSTREAM_EOF : (ANTLR3_UCHAR)(*(NEXTCHAR + n - 1))) ++# define CONSUME() \ ++{ \ ++ if (NEXTCHAR < (DATAP + INPUT->sizeBuf)) \ ++ { \ ++ INPUT->charPositionInLine++; \ ++ if ((ANTLR3_UCHAR)(*NEXTCHAR) == INPUT->newlineChar) \ ++ { \ ++ INPUT->line++; \ ++ INPUT->charPositionInLine = 0; \ ++ INPUT->currentLine = (void *)(NEXTCHAR + 1); \ ++ } \ ++ INPUT->nextChar = (void *)(NEXTCHAR + 1); \ ++ } \ ++} ++ ++#else ++ ++// Pick up the input character by calling the input stream implementation. ++// ++#define CONSUME() INPUT->istream->consume(INPUT->istream) ++#define LA(n) INPUT->istream->_LA(INPUT->istream, n) ++ ++#endif ++#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt ++ ++/* The 4 tokens defined below may well clash with your own #defines or token types. If so ++ * then for the present you must use different names for your defines as these are hard coded ++ * in the code generator. It would be better not to use such names internally, and maybe ++ * we can change this in a forthcoming release. I deliberately do not #undef these ++ * here as this will at least give you a redefined error somewhere if they clash. ++ */ ++#define UP ANTLR3_TOKEN_UP ++#define DOWN ANTLR3_TOKEN_DOWN ++#define EOR ANTLR3_TOKEN_EOR ++#define INVALID ANTLR3_TOKEN_INVALID ++ ++ ++/* ============================================================================= ++ * Functions to create and destroy scopes. First come the rule scopes, followed ++ * by the global declared scopes. ++ */ ++ ++ ++ ++/* ============================================================================= */ ++ ++/* ============================================================================= ++ * Start of recognizer ++ */ ++ ++ ++/* Forward declare the locally static matching functions we have generated and any predicate functions. ++ */ ++static ANTLR3_INLINE void mQUOTE (pDAAPLexer ctx); ++static ANTLR3_INLINE void mLPAR (pDAAPLexer ctx); ++static ANTLR3_INLINE void mRPAR (pDAAPLexer ctx); ++static ANTLR3_INLINE void mOPAND (pDAAPLexer ctx); ++static ANTLR3_INLINE void mOPOR (pDAAPLexer ctx); ++static ANTLR3_INLINE void mNEWLINE (pDAAPLexer ctx); ++static ANTLR3_INLINE void mSTR (pDAAPLexer ctx); ++static ANTLR3_INLINE void mESCAPED (pDAAPLexer ctx); ++static ANTLR3_INLINE void mTokens (pDAAPLexer ctx); ++static void DAAPLexerFree(pDAAPLexer ctx); ++ ++/* ========================================================================= ++ * Lexer matching rules end. ++ * ========================================================================= ++ */ ++ ++ ++ ++static void ++DAAPLexerFree (pDAAPLexer ctx) ++{ ++ LEXER->free(LEXER); ++ ++ ANTLR3_FREE(ctx); ++} ++ ++/** \brief Name of the grammar file that generated this code ++ */ ++static const char fileName[] = "DAAP.g"; ++ ++/** \brief Return the name of the grammar file that generated this code. ++ */ ++static const char * getGrammarFileName() ++{ ++ return fileName; ++} ++ ++/** \brief Create a new lexer called DAAPLexer ++ * ++ * \param[in] instream Pointer to an initialized input stream ++ * \return ++ * - Success pDAAPLexer initialized for the lex start ++ * - Fail NULL ++ */ ++ANTLR3_API pDAAPLexer DAAPLexerNew ++(pANTLR3_INPUT_STREAM instream) ++{ ++ // See if we can create a new lexer with the standard constructor ++ // ++ return DAAPLexerNewSSD(instream, NULL); ++} ++ ++/** \brief Create a new lexer called DAAPLexer ++ * ++ * \param[in] instream Pointer to an initialized input stream ++ * \param[state] state Previously created shared recognizer stat ++ * \return ++ * - Success pDAAPLexer initialized for the lex start ++ * - Fail NULL ++ */ ++ANTLR3_API pDAAPLexer DAAPLexerNewSSD ++(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) ++{ ++ pDAAPLexer ctx; // Context structure we will build and return ++ ++ ctx = (pDAAPLexer) ANTLR3_CALLOC(1, sizeof(DAAPLexer)); ++ ++ if (ctx == NULL) ++ { ++ // Failed to allocate memory for lexer context ++ return NULL; ++ } ++ ++ /* ------------------------------------------------------------------- ++ * Memory for basic structure is allocated, now to fill in ++ * in base ANTLR3 structures. We initialize the function pointers ++ * for the standard ANTLR3 lexer function set, but upon return ++ * from here, the programmer may set the pointers to provide custom ++ * implementations of each function. ++ * ++ * We don't use the macros defined in DAAPLexer.h here so you can get a sense ++ * of what goes where. ++ */ ++ ++ /* Create a base lexer, using the supplied input stream ++ */ ++ ctx->pLexer = antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state); ++ ++ /* Check that we allocated the memory correctly ++ */ ++ if (ctx->pLexer == NULL) ++ { ++ ANTLR3_FREE(ctx); ++ return NULL; ++ } ++ /* Install the implementation of our DAAPLexer interface ++ */ ++ ctx->mQUOTE = mQUOTE; ++ ctx->mLPAR = mLPAR; ++ ctx->mRPAR = mRPAR; ++ ctx->mOPAND = mOPAND; ++ ctx->mOPOR = mOPOR; ++ ctx->mNEWLINE = mNEWLINE; ++ ctx->mSTR = mSTR; ++ ctx->mESCAPED = mESCAPED; ++ ctx->mTokens = mTokens; ++ ++ /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE ++ * it will call mTokens() in this generated code, and will pass it the ctx ++ * pointer of this lexer, not the context of the base lexer, so store that now. ++ */ ++ ctx->pLexer->ctx = ctx; ++ ++ /**Install the token matching function ++ */ ++ ctx->pLexer->mTokens = (void (*) (void *))(mTokens); ++ ++ ctx->getGrammarFileName = getGrammarFileName; ++ ctx->free = DAAPLexerFree; ++ ++ ++ ++ ++ ++ /* Return the newly built lexer to the caller ++ */ ++ return ctx; ++} ++ ++ ++/* ========================================================================= ++ * Functions to match the lexer grammar defined tokens from the input stream ++ */ ++ ++// Comes from: 40:7: ( '\\'' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start QUOTE ++ * ++ * Looks to match the characters the constitute the token QUOTE ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mQUOTE(pDAAPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = QUOTE; ++ ++ ++ // DAAP.g:40:7: ( '\\'' ) ++ // DAAP.g:40:9: '\\'' ++ { ++ MATCHC('\''); ++ if (HASEXCEPTION()) ++ { ++ goto ruleQUOTEEx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleQUOTEEx; /* Prevent compiler warnings */ ++ ruleQUOTEEx: ; ++ ++} ++// $ANTLR end QUOTE ++ ++// Comes from: 41:6: ( '(' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start LPAR ++ * ++ * Looks to match the characters the constitute the token LPAR ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mLPAR(pDAAPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = LPAR; ++ ++ ++ // DAAP.g:41:6: ( '(' ) ++ // DAAP.g:41:8: '(' ++ { ++ MATCHC('('); ++ if (HASEXCEPTION()) ++ { ++ goto ruleLPAREx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleLPAREx; /* Prevent compiler warnings */ ++ ruleLPAREx: ; ++ ++} ++// $ANTLR end LPAR ++ ++// Comes from: 42:6: ( ')' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start RPAR ++ * ++ * Looks to match the characters the constitute the token RPAR ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mRPAR(pDAAPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = RPAR; ++ ++ ++ // DAAP.g:42:6: ( ')' ) ++ // DAAP.g:42:8: ')' ++ { ++ MATCHC(')'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleRPAREx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleRPAREx; /* Prevent compiler warnings */ ++ ruleRPAREx: ; ++ ++} ++// $ANTLR end RPAR ++ ++// Comes from: 44:7: ( '+' | ' ' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start OPAND ++ * ++ * Looks to match the characters the constitute the token OPAND ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mOPAND(pDAAPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = OPAND; ++ ++ ++ // DAAP.g:44:7: ( '+' | ' ' ) ++ // DAAP.g: ++ { ++ if ( LA(1) == ' ' || LA(1) == '+' ) ++ { ++ CONSUME(); ++ ++ } ++ else ++ { ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; ++ EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; ++ ++ LRECOVER(); goto ruleOPANDEx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleOPANDEx; /* Prevent compiler warnings */ ++ ruleOPANDEx: ; ++ ++} ++// $ANTLR end OPAND ++ ++// Comes from: 45:6: ( ',' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start OPOR ++ * ++ * Looks to match the characters the constitute the token OPOR ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mOPOR(pDAAPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = OPOR; ++ ++ ++ // DAAP.g:45:6: ( ',' ) ++ // DAAP.g:45:8: ',' ++ { ++ MATCHC(','); ++ if (HASEXCEPTION()) ++ { ++ goto ruleOPOREx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleOPOREx; /* Prevent compiler warnings */ ++ ruleOPOREx: ; ++ ++} ++// $ANTLR end OPOR ++ ++// Comes from: 47:9: ( ( '\\r' )? '\\n' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start NEWLINE ++ * ++ * Looks to match the characters the constitute the token NEWLINE ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mNEWLINE(pDAAPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = NEWLINE; ++ ++ ++ // DAAP.g:47:9: ( ( '\\r' )? '\\n' ) ++ // DAAP.g:47:11: ( '\\r' )? '\\n' ++ { ++ ++ // DAAP.g:47:11: ( '\\r' )? ++ { ++ int alt1=2; ++ switch ( LA(1) ) ++ { ++ case '\r': ++ { ++ alt1=1; ++ } ++ break; ++ } ++ ++ switch (alt1) ++ { ++ case 1: ++ // DAAP.g:47:11: '\\r' ++ { ++ MATCHC('\r'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleNEWLINEEx; ++ } ++ ++ ++ } ++ break; ++ ++ } ++ } ++ MATCHC('\n'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleNEWLINEEx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleNEWLINEEx; /* Prevent compiler warnings */ ++ ruleNEWLINEEx: ; ++ ++} ++// $ANTLR end NEWLINE ++ ++// Comes from: 55:2: ( QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start STR ++ * ++ * Looks to match the characters the constitute the token STR ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mSTR(pDAAPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ pANTLR3_COMMON_TOKEN esc; ++ ANTLR3_UINT32 reg; ++ ++ ++ esc = NULL; ++ ++ _type = STR; ++ ++ pANTLR3_STRING unesc = GETTEXT()->factory->newRaw(GETTEXT()->factory); ++ ++ // DAAP.g:55:2: ( QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE ) ++ // DAAP.g:55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE ++ { ++ /* 55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE */ ++ mQUOTE(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleSTREx; ++ } ++ ++ // DAAP.g:55:10: (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ ++ { ++ int cnt2=0; ++ ++ for (;;) ++ { ++ int alt2=3; ++ { ++ /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) ++ */ ++ int LA2_0 = LA(1); ++ if ( (((LA2_0 >= 0x0000) && (LA2_0 <= '&')) || ((LA2_0 >= '(') && (LA2_0 <= '[')) || ((LA2_0 >= ']') && (LA2_0 <= 0xFFFF))) ) ++ { ++ alt2=1; ++ } ++ else if ( (LA2_0 == '\\') ) ++ { ++ alt2=2; ++ } ++ ++ } ++ switch (alt2) ++ { ++ case 1: ++ // DAAP.g:55:12: reg=~ ( '\\\\' | '\\'' ) ++ { ++ reg= LA(1); ++ if ( ((LA(1) >= 0x0000) && (LA(1) <= '&')) || ((LA(1) >= '(') && (LA(1) <= '[')) || ((LA(1) >= ']') && (LA(1) <= 0xFFFF)) ) ++ { ++ CONSUME(); ++ ++ } ++ else ++ { ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; ++ EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; ++ ++ LRECOVER(); goto ruleSTREx; ++ } ++ ++ { ++ unesc->addc(unesc, reg); ++ } ++ ++ } ++ break; ++ case 2: ++ // DAAP.g:56:6: esc= ESCAPED ++ { ++ /* 56:6: esc= ESCAPED */ ++ { ++ ANTLR3_MARKER escStart118 = GETCHARINDEX(); ++ mESCAPED(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleSTREx; ++ } ++ ++ esc = LEXSTATE->tokFactory->newToken(LEXSTATE->tokFactory); ++ esc->setType(esc, ANTLR3_TOKEN_INVALID); ++ esc->setStartIndex(esc, escStart118); ++ esc->setStopIndex(esc, GETCHARINDEX()-1); ++ esc->input = INPUT; ++ } ++ { ++ unesc->appendS(unesc, GETTEXT()); ++ } ++ ++ } ++ break; ++ ++ default: ++ ++ if ( cnt2 >= 1 ) ++ { ++ goto loop2; ++ } ++ /* mismatchedSetEx() ++ */ ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; ++ EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; ++ ++ ++ goto ruleSTREx; ++ } ++ cnt2++; ++ } ++ loop2: ; /* Jump to here if this rule does not match */ ++ } ++ /* 55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE */ ++ mQUOTE(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleSTREx; ++ } ++ ++ { ++ SETTEXT(unesc); ++ } ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleSTREx; /* Prevent compiler warnings */ ++ ruleSTREx: ; ++ ++ esc = NULL; ++ ++} ++// $ANTLR end STR ++ ++// Comes from: 59:9: ( '\\\\' ( '\\\\' | '\\'' ) ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start ESCAPED ++ * ++ * Looks to match the characters the constitute the token ESCAPED ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mESCAPED(pDAAPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ ++ // DAAP.g:59:9: ( '\\\\' ( '\\\\' | '\\'' ) ) ++ // DAAP.g:59:11: '\\\\' ( '\\\\' | '\\'' ) ++ { ++ MATCHC('\\'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleESCAPEDEx; ++ } ++ ++ ++ // DAAP.g:60:3: ( '\\\\' | '\\'' ) ++ { ++ int alt3=2; ++ switch ( LA(1) ) ++ { ++ case '\\': ++ { ++ alt3=1; ++ } ++ break; ++ case '\'': ++ { ++ alt3=2; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 3; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleESCAPEDEx; ++ } ++ ++ switch (alt3) ++ { ++ case 1: ++ // DAAP.g:60:5: '\\\\' ++ { ++ MATCHC('\\'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleESCAPEDEx; ++ } ++ ++ { ++ SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\\")); ++ } ++ ++ } ++ break; ++ case 2: ++ // DAAP.g:61:5: '\\'' ++ { ++ MATCHC('\''); ++ if (HASEXCEPTION()) ++ { ++ goto ruleESCAPEDEx; ++ } ++ ++ { ++ SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\'")); ++ } ++ ++ } ++ break; ++ ++ } ++ } ++ ++ } ++ ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleESCAPEDEx; /* Prevent compiler warnings */ ++ ruleESCAPEDEx: ; ++ ++} ++// $ANTLR end ESCAPED ++ ++/** This is the entry point in to the lexer from an object that ++ * wants to generate the next token, such as a pCOMMON_TOKEN_STREAM ++ */ ++static void ++mTokens(pDAAPLexer ctx) ++{ ++ { ++ // DAAP.g:1:8: ( QUOTE | LPAR | RPAR | OPAND | OPOR | NEWLINE | STR ) ++ ++ ANTLR3_UINT32 alt4; ++ ++ alt4=7; ++ ++ switch ( LA(1) ) ++ { ++ case '\'': ++ { ++ ++ { ++ int LA4_1 = LA(2); ++ if ( (((LA4_1 >= 0x0000) && (LA4_1 <= '&')) || ((LA4_1 >= '(') && (LA4_1 <= 0xFFFF))) ) ++ { ++ alt4=7; ++ } ++ else ++ { ++ alt4=1; } ++ } ++ } ++ break; ++ case '(': ++ { ++ alt4=2; ++ } ++ break; ++ case ')': ++ { ++ alt4=3; ++ } ++ break; ++ case ' ': ++ case '+': ++ { ++ alt4=4; ++ } ++ break; ++ case ',': ++ { ++ alt4=5; ++ } ++ break; ++ case '\n': ++ case '\r': ++ { ++ alt4=6; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 4; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleTokensEx; ++ } ++ ++ switch (alt4) ++ { ++ case 1: ++ // DAAP.g:1:10: QUOTE ++ { ++ /* 1:10: QUOTE */ ++ mQUOTE(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 2: ++ // DAAP.g:1:16: LPAR ++ { ++ /* 1:16: LPAR */ ++ mLPAR(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 3: ++ // DAAP.g:1:21: RPAR ++ { ++ /* 1:21: RPAR */ ++ mRPAR(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 4: ++ // DAAP.g:1:26: OPAND ++ { ++ /* 1:26: OPAND */ ++ mOPAND(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 5: ++ // DAAP.g:1:32: OPOR ++ { ++ /* 1:32: OPOR */ ++ mOPOR(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 6: ++ // DAAP.g:1:37: NEWLINE ++ { ++ /* 1:37: NEWLINE */ ++ mNEWLINE(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 7: ++ // DAAP.g:1:45: STR ++ { ++ /* 1:45: STR */ ++ mSTR(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ ++ } ++ } ++ ++ ++ goto ruleTokensEx; /* Prevent compiler warnings */ ++ruleTokensEx: ; ++} ++ ++/* ========================================================================= ++ * Lexer matching rules end. ++ * ========================================================================= ++ */ ++/* End of Lexer code ++ * ================================================ ++ * ================================================ ++ */ ++ ++ ++/* End of code ++ * ============================================================================= ++ */ +diff --git a/src/pregen/DAAPLexer.h b/src/pregen/DAAPLexer.h +new file mode 100644 +index 0000000..ba8f58b +--- /dev/null ++++ b/src/pregen/DAAPLexer.h +@@ -0,0 +1,188 @@ ++/** \file ++ * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3 ++ * ++ * - From the grammar source file : DAAP.g ++ * - On : 2014-09-30 21:42:40 ++ * - for the lexer : DAAPLexerLexer * ++ * Editing it, at least manually, is not wise. ++ * ++ * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. ++ * ++ * ++ * The lexer DAAPLexer has the callable functions (rules) shown below, ++ * which will invoke the code for the associated rule in the source grammar ++ * assuming that the input stream is pointing to a token/text stream that could begin ++ * this rule. ++ * ++ * For instance if you call the first (topmost) rule in a parser grammar, you will ++ * get the results of a full parse, but calling a rule half way through the grammar will ++ * allow you to pass part of a full token stream to the parser, such as for syntax checking ++ * in editors and so on. ++ * ++ * The parser entry points are called indirectly (by function pointer to function) via ++ * a parser context typedef pDAAPLexer, which is returned from a call to DAAPLexerNew(). ++ * ++ * As this is a generated lexer, it is unlikely you will call it 'manually'. However ++ * the methods are provided anyway. ++ * * The methods in pDAAPLexer are as follows: ++ * ++ * - void pDAAPLexer->QUOTE(pDAAPLexer) ++ * - void pDAAPLexer->LPAR(pDAAPLexer) ++ * - void pDAAPLexer->RPAR(pDAAPLexer) ++ * - void pDAAPLexer->OPAND(pDAAPLexer) ++ * - void pDAAPLexer->OPOR(pDAAPLexer) ++ * - void pDAAPLexer->NEWLINE(pDAAPLexer) ++ * - void pDAAPLexer->STR(pDAAPLexer) ++ * - void pDAAPLexer->ESCAPED(pDAAPLexer) ++ * - void pDAAPLexer->Tokens(pDAAPLexer) ++ * ++ * The return type for any particular rule is of course determined by the source ++ * grammar file. ++ */ ++// [The "BSD licence"] ++// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC ++// http://www.temporal-wave.com ++// http://www.linkedin.com/in/jimidle ++// ++// All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions ++// are met: ++// 1. Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// 2. Redistributions in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// 3. The name of the author may not be used to endorse or promote products ++// derived from this software without specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++#ifndef _DAAPLexer_H ++#define _DAAPLexer_H ++/* ============================================================================= ++ * Standard antlr3 C runtime definitions ++ */ ++#include ++ ++/* End of standard antlr 3 runtime definitions ++ * ============================================================================= ++ */ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++// Forward declare the context typedef so that we can use it before it is ++// properly defined. Delegators and delegates (from import statements) are ++// interdependent and their context structures contain pointers to each other ++// C only allows such things to be declared if you pre-declare the typedef. ++// ++typedef struct DAAPLexer_Ctx_struct DAAPLexer, * pDAAPLexer; ++ ++ ++ ++#ifdef ANTLR3_WINDOWS ++// Disable: Unreferenced parameter, - Rules with parameters that are not used ++// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) ++// initialized but unused variable - tree rewrite variables declared but not needed ++// Unreferenced local variable - lexer rule declares but does not always use _type ++// potentially unitialized variable used - retval always returned from a rule ++// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns ++// ++// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at ++// and the codegen must generate some of these warnings by necessity, apart from 4100, which is ++// usually generated when a parser rule is given a parameter that it does not use. Mostly though ++// this is a matter of orthogonality hence I disable that one. ++// ++#pragma warning( disable : 4100 ) ++#pragma warning( disable : 4101 ) ++#pragma warning( disable : 4127 ) ++#pragma warning( disable : 4189 ) ++#pragma warning( disable : 4505 ) ++#pragma warning( disable : 4701 ) ++#endif ++ ++/** Context tracking structure for DAAPLexer ++ */ ++struct DAAPLexer_Ctx_struct ++{ ++ /** Built in ANTLR3 context tracker contains all the generic elements ++ * required for context tracking. ++ */ ++ pANTLR3_LEXER pLexer; ++ ++ ++ void (*mQUOTE) (struct DAAPLexer_Ctx_struct * ctx); ++ void (*mLPAR) (struct DAAPLexer_Ctx_struct * ctx); ++ void (*mRPAR) (struct DAAPLexer_Ctx_struct * ctx); ++ void (*mOPAND) (struct DAAPLexer_Ctx_struct * ctx); ++ void (*mOPOR) (struct DAAPLexer_Ctx_struct * ctx); ++ void (*mNEWLINE) (struct DAAPLexer_Ctx_struct * ctx); ++ void (*mSTR) (struct DAAPLexer_Ctx_struct * ctx); ++ void (*mESCAPED) (struct DAAPLexer_Ctx_struct * ctx); ++ void (*mTokens) (struct DAAPLexer_Ctx_struct * ctx); const char * (*getGrammarFileName)(); ++ void (*free) (struct DAAPLexer_Ctx_struct * ctx); ++ ++}; ++ ++// Function protoypes for the constructor functions that external translation units ++// such as delegators and delegates may wish to call. ++// ++ANTLR3_API pDAAPLexer DAAPLexerNew (pANTLR3_INPUT_STREAM instream); ++ANTLR3_API pDAAPLexer DAAPLexerNewSSD (pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); ++ ++/** Symbolic definitions of all the tokens that the lexer will work with. ++ * \{ ++ * ++ * Antlr will define EOF, but we can't use that as it it is too common in ++ * in C header files and that would be confusing. There is no way to filter this out at the moment ++ * so we just undef it here for now. That isn't the value we get back from C recognizers ++ * anyway. We are looking for ANTLR3_TOKEN_EOF. ++ */ ++#ifdef EOF ++#undef EOF ++#endif ++#ifdef Tokens ++#undef Tokens ++#endif ++#define STR 9 ++#define QUOTE 10 ++#define NEWLINE 4 ++#define LPAR 7 ++#define OPOR 5 ++#define RPAR 8 ++#define ESCAPED 11 ++#define OPAND 6 ++#define EOF -1 ++#ifdef EOF ++#undef EOF ++#define EOF ANTLR3_TOKEN_EOF ++#endif ++ ++#ifndef TOKENSOURCE ++#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource ++#endif ++ ++/* End of token definitions for DAAPLexer ++ * ============================================================================= ++ */ ++/** \} */ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif ++ ++/* END - Note:Keep extra line feed to satisfy UNIX systems */ +diff --git a/src/pregen/DAAPParser.c b/src/pregen/DAAPParser.c +new file mode 100644 +index 0000000..6d0239d +--- /dev/null ++++ b/src/pregen/DAAPParser.c +@@ -0,0 +1,1014 @@ ++/** \file ++ * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3 ++ * ++ * - From the grammar source file : DAAP.g ++ * - On : 2014-09-30 21:42:39 ++ * - for the parser : DAAPParserParser * ++ * Editing it, at least manually, is not wise. ++ * ++ * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. ++ * ++ * ++*/ ++// [The "BSD licence"] ++// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC ++// http://www.temporal-wave.com ++// http://www.linkedin.com/in/jimidle ++// ++// All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions ++// are met: ++// 1. Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// 2. Redistributions in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// 3. The name of the author may not be used to endorse or promote products ++// derived from this software without specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++/* ----------------------------------------- ++ * Include the ANTLR3 generated header file. ++ */ ++#include "DAAPParser.h" ++/* ----------------------------------------- */ ++ ++ ++ ++ ++ ++/* MACROS that hide the C interface implementations from the ++ * generated code, which makes it a little more understandable to the human eye. ++ * I am very much against using C pre-processor macros for function calls and bits ++ * of code as you cannot see what is happening when single stepping in debuggers ++ * and so on. The exception (in my book at least) is for generated code, where you are ++ * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() ++ * hides some indirect calls, but is always referring to the input stream. This is ++ * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig ++ * the runtime interfaces without changing the generated code too often, without ++ * confusing the reader of the generated output, who may not wish to know the gory ++ * details of the interface inheritance. ++ */ ++ ++#define CTX ctx ++ ++/* Aids in accessing scopes for grammar programmers ++ */ ++#undef SCOPE_TYPE ++#undef SCOPE_STACK ++#undef SCOPE_TOP ++#define SCOPE_TYPE(scope) pDAAPParser_##scope##_SCOPE ++#define SCOPE_STACK(scope) pDAAPParser_##scope##Stack ++#define SCOPE_TOP(scope) ctx->pDAAPParser_##scope##Top ++#define SCOPE_SIZE(scope) ctx->pDAAPParser_##scope##Stack_limit ++#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) ++ ++/* Macros for accessing things in the parser ++ */ ++ ++#undef PARSER ++#undef RECOGNIZER ++#undef HAVEPARSEDRULE ++#undef MEMOIZE ++#undef INPUT ++#undef STRSTREAM ++#undef HASEXCEPTION ++#undef EXCEPTION ++#undef MATCHT ++#undef MATCHANYT ++#undef FOLLOWSTACK ++#undef FOLLOWPUSH ++#undef FOLLOWPOP ++#undef PRECOVER ++#undef PREPORTERROR ++#undef LA ++#undef LT ++#undef CONSTRUCTEX ++#undef CONSUME ++#undef MARK ++#undef REWIND ++#undef REWINDLAST ++#undef PERRORRECOVERY ++#undef HASFAILED ++#undef FAILEDFLAG ++#undef RECOVERFROMMISMATCHEDSET ++#undef RECOVERFROMMISMATCHEDELEMENT ++#undef INDEX ++#undef ADAPTOR ++#undef SEEK ++#undef RULEMEMO ++#undef DBG ++ ++#define PARSER ctx->pParser ++#define RECOGNIZER PARSER->rec ++#define PSRSTATE RECOGNIZER->state ++#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) ++#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si) ++#define INPUT PARSER->tstream ++#define STRSTREAM INPUT ++#define ISTREAM INPUT->istream ++#define INDEX() ISTREAM->index(INPUT->istream) ++#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE) ++#define EXCEPTION PSRSTATE->exception ++#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs) ++#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER) ++#define FOLLOWSTACK PSRSTATE->following ++#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL) ++#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK) ++#define PRECOVER() RECOGNIZER->recover(RECOGNIZER) ++#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER) ++#define LA(n) INPUT->istream->_LA(ISTREAM, n) ++#define LT(n) INPUT->_LT(INPUT, n) ++#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) ++#define CONSUME() ISTREAM->consume(ISTREAM) ++#define MARK() ISTREAM->mark(ISTREAM) ++#define REWIND(m) ISTREAM->rewind(ISTREAM, m) ++#define REWINDLAST() ISTREAM->rewindLast(ISTREAM) ++#define SEEK(n) ISTREAM->seek(ISTREAM, n) ++#define PERRORRECOVERY PSRSTATE->errorRecovery ++#define FAILEDFLAG PSRSTATE->failed ++#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE) ++#define BACKTRACKING PSRSTATE->backtracking ++#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s) ++#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s) ++#define ADAPTOR ctx->adaptor ++#define RULEMEMO PSRSTATE->ruleMemo ++#define DBG RECOGNIZER->debugger ++ ++#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt ++ ++/* The 4 tokens defined below may well clash with your own #defines or token types. If so ++ * then for the present you must use different names for your defines as these are hard coded ++ * in the code generator. It would be better not to use such names internally, and maybe ++ * we can change this in a forthcoming release. I deliberately do not #undef these ++ * here as this will at least give you a redefined error somewhere if they clash. ++ */ ++#define UP ANTLR3_TOKEN_UP ++#define DOWN ANTLR3_TOKEN_DOWN ++#define EOR ANTLR3_TOKEN_EOR ++#define INVALID ANTLR3_TOKEN_INVALID ++ ++ ++/* ============================================================================= ++ * Functions to create and destroy scopes. First come the rule scopes, followed ++ * by the global declared scopes. ++ */ ++ ++ ++ ++/* ============================================================================= */ ++ ++/* ============================================================================= ++ * Start of recognizer ++ */ ++ ++ ++ ++/** \brief Table of all token names in symbolic order, mainly used for ++ * error reporting. ++ */ ++pANTLR3_UINT8 DAAPParserTokenNames[8+4] ++ = { ++ (pANTLR3_UINT8) "", /* String to print to indicate an invalid token */ ++ (pANTLR3_UINT8) "", ++ (pANTLR3_UINT8) "", ++ (pANTLR3_UINT8) "", ++ (pANTLR3_UINT8) "NEWLINE", ++ (pANTLR3_UINT8) "OPOR", ++ (pANTLR3_UINT8) "OPAND", ++ (pANTLR3_UINT8) "LPAR", ++ (pANTLR3_UINT8) "RPAR", ++ (pANTLR3_UINT8) "STR", ++ (pANTLR3_UINT8) "QUOTE", ++ (pANTLR3_UINT8) "ESCAPED" ++ }; ++ ++ ++ ++// Forward declare the locally static matching functions we have generated. ++// ++static DAAPParser_query_return query (pDAAPParser ctx); ++static DAAPParser_expr_return expr (pDAAPParser ctx); ++static DAAPParser_aexpr_return aexpr (pDAAPParser ctx); ++static DAAPParser_crit_return crit (pDAAPParser ctx); ++static void DAAPParserFree(pDAAPParser ctx); ++/* For use in tree output where we are accumulating rule labels via label += ruleRef ++ * we need a function that knows how to free a return scope when the list is destroyed. ++ * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro. ++ */ ++static void ANTLR3_CDECL freeScope(void * scope) ++{ ++ ANTLR3_FREE(scope); ++} ++ ++/** \brief Name of the grammar file that generated this code ++ */ ++static const char fileName[] = "DAAP.g"; ++ ++/** \brief Return the name of the grammar file that generated this code. ++ */ ++static const char * getGrammarFileName() ++{ ++ return fileName; ++} ++/** \brief Create a new DAAPParser parser and return a context for it. ++ * ++ * \param[in] instream Pointer to an input stream interface. ++ * ++ * \return Pointer to new parser context upon success. ++ */ ++ANTLR3_API pDAAPParser ++DAAPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream) ++{ ++ // See if we can create a new parser with the standard constructor ++ // ++ return DAAPParserNewSSD(instream, NULL); ++} ++ ++/** \brief Create a new DAAPParser parser and return a context for it. ++ * ++ * \param[in] instream Pointer to an input stream interface. ++ * ++ * \return Pointer to new parser context upon success. ++ */ ++ANTLR3_API pDAAPParser ++DAAPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) ++{ ++ pDAAPParser ctx; /* Context structure we will build and return */ ++ ++ ctx = (pDAAPParser) ANTLR3_CALLOC(1, sizeof(DAAPParser)); ++ ++ if (ctx == NULL) ++ { ++ // Failed to allocate memory for parser context ++ // ++ return NULL; ++ } ++ ++ /* ------------------------------------------------------------------- ++ * Memory for basic structure is allocated, now to fill in ++ * the base ANTLR3 structures. We initialize the function pointers ++ * for the standard ANTLR3 parser function set, but upon return ++ * from here, the programmer may set the pointers to provide custom ++ * implementations of each function. ++ * ++ * We don't use the macros defined in DAAPParser.h here, in order that you can get a sense ++ * of what goes where. ++ */ ++ ++ /* Create a base parser/recognizer, using the supplied token stream ++ */ ++ ctx->pParser = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state); ++ /* Install the implementation of our DAAPParser interface ++ */ ++ ctx->query = query; ++ ctx->expr = expr; ++ ctx->aexpr = aexpr; ++ ctx->crit = crit; ++ ctx->free = DAAPParserFree; ++ ctx->getGrammarFileName = getGrammarFileName; ++ ++ /* Install the scope pushing methods. ++ */ ++ ADAPTOR = ANTLR3_TREE_ADAPTORNew(instream->tstream->tokenSource->strFactory); ++ ctx->vectors = antlr3VectorFactoryNew(0); ++ ++ ++ ++ /* Install the token table ++ */ ++ PSRSTATE->tokenNames = DAAPParserTokenNames; ++ ++ ++ /* Return the newly built parser to the caller ++ */ ++ return ctx; ++} ++ ++/** Free the parser resources ++ */ ++ static void ++ DAAPParserFree(pDAAPParser ctx) ++ { ++ /* Free any scope memory ++ */ ++ ++ ctx->vectors->close(ctx->vectors); ++ /* We created the adaptor so we must free it ++ */ ++ ADAPTOR->free(ADAPTOR); ++ // Free this parser ++ // ++ ctx->pParser->free(ctx->pParser); ++ ANTLR3_FREE(ctx); ++ ++ /* Everything is released, so we can return ++ */ ++ return; ++ } ++ ++/** Return token names used by this parser ++ * ++ * The returned pointer is used as an index into the token names table (using the token ++ * number as the index). ++ * ++ * \return Pointer to first char * in the table. ++ */ ++static pANTLR3_UINT8 *getTokenNames() ++{ ++ return DAAPParserTokenNames; ++} ++ ++ ++/* Declare the bitsets ++ */ ++ ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query42 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_query42_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000010) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_query42 = { FOLLOW_expr_in_query42_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_NEWLINE_in_query44 */ ++static ANTLR3_BITWORD FOLLOW_NEWLINE_in_query44_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000000) }; ++static ANTLR3_BITSET_LIST FOLLOW_NEWLINE_in_query44 = { FOLLOW_NEWLINE_in_query44_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_EOF_in_query47 */ ++static ANTLR3_BITWORD FOLLOW_EOF_in_query47_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_EOF_in_query47 = { FOLLOW_EOF_in_query47_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr62 */ ++static ANTLR3_BITWORD FOLLOW_aexpr_in_expr62_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) }; ++static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr62 = { FOLLOW_aexpr_in_expr62_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPOR_in_expr65 */ ++static ANTLR3_BITWORD FOLLOW_OPOR_in_expr65_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) }; ++static ANTLR3_BITSET_LIST FOLLOW_OPOR_in_expr65 = { FOLLOW_OPOR_in_expr65_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr68 */ ++static ANTLR3_BITWORD FOLLOW_aexpr_in_expr68_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) }; ++static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr68 = { FOLLOW_aexpr_in_expr68_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr80 */ ++static ANTLR3_BITWORD FOLLOW_crit_in_aexpr80_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) }; ++static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr80 = { FOLLOW_crit_in_aexpr80_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPAND_in_aexpr83 */ ++static ANTLR3_BITWORD FOLLOW_OPAND_in_aexpr83_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) }; ++static ANTLR3_BITSET_LIST FOLLOW_OPAND_in_aexpr83 = { FOLLOW_OPAND_in_aexpr83_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr86 */ ++static ANTLR3_BITWORD FOLLOW_crit_in_aexpr86_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) }; ++static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr86 = { FOLLOW_crit_in_aexpr86_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_LPAR_in_crit98 */ ++static ANTLR3_BITWORD FOLLOW_LPAR_in_crit98_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) }; ++static ANTLR3_BITSET_LIST FOLLOW_LPAR_in_crit98 = { FOLLOW_LPAR_in_crit98_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_crit100 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_crit100_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000100) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_crit100 = { FOLLOW_expr_in_crit100_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_RPAR_in_crit102 */ ++static ANTLR3_BITWORD FOLLOW_RPAR_in_crit102_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_RPAR_in_crit102 = { FOLLOW_RPAR_in_crit102_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_crit112 */ ++static ANTLR3_BITWORD FOLLOW_STR_in_crit112_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_STR_in_crit112 = { FOLLOW_STR_in_crit112_bits, 1 }; ++ ++ ++ ++ ++/* ============================================== ++ * Parsing rules ++ */ ++/** ++ * $ANTLR start query ++ * DAAP.g:27:1: query : expr ( NEWLINE )? EOF -> expr ; ++ */ ++static DAAPParser_query_return ++query(pDAAPParser ctx) ++{ ++ DAAPParser_query_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN NEWLINE2; ++ pANTLR3_COMMON_TOKEN EOF3; ++ DAAPParser_expr_return expr1; ++ #undef RETURN_TYPE_expr1 ++ #define RETURN_TYPE_expr1 DAAPParser_expr_return ++ ++ pANTLR3_BASE_TREE NEWLINE2_tree; ++ pANTLR3_BASE_TREE EOF3_tree; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NEWLINE; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_EOF; ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr; ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ NEWLINE2 = NULL; ++ EOF3 = NULL; ++ expr1.tree = NULL; ++ ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ NEWLINE2_tree = NULL; ++ EOF3_tree = NULL; ++ ++ stream_NEWLINE = NULL; ++ #define CREATE_stream_NEWLINE if (stream_NEWLINE == NULL) {stream_NEWLINE = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NEWLINE"); } ++ stream_EOF = NULL; ++ #define CREATE_stream_EOF if (stream_EOF == NULL) {stream_EOF = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token EOF"); } ++ stream_expr = NULL; ++ #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); } ++ ++ retval.tree = NULL; ++ { ++ // DAAP.g:27:7: ( expr ( NEWLINE )? EOF -> expr ) ++ // DAAP.g:27:9: expr ( NEWLINE )? EOF ++ { ++ FOLLOWPUSH(FOLLOW_expr_in_query42); ++ expr1=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto rulequeryEx; ++ } ++ ++ CREATE_stream_expr; stream_expr->add(stream_expr, expr1.tree, NULL); ++ ++ // DAAP.g:27:14: ( NEWLINE )? ++ { ++ int alt1=2; ++ switch ( LA(1) ) ++ { ++ case NEWLINE: ++ { ++ alt1=1; ++ } ++ break; ++ } ++ ++ switch (alt1) ++ { ++ case 1: ++ // DAAP.g:27:14: NEWLINE ++ { ++ NEWLINE2 = (pANTLR3_COMMON_TOKEN) MATCHT(NEWLINE, &FOLLOW_NEWLINE_in_query44); ++ if (HASEXCEPTION()) ++ { ++ goto rulequeryEx; ++ } ++ ++ CREATE_stream_NEWLINE; stream_NEWLINE->add(stream_NEWLINE, NEWLINE2, NULL); ++ ++ ++ } ++ break; ++ ++ } ++ } ++ EOF3 = (pANTLR3_COMMON_TOKEN) MATCHT(EOF, &FOLLOW_EOF_in_query47); ++ if (HASEXCEPTION()) ++ { ++ goto rulequeryEx; ++ } ++ ++ CREATE_stream_EOF; stream_EOF->add(stream_EOF, EOF3, NULL); ++ ++ ++ ++ /* AST REWRITE ++ * elements : expr ++ * token labels : ++ * rule labels : retval ++ * token list labels : ++ * rule list labels : ++ */ ++ { ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; ++ ++ stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); ++ ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ retval.tree = root_0; ++ // 27:27: -> expr ++ { ++ ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr)); ++ ++ } ++ ++ retval.tree = root_0; // set result root ++ if (stream_retval != NULL) stream_retval->free(stream_retval); ++ ++ ++ } ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto rulequeryEx; /* Prevent compiler warnings */ ++ rulequeryEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ if (stream_NEWLINE != NULL) stream_NEWLINE->free(stream_NEWLINE); ++ if (stream_EOF != NULL) stream_EOF->free(stream_EOF); ++ if (stream_expr != NULL) stream_expr->free(stream_expr); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end query */ ++ ++/** ++ * $ANTLR start expr ++ * DAAP.g:30:1: expr : aexpr ( OPOR aexpr )* ; ++ */ ++static DAAPParser_expr_return ++expr(pDAAPParser ctx) ++{ ++ DAAPParser_expr_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN OPOR5; ++ DAAPParser_aexpr_return aexpr4; ++ #undef RETURN_TYPE_aexpr4 ++ #define RETURN_TYPE_aexpr4 DAAPParser_aexpr_return ++ ++ DAAPParser_aexpr_return aexpr6; ++ #undef RETURN_TYPE_aexpr6 ++ #define RETURN_TYPE_aexpr6 DAAPParser_aexpr_return ++ ++ pANTLR3_BASE_TREE OPOR5_tree; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ OPOR5 = NULL; ++ aexpr4.tree = NULL; ++ ++ aexpr6.tree = NULL; ++ ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ OPOR5_tree = NULL; ++ ++ ++ retval.tree = NULL; ++ { ++ // DAAP.g:30:6: ( aexpr ( OPOR aexpr )* ) ++ // DAAP.g:30:8: aexpr ( OPOR aexpr )* ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ FOLLOWPUSH(FOLLOW_aexpr_in_expr62); ++ aexpr4=aexpr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, aexpr4.tree); ++ ++ // DAAP.g:30:14: ( OPOR aexpr )* ++ ++ for (;;) ++ { ++ int alt2=2; ++ switch ( LA(1) ) ++ { ++ case OPOR: ++ { ++ alt2=1; ++ } ++ break; ++ ++ } ++ ++ switch (alt2) ++ { ++ case 1: ++ // DAAP.g:30:15: OPOR aexpr ++ { ++ OPOR5 = (pANTLR3_COMMON_TOKEN) MATCHT(OPOR, &FOLLOW_OPOR_in_expr65); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ OPOR5_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OPOR5)); ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OPOR5_tree, root_0)); ++ ++ FOLLOWPUSH(FOLLOW_aexpr_in_expr68); ++ aexpr6=aexpr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, aexpr6.tree); ++ ++ } ++ break; ++ ++ default: ++ goto loop2; /* break out of the loop */ ++ break; ++ } ++ } ++ loop2: ; /* Jump out to here if this rule does not match */ ++ ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleexprEx; /* Prevent compiler warnings */ ++ ruleexprEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end expr */ ++ ++/** ++ * $ANTLR start aexpr ++ * DAAP.g:33:1: aexpr : crit ( OPAND crit )* ; ++ */ ++static DAAPParser_aexpr_return ++aexpr(pDAAPParser ctx) ++{ ++ DAAPParser_aexpr_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN OPAND8; ++ DAAPParser_crit_return crit7; ++ #undef RETURN_TYPE_crit7 ++ #define RETURN_TYPE_crit7 DAAPParser_crit_return ++ ++ DAAPParser_crit_return crit9; ++ #undef RETURN_TYPE_crit9 ++ #define RETURN_TYPE_crit9 DAAPParser_crit_return ++ ++ pANTLR3_BASE_TREE OPAND8_tree; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ OPAND8 = NULL; ++ crit7.tree = NULL; ++ ++ crit9.tree = NULL; ++ ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ OPAND8_tree = NULL; ++ ++ ++ retval.tree = NULL; ++ { ++ // DAAP.g:33:7: ( crit ( OPAND crit )* ) ++ // DAAP.g:33:9: crit ( OPAND crit )* ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ FOLLOWPUSH(FOLLOW_crit_in_aexpr80); ++ crit7=crit(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleaexprEx; ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, crit7.tree); ++ ++ // DAAP.g:33:14: ( OPAND crit )* ++ ++ for (;;) ++ { ++ int alt3=2; ++ switch ( LA(1) ) ++ { ++ case OPAND: ++ { ++ alt3=1; ++ } ++ break; ++ ++ } ++ ++ switch (alt3) ++ { ++ case 1: ++ // DAAP.g:33:15: OPAND crit ++ { ++ OPAND8 = (pANTLR3_COMMON_TOKEN) MATCHT(OPAND, &FOLLOW_OPAND_in_aexpr83); ++ if (HASEXCEPTION()) ++ { ++ goto ruleaexprEx; ++ } ++ ++ OPAND8_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OPAND8)); ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OPAND8_tree, root_0)); ++ ++ FOLLOWPUSH(FOLLOW_crit_in_aexpr86); ++ crit9=crit(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleaexprEx; ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, crit9.tree); ++ ++ } ++ break; ++ ++ default: ++ goto loop3; /* break out of the loop */ ++ break; ++ } ++ } ++ loop3: ; /* Jump out to here if this rule does not match */ ++ ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleaexprEx; /* Prevent compiler warnings */ ++ ruleaexprEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end aexpr */ ++ ++/** ++ * $ANTLR start crit ++ * DAAP.g:36:1: crit : ( LPAR expr RPAR -> expr | STR ); ++ */ ++static DAAPParser_crit_return ++crit(pDAAPParser ctx) ++{ ++ DAAPParser_crit_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN LPAR10; ++ pANTLR3_COMMON_TOKEN RPAR12; ++ pANTLR3_COMMON_TOKEN STR13; ++ DAAPParser_expr_return expr11; ++ #undef RETURN_TYPE_expr11 ++ #define RETURN_TYPE_expr11 DAAPParser_expr_return ++ ++ pANTLR3_BASE_TREE LPAR10_tree; ++ pANTLR3_BASE_TREE RPAR12_tree; ++ pANTLR3_BASE_TREE STR13_tree; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_RPAR; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_LPAR; ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr; ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ LPAR10 = NULL; ++ RPAR12 = NULL; ++ STR13 = NULL; ++ expr11.tree = NULL; ++ ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ LPAR10_tree = NULL; ++ RPAR12_tree = NULL; ++ STR13_tree = NULL; ++ ++ stream_RPAR = NULL; ++ #define CREATE_stream_RPAR if (stream_RPAR == NULL) {stream_RPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token RPAR"); } ++ stream_LPAR = NULL; ++ #define CREATE_stream_LPAR if (stream_LPAR == NULL) {stream_LPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token LPAR"); } ++ stream_expr = NULL; ++ #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); } ++ ++ retval.tree = NULL; ++ { ++ { ++ // DAAP.g:36:6: ( LPAR expr RPAR -> expr | STR ) ++ ++ ANTLR3_UINT32 alt4; ++ ++ alt4=2; ++ ++ switch ( LA(1) ) ++ { ++ case LPAR: ++ { ++ alt4=1; ++ } ++ break; ++ case STR: ++ { ++ alt4=2; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 4; ++ EXCEPTION->state = 0; ++ ++ ++ goto rulecritEx; ++ } ++ ++ switch (alt4) ++ { ++ case 1: ++ // DAAP.g:36:8: LPAR expr RPAR ++ { ++ LPAR10 = (pANTLR3_COMMON_TOKEN) MATCHT(LPAR, &FOLLOW_LPAR_in_crit98); ++ if (HASEXCEPTION()) ++ { ++ goto rulecritEx; ++ } ++ ++ CREATE_stream_LPAR; stream_LPAR->add(stream_LPAR, LPAR10, NULL); ++ ++ FOLLOWPUSH(FOLLOW_expr_in_crit100); ++ expr11=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto rulecritEx; ++ } ++ ++ CREATE_stream_expr; stream_expr->add(stream_expr, expr11.tree, NULL); ++ RPAR12 = (pANTLR3_COMMON_TOKEN) MATCHT(RPAR, &FOLLOW_RPAR_in_crit102); ++ if (HASEXCEPTION()) ++ { ++ goto rulecritEx; ++ } ++ ++ CREATE_stream_RPAR; stream_RPAR->add(stream_RPAR, RPAR12, NULL); ++ ++ ++ ++ /* AST REWRITE ++ * elements : expr ++ * token labels : ++ * rule labels : retval ++ * token list labels : ++ * rule list labels : ++ */ ++ { ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; ++ ++ stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); ++ ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ retval.tree = root_0; ++ // 36:24: -> expr ++ { ++ ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr)); ++ ++ } ++ ++ retval.tree = root_0; // set result root ++ if (stream_retval != NULL) stream_retval->free(stream_retval); ++ ++ ++ } ++ } ++ break; ++ case 2: ++ // DAAP.g:37:4: STR ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ STR13 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_crit112); ++ if (HASEXCEPTION()) ++ { ++ goto rulecritEx; ++ } ++ ++ STR13_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, STR13)); ++ ADAPTOR->addChild(ADAPTOR, root_0, STR13_tree); ++ ++ ++ } ++ break; ++ ++ } ++ } ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto rulecritEx; /* Prevent compiler warnings */ ++ rulecritEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ if (stream_RPAR != NULL) stream_RPAR->free(stream_RPAR); ++ if (stream_LPAR != NULL) stream_LPAR->free(stream_LPAR); ++ if (stream_expr != NULL) stream_expr->free(stream_expr); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end crit */ ++/* End of parsing rules ++ * ============================================== ++ */ ++ ++/* ============================================== ++ * Syntactic predicates ++ */ ++/* End of syntactic predicates ++ * ============================================== ++ */ ++ ++ ++ ++ ++ ++ ++/* End of code ++ * ============================================================================= ++ */ +diff --git a/src/pregen/DAAPParser.h b/src/pregen/DAAPParser.h +new file mode 100644 +index 0000000..dcc664f +--- /dev/null ++++ b/src/pregen/DAAPParser.h +@@ -0,0 +1,226 @@ ++/** \file ++ * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3 ++ * ++ * - From the grammar source file : DAAP.g ++ * - On : 2014-09-30 21:42:39 ++ * - for the parser : DAAPParserParser * ++ * Editing it, at least manually, is not wise. ++ * ++ * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. ++ * ++ * ++ * The parser DAAPParser has the callable functions (rules) shown below, ++ * which will invoke the code for the associated rule in the source grammar ++ * assuming that the input stream is pointing to a token/text stream that could begin ++ * this rule. ++ * ++ * For instance if you call the first (topmost) rule in a parser grammar, you will ++ * get the results of a full parse, but calling a rule half way through the grammar will ++ * allow you to pass part of a full token stream to the parser, such as for syntax checking ++ * in editors and so on. ++ * ++ * The parser entry points are called indirectly (by function pointer to function) via ++ * a parser context typedef pDAAPParser, which is returned from a call to DAAPParserNew(). ++ * ++ * The methods in pDAAPParser are as follows: ++ * ++ * - DAAPParser_query_return pDAAPParser->query(pDAAPParser) ++ * - DAAPParser_expr_return pDAAPParser->expr(pDAAPParser) ++ * - DAAPParser_aexpr_return pDAAPParser->aexpr(pDAAPParser) ++ * - DAAPParser_crit_return pDAAPParser->crit(pDAAPParser) ++ * ++ * The return type for any particular rule is of course determined by the source ++ * grammar file. ++ */ ++// [The "BSD licence"] ++// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC ++// http://www.temporal-wave.com ++// http://www.linkedin.com/in/jimidle ++// ++// All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions ++// are met: ++// 1. Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// 2. Redistributions in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// 3. The name of the author may not be used to endorse or promote products ++// derived from this software without specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++#ifndef _DAAPParser_H ++#define _DAAPParser_H ++/* ============================================================================= ++ * Standard antlr3 C runtime definitions ++ */ ++#include ++ ++/* End of standard antlr 3 runtime definitions ++ * ============================================================================= ++ */ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++// Forward declare the context typedef so that we can use it before it is ++// properly defined. Delegators and delegates (from import statements) are ++// interdependent and their context structures contain pointers to each other ++// C only allows such things to be declared if you pre-declare the typedef. ++// ++typedef struct DAAPParser_Ctx_struct DAAPParser, * pDAAPParser; ++ ++ ++ ++#ifdef ANTLR3_WINDOWS ++// Disable: Unreferenced parameter, - Rules with parameters that are not used ++// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) ++// initialized but unused variable - tree rewrite variables declared but not needed ++// Unreferenced local variable - lexer rule declares but does not always use _type ++// potentially unitialized variable used - retval always returned from a rule ++// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns ++// ++// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at ++// and the codegen must generate some of these warnings by necessity, apart from 4100, which is ++// usually generated when a parser rule is given a parameter that it does not use. Mostly though ++// this is a matter of orthogonality hence I disable that one. ++// ++#pragma warning( disable : 4100 ) ++#pragma warning( disable : 4101 ) ++#pragma warning( disable : 4127 ) ++#pragma warning( disable : 4189 ) ++#pragma warning( disable : 4505 ) ++#pragma warning( disable : 4701 ) ++#endif ++typedef struct DAAPParser_query_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ DAAPParser_query_return; ++ ++typedef struct DAAPParser_expr_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ DAAPParser_expr_return; ++ ++typedef struct DAAPParser_aexpr_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ DAAPParser_aexpr_return; ++ ++typedef struct DAAPParser_crit_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ DAAPParser_crit_return; ++ ++ ++ ++/** Context tracking structure for DAAPParser ++ */ ++struct DAAPParser_Ctx_struct ++{ ++ /** Built in ANTLR3 context tracker contains all the generic elements ++ * required for context tracking. ++ */ ++ pANTLR3_PARSER pParser; ++ ++ ++ DAAPParser_query_return (*query) (struct DAAPParser_Ctx_struct * ctx); ++ DAAPParser_expr_return (*expr) (struct DAAPParser_Ctx_struct * ctx); ++ DAAPParser_aexpr_return (*aexpr) (struct DAAPParser_Ctx_struct * ctx); ++ DAAPParser_crit_return (*crit) (struct DAAPParser_Ctx_struct * ctx); ++ // Delegated rules ++ const char * (*getGrammarFileName)(); ++ void (*free) (struct DAAPParser_Ctx_struct * ctx); ++ /* @headerFile.members() */ ++ pANTLR3_BASE_TREE_ADAPTOR adaptor; ++ pANTLR3_VECTOR_FACTORY vectors; ++ /* End @headerFile.members() */ ++}; ++ ++// Function protoypes for the constructor functions that external translation units ++// such as delegators and delegates may wish to call. ++// ++ANTLR3_API pDAAPParser DAAPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream); ++ANTLR3_API pDAAPParser DAAPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); ++ ++/** Symbolic definitions of all the tokens that the parser will work with. ++ * \{ ++ * ++ * Antlr will define EOF, but we can't use that as it it is too common in ++ * in C header files and that would be confusing. There is no way to filter this out at the moment ++ * so we just undef it here for now. That isn't the value we get back from C recognizers ++ * anyway. We are looking for ANTLR3_TOKEN_EOF. ++ */ ++#ifdef EOF ++#undef EOF ++#endif ++#ifdef Tokens ++#undef Tokens ++#endif ++#define STR 9 ++#define QUOTE 10 ++#define LPAR 7 ++#define NEWLINE 4 ++#define OPOR 5 ++#define RPAR 8 ++#define ESCAPED 11 ++#define OPAND 6 ++#define EOF -1 ++#ifdef EOF ++#undef EOF ++#define EOF ANTLR3_TOKEN_EOF ++#endif ++ ++#ifndef TOKENSOURCE ++#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource ++#endif ++ ++/* End of token definitions for DAAPParser ++ * ============================================================================= ++ */ ++/** \} */ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif ++ ++/* END - Note:Keep extra line feed to satisfy UNIX systems */ +diff --git a/src/pregen/RSP.u b/src/pregen/RSP.u +new file mode 100644 +index 0000000..89256ff +--- /dev/null ++++ b/src/pregen/RSP.u +@@ -0,0 +1,6 @@ ++RSPParser.c : RSP.g ++./RSP.tokens : RSP.g ++RSPParser.h : RSP.g ++RSPLexer.c : RSP.g ++RSPLexer.h : RSP.g ++ANTLR_PRODUCTS += RSPParser.c ./RSP.tokens RSPParser.h RSPLexer.c RSPLexer.h +\ No newline at end of file +diff --git a/src/pregen/RSP2SQL.c b/src/pregen/RSP2SQL.c +new file mode 100644 +index 0000000..b5c9550 +--- /dev/null ++++ b/src/pregen/RSP2SQL.c +@@ -0,0 +1,2546 @@ ++/** \file ++ * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3 ++ * ++ * - From the grammar source file : RSP2SQL.g ++ * - On : 2014-09-30 21:42:42 ++ * - for the tree parser : RSP2SQLTreeParser * ++ * Editing it, at least manually, is not wise. ++ * ++ * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. ++ * ++ * ++*/ ++// [The "BSD licence"] ++// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC ++// http://www.temporal-wave.com ++// http://www.linkedin.com/in/jimidle ++// ++// All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions ++// are met: ++// 1. Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// 2. Redistributions in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// 3. The name of the author may not be used to endorse or promote products ++// derived from this software without specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++ ++/* ============================================================================= ++ * This is what the grammar programmer asked us to put at the top of every file. ++ */ ++ ++ /* Needs #define _GNU_SOURCE for strptime() */ ++ ++ #include ++ #include ++ #include ++ #include ++ ++ #include "logger.h" ++ #include "db.h" ++ #include "misc.h" ++ #include "rsp_query.h" ++ ++/* End of Header action. ++ * ============================================================================= ++ */ ++/* ----------------------------------------- ++ * Include the ANTLR3 generated header file. ++ */ ++#include "RSP2SQL.h" ++/* ----------------------------------------- */ ++ ++ ++ ++ ++ ++/* MACROS that hide the C interface implementations from the ++ * generated code, which makes it a little more understandable to the human eye. ++ * I am very much against using C pre-processor macros for function calls and bits ++ * of code as you cannot see what is happening when single stepping in debuggers ++ * and so on. The exception (in my book at least) is for generated code, where you are ++ * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() ++ * hides some indirect calls, but is always referring to the input stream. This is ++ * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig ++ * the runtime interfaces without changing the generated code too often, without ++ * confusing the reader of the generated output, who may not wish to know the gory ++ * details of the interface inheritance. ++ */ ++ ++#define CTX ctx ++ ++/* Aids in accessing scopes for grammar programmers ++ */ ++#undef SCOPE_TYPE ++#undef SCOPE_STACK ++#undef SCOPE_TOP ++#define SCOPE_TYPE(scope) pRSP2SQL_##scope##_SCOPE ++#define SCOPE_STACK(scope) pRSP2SQL_##scope##Stack ++#define SCOPE_TOP(scope) ctx->pRSP2SQL_##scope##Top ++#define SCOPE_SIZE(scope) ctx->pRSP2SQL_##scope##Stack_limit ++#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) ++ ++/* Macros for accessing things in the parser ++ */ ++ ++#undef PARSER ++#undef RECOGNIZER ++#undef HAVEPARSEDRULE ++#undef INPUT ++#undef STRSTREAM ++#undef HASEXCEPTION ++#undef EXCEPTION ++#undef MATCHT ++#undef MATCHANYT ++#undef FOLLOWSTACK ++#undef FOLLOWPUSH ++#undef FOLLOWPOP ++#undef PRECOVER ++#undef PREPORTERROR ++#undef LA ++#undef LT ++#undef CONSTRUCTEX ++#undef CONSUME ++#undef MARK ++#undef REWIND ++#undef REWINDLAST ++#undef PERRORRECOVERY ++#undef HASFAILED ++#undef FAILEDFLAG ++#undef RECOVERFROMMISMATCHEDSET ++#undef RECOVERFROMMISMATCHEDELEMENT ++#undef BACKTRACKING ++#undef ADAPTOR ++#undef RULEMEMO ++#undef SEEK ++#undef INDEX ++#undef DBG ++ ++#define PARSER ctx->pTreeParser ++#define RECOGNIZER PARSER->rec ++#define PSRSTATE RECOGNIZER->state ++#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) ++#define INPUT PARSER->ctnstream ++#define ISTREAM INPUT->tnstream->istream ++#define STRSTREAM INPUT->tnstream ++#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE) ++#define EXCEPTION PSRSTATE->exception ++#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs) ++#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER) ++#define FOLLOWSTACK PSRSTATE->following ++#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL) ++#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK) ++#define PRECOVER() RECOGNIZER->recover(RECOGNIZER) ++#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER) ++#define LA(n) ISTREAM->_LA(ISTREAM, n) ++#define LT(n) INPUT->tnstream->_LT(INPUT->tnstream, n) ++#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) ++#define CONSUME() ISTREAM->consume(ISTREAM) ++#define MARK() ISTREAM->mark(ISTREAM) ++#define REWIND(m) ISTREAM->rewind(ISTREAM, m) ++#define REWINDLAST() ISTREAM->rewindLast(ISTREAM) ++#define PERRORRECOVERY PSRSTATE->errorRecovery ++#define FAILEDFLAG PSRSTATE->failed ++#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE) ++#define BACKTRACKING PSRSTATE->backtracking ++#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s) ++#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s) ++#define ADAPTOR INPUT->adaptor ++#define RULEMEMO PSRSTATE->ruleMemo ++#define SEEK(n) ISTREAM->seek(ISTREAM, n) ++#define INDEX() ISTREAM->index(ISTREAM) ++#define DBG RECOGNIZER->debugger ++ ++ ++#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt ++ ++/* The 4 tokens defined below may well clash with your own #defines or token types. If so ++ * then for the present you must use different names for your defines as these are hard coded ++ * in the code generator. It would be better not to use such names internally, and maybe ++ * we can change this in a forthcoming release. I deliberately do not #undef these ++ * here as this will at least give you a redefined error somewhere if they clash. ++ */ ++#define UP ANTLR3_TOKEN_UP ++#define DOWN ANTLR3_TOKEN_DOWN ++#define EOR ANTLR3_TOKEN_EOR ++#define INVALID ANTLR3_TOKEN_INVALID ++ ++ ++/* ============================================================================= ++ * Functions to create and destroy scopes. First come the rule scopes, followed ++ * by the global declared scopes. ++ */ ++ ++ ++ ++/* ============================================================================= */ ++ ++/* ============================================================================= ++ * Start of recognizer ++ */ ++ ++ ++ ++/** \brief Table of all token names in symbolic order, mainly used for ++ * error reporting. ++ */ ++pANTLR3_UINT8 RSP2SQLTokenNames[30+4] ++ = { ++ (pANTLR3_UINT8) "", /* String to print to indicate an invalid token */ ++ (pANTLR3_UINT8) "", ++ (pANTLR3_UINT8) "", ++ (pANTLR3_UINT8) "", ++ (pANTLR3_UINT8) "NEWLINE", ++ (pANTLR3_UINT8) "OR", ++ (pANTLR3_UINT8) "AND", ++ (pANTLR3_UINT8) "LPAR", ++ (pANTLR3_UINT8) "RPAR", ++ (pANTLR3_UINT8) "FIELD", ++ (pANTLR3_UINT8) "STR", ++ (pANTLR3_UINT8) "NOT", ++ (pANTLR3_UINT8) "EQUAL", ++ (pANTLR3_UINT8) "INCLUDES", ++ (pANTLR3_UINT8) "STARTSW", ++ (pANTLR3_UINT8) "ENDSW", ++ (pANTLR3_UINT8) "INT", ++ (pANTLR3_UINT8) "LESS", ++ (pANTLR3_UINT8) "GREATER", ++ (pANTLR3_UINT8) "LTE", ++ (pANTLR3_UINT8) "GTE", ++ (pANTLR3_UINT8) "BEFORE", ++ (pANTLR3_UINT8) "AFTER", ++ (pANTLR3_UINT8) "DATE", ++ (pANTLR3_UINT8) "TODAY", ++ (pANTLR3_UINT8) "DAY", ++ (pANTLR3_UINT8) "WEEK", ++ (pANTLR3_UINT8) "MONTH", ++ (pANTLR3_UINT8) "YEAR", ++ (pANTLR3_UINT8) "QUOTE", ++ (pANTLR3_UINT8) "WS", ++ (pANTLR3_UINT8) "DIGIT19", ++ (pANTLR3_UINT8) "DIGIT09", ++ (pANTLR3_UINT8) "ESCAPED" ++ }; ++ ++ ++ ++// Forward declare the locally static matching functions we have generated. ++// ++static pANTLR3_STRING query (pRSP2SQL ctx); ++static RSP2SQL_expr_return expr (pRSP2SQL ctx); ++static RSP2SQL_strcrit_return strcrit (pRSP2SQL ctx); ++static pANTLR3_COMMON_TOKEN strop (pRSP2SQL ctx); ++static RSP2SQL_intcrit_return intcrit (pRSP2SQL ctx); ++static pANTLR3_COMMON_TOKEN intop (pRSP2SQL ctx); ++static RSP2SQL_datecrit_return datecrit (pRSP2SQL ctx); ++static pANTLR3_COMMON_TOKEN dateop (pRSP2SQL ctx); ++static RSP2SQL_datespec_return datespec (pRSP2SQL ctx); ++static RSP2SQL_dateref_return dateref (pRSP2SQL ctx); ++static RSP2SQL_dateintval_return dateintval (pRSP2SQL ctx); ++static void RSP2SQLFree(pRSP2SQL ctx); ++/* For use in tree output where we are accumulating rule labels via label += ruleRef ++ * we need a function that knows how to free a return scope when the list is destroyed. ++ * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro. ++ */ ++static void ANTLR3_CDECL freeScope(void * scope) ++{ ++ ANTLR3_FREE(scope); ++} ++ ++/** \brief Name of the grammar file that generated this code ++ */ ++static const char fileName[] = "RSP2SQL.g"; ++ ++/** \brief Return the name of the grammar file that generated this code. ++ */ ++static const char * getGrammarFileName() ++{ ++ return fileName; ++} ++/** \brief Create a new RSP2SQL parser and return a context for it. ++ * ++ * \param[in] instream Pointer to an input stream interface. ++ * ++ * \return Pointer to new parser context upon success. ++ */ ++ANTLR3_API pRSP2SQL ++RSP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream) ++{ ++ // See if we can create a new parser with the standard constructor ++ // ++ return RSP2SQLNewSSD(instream, NULL); ++} ++ ++/** \brief Create a new RSP2SQL parser and return a context for it. ++ * ++ * \param[in] instream Pointer to an input stream interface. ++ * ++ * \return Pointer to new parser context upon success. ++ */ ++ANTLR3_API pRSP2SQL ++RSP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) ++{ ++ pRSP2SQL ctx; /* Context structure we will build and return */ ++ ++ ctx = (pRSP2SQL) ANTLR3_CALLOC(1, sizeof(RSP2SQL)); ++ ++ if (ctx == NULL) ++ { ++ // Failed to allocate memory for parser context ++ // ++ return NULL; ++ } ++ ++ /* ------------------------------------------------------------------- ++ * Memory for basic structure is allocated, now to fill in ++ * the base ANTLR3 structures. We initialize the function pointers ++ * for the standard ANTLR3 parser function set, but upon return ++ * from here, the programmer may set the pointers to provide custom ++ * implementations of each function. ++ * ++ * We don't use the macros defined in RSP2SQL.h here, in order that you can get a sense ++ * of what goes where. ++ */ ++ ++ /* Create a base Tree parser/recognizer, using the supplied tree node stream ++ */ ++ ctx->pTreeParser = antlr3TreeParserNewStream(ANTLR3_SIZE_HINT, instream, state); ++ /* Install the implementation of our RSP2SQL interface ++ */ ++ ctx->query = query; ++ ctx->expr = expr; ++ ctx->strcrit = strcrit; ++ ctx->strop = strop; ++ ctx->intcrit = intcrit; ++ ctx->intop = intop; ++ ctx->datecrit = datecrit; ++ ctx->dateop = dateop; ++ ctx->datespec = datespec; ++ ctx->dateref = dateref; ++ ctx->dateintval = dateintval; ++ ctx->free = RSP2SQLFree; ++ ctx->getGrammarFileName = getGrammarFileName; ++ ++ /* Install the scope pushing methods. ++ */ ++ ++ ++ ++ ++ ++ /* Install the token table ++ */ ++ PSRSTATE->tokenNames = RSP2SQLTokenNames; ++ ++ ++ /* Return the newly built parser to the caller ++ */ ++ return ctx; ++} ++ ++/** Free the parser resources ++ */ ++ static void ++ RSP2SQLFree(pRSP2SQL ctx) ++ { ++ /* Free any scope memory ++ */ ++ ++ ++ // Free this parser ++ // ++ ctx->pTreeParser->free(ctx->pTreeParser); ++ ANTLR3_FREE(ctx); ++ ++ /* Everything is released, so we can return ++ */ ++ return; ++ } ++ ++/** Return token names used by this tree parser ++ * ++ * The returned pointer is used as an index into the token names table (using the token ++ * number as the index). ++ * ++ * \return Pointer to first char * in the table. ++ */ ++static pANTLR3_UINT8 *getTokenNames() ++{ ++ return RSP2SQLTokenNames; ++} ++ ++ ++ #define RSP_TYPE_STRING 0 ++ #define RSP_TYPE_INT 1 ++ #define RSP_TYPE_DATE 2 ++ ++ struct rsp_query_field_map { ++ char *rsp_field; ++ int field_type; ++ /* RSP fields are named after the DB columns - or vice versa */ ++ }; ++ ++ /* gperf static hash, rsp_query.gperf */ ++ #include "rsp_query_hash.c" ++ ++ ++/* Declare the bitsets ++ */ ++ ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query70 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_query70_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_query70 = { FOLLOW_expr_in_query70_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_AND_in_expr95 */ ++static ANTLR3_BITWORD FOLLOW_AND_in_expr95_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; ++static ANTLR3_BITSET_LIST FOLLOW_AND_in_expr95 = { FOLLOW_AND_in_expr95_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr101 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_expr101_bits[] = { ANTLR3_UINT64_LIT(0x00000000007EF860) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr101 = { FOLLOW_expr_in_expr101_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr107 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_expr107_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr107 = { FOLLOW_expr_in_expr107_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_OR_in_expr118 */ ++static ANTLR3_BITWORD FOLLOW_OR_in_expr118_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; ++static ANTLR3_BITSET_LIST FOLLOW_OR_in_expr118 = { FOLLOW_OR_in_expr118_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr124 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_expr124_bits[] = { ANTLR3_UINT64_LIT(0x00000000007EF860) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr124 = { FOLLOW_expr_in_expr124_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr130 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_expr130_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr130 = { FOLLOW_expr_in_expr130_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_strcrit_in_expr144 */ ++static ANTLR3_BITWORD FOLLOW_strcrit_in_expr144_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_strcrit_in_expr144 = { FOLLOW_strcrit_in_expr144_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_expr154 */ ++static ANTLR3_BITWORD FOLLOW_NOT_in_expr154_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; ++static ANTLR3_BITSET_LIST FOLLOW_NOT_in_expr154 = { FOLLOW_NOT_in_expr154_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_strcrit_in_expr160 */ ++static ANTLR3_BITWORD FOLLOW_strcrit_in_expr160_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; ++static ANTLR3_BITSET_LIST FOLLOW_strcrit_in_expr160 = { FOLLOW_strcrit_in_expr160_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_intcrit_in_expr174 */ ++static ANTLR3_BITWORD FOLLOW_intcrit_in_expr174_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_intcrit_in_expr174 = { FOLLOW_intcrit_in_expr174_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_expr184 */ ++static ANTLR3_BITWORD FOLLOW_NOT_in_expr184_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; ++static ANTLR3_BITSET_LIST FOLLOW_NOT_in_expr184 = { FOLLOW_NOT_in_expr184_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_intcrit_in_expr190 */ ++static ANTLR3_BITWORD FOLLOW_intcrit_in_expr190_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; ++static ANTLR3_BITSET_LIST FOLLOW_intcrit_in_expr190 = { FOLLOW_intcrit_in_expr190_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_datecrit_in_expr204 */ ++static ANTLR3_BITWORD FOLLOW_datecrit_in_expr204_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_datecrit_in_expr204 = { FOLLOW_datecrit_in_expr204_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit233 */ ++static ANTLR3_BITWORD FOLLOW_strop_in_strcrit233_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; ++static ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit233 = { FOLLOW_strop_in_strcrit233_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit239 */ ++static ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit239_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000400) }; ++static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit239 = { FOLLOW_FIELD_in_strcrit239_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit245 */ ++static ANTLR3_BITWORD FOLLOW_STR_in_strcrit245_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; ++static ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit245 = { FOLLOW_STR_in_strcrit245_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_EQUAL_in_strop274 */ ++static ANTLR3_BITWORD FOLLOW_EQUAL_in_strop274_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_EQUAL_in_strop274 = { FOLLOW_EQUAL_in_strop274_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_INCLUDES_in_strop287 */ ++static ANTLR3_BITWORD FOLLOW_INCLUDES_in_strop287_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_INCLUDES_in_strop287 = { FOLLOW_INCLUDES_in_strop287_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_STARTSW_in_strop300 */ ++static ANTLR3_BITWORD FOLLOW_STARTSW_in_strop300_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_STARTSW_in_strop300 = { FOLLOW_STARTSW_in_strop300_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_ENDSW_in_strop313 */ ++static ANTLR3_BITWORD FOLLOW_ENDSW_in_strop313_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_ENDSW_in_strop313 = { FOLLOW_ENDSW_in_strop313_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit342 */ ++static ANTLR3_BITWORD FOLLOW_intop_in_intcrit342_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; ++static ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit342 = { FOLLOW_intop_in_intcrit342_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit348 */ ++static ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit348_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; ++static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit348 = { FOLLOW_FIELD_in_intcrit348_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit354 */ ++static ANTLR3_BITWORD FOLLOW_INT_in_intcrit354_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; ++static ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit354 = { FOLLOW_INT_in_intcrit354_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_EQUAL_in_intop383 */ ++static ANTLR3_BITWORD FOLLOW_EQUAL_in_intop383_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_EQUAL_in_intop383 = { FOLLOW_EQUAL_in_intop383_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_LESS_in_intop396 */ ++static ANTLR3_BITWORD FOLLOW_LESS_in_intop396_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_LESS_in_intop396 = { FOLLOW_LESS_in_intop396_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_GREATER_in_intop409 */ ++static ANTLR3_BITWORD FOLLOW_GREATER_in_intop409_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_GREATER_in_intop409 = { FOLLOW_GREATER_in_intop409_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_LTE_in_intop422 */ ++static ANTLR3_BITWORD FOLLOW_LTE_in_intop422_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_LTE_in_intop422 = { FOLLOW_LTE_in_intop422_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_GTE_in_intop435 */ ++static ANTLR3_BITWORD FOLLOW_GTE_in_intop435_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_GTE_in_intop435 = { FOLLOW_GTE_in_intop435_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datecrit464 */ ++static ANTLR3_BITWORD FOLLOW_dateop_in_datecrit464_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; ++static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datecrit464 = { FOLLOW_dateop_in_datecrit464_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_datecrit470 */ ++static ANTLR3_BITWORD FOLLOW_FIELD_in_datecrit470_bits[] = { ANTLR3_UINT64_LIT(0x0000000001FEF860) }; ++static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_datecrit470 = { FOLLOW_FIELD_in_datecrit470_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_datespec_in_datecrit476 */ ++static ANTLR3_BITWORD FOLLOW_datespec_in_datecrit476_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; ++static ANTLR3_BITSET_LIST FOLLOW_datespec_in_datecrit476 = { FOLLOW_datespec_in_datecrit476_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_BEFORE_in_dateop505 */ ++static ANTLR3_BITWORD FOLLOW_BEFORE_in_dateop505_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_BEFORE_in_dateop505 = { FOLLOW_BEFORE_in_dateop505_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_AFTER_in_dateop518 */ ++static ANTLR3_BITWORD FOLLOW_AFTER_in_dateop518_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_AFTER_in_dateop518 = { FOLLOW_AFTER_in_dateop518_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec546 */ ++static ANTLR3_BITWORD FOLLOW_dateref_in_datespec546_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec546 = { FOLLOW_dateref_in_datespec546_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datespec560 */ ++static ANTLR3_BITWORD FOLLOW_dateop_in_datespec560_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; ++static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datespec560 = { FOLLOW_dateop_in_datespec560_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec566 */ ++static ANTLR3_BITWORD FOLLOW_dateref_in_datespec566_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; ++static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec566 = { FOLLOW_dateref_in_datespec566_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_datespec572 */ ++static ANTLR3_BITWORD FOLLOW_INT_in_datespec572_bits[] = { ANTLR3_UINT64_LIT(0x000000001E000000) }; ++static ANTLR3_BITSET_LIST FOLLOW_INT_in_datespec572 = { FOLLOW_INT_in_datespec572_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateintval_in_datespec578 */ ++static ANTLR3_BITWORD FOLLOW_dateintval_in_datespec578_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; ++static ANTLR3_BITSET_LIST FOLLOW_dateintval_in_datespec578 = { FOLLOW_dateintval_in_datespec578_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATE_in_dateref607 */ ++static ANTLR3_BITWORD FOLLOW_DATE_in_dateref607_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_DATE_in_dateref607 = { FOLLOW_DATE_in_dateref607_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_TODAY_in_dateref616 */ ++static ANTLR3_BITWORD FOLLOW_TODAY_in_dateref616_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_TODAY_in_dateref616 = { FOLLOW_TODAY_in_dateref616_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_DAY_in_dateintval640 */ ++static ANTLR3_BITWORD FOLLOW_DAY_in_dateintval640_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_DAY_in_dateintval640 = { FOLLOW_DAY_in_dateintval640_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_WEEK_in_dateintval649 */ ++static ANTLR3_BITWORD FOLLOW_WEEK_in_dateintval649_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_WEEK_in_dateintval649 = { FOLLOW_WEEK_in_dateintval649_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_MONTH_in_dateintval658 */ ++static ANTLR3_BITWORD FOLLOW_MONTH_in_dateintval658_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_MONTH_in_dateintval658 = { FOLLOW_MONTH_in_dateintval658_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_YEAR_in_dateintval667 */ ++static ANTLR3_BITWORD FOLLOW_YEAR_in_dateintval667_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_YEAR_in_dateintval667 = { FOLLOW_YEAR_in_dateintval667_bits, 1 }; ++ ++ ++ ++ ++/* ============================================== ++ * Parsing rules ++ */ ++/** ++ * $ANTLR start query ++ * RSP2SQL.g:56:1: query returns [ pANTLR3_STRING result ] : e= expr ; ++ */ ++static pANTLR3_STRING ++query(pRSP2SQL ctx) ++{ ++ pANTLR3_STRING result = NULL; ++ ++ RSP2SQL_expr_return e; ++ #undef RETURN_TYPE_e ++ #define RETURN_TYPE_e RSP2SQL_expr_return ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ result= NULL; ++ { ++ // RSP2SQL.g:58:2: (e= expr ) ++ // RSP2SQL.g:58:4: e= expr ++ { ++ FOLLOWPUSH(FOLLOW_expr_in_query70); ++ e=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto rulequeryEx; ++ } ++ ++ { ++ ++ if (!e.valid) ++ { ++ result= NULL; ++ } ++ else ++ { ++ result= e.result->factory->newRaw(e.result->factory); ++ result->append8(result, "("); ++ result->appendS(result, e.result); ++ result->append8(result, ")"); ++ } ++ ++ } ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto rulequeryEx; /* Prevent compiler warnings */ ++ rulequeryEx: ; ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ } ++ ++ ++ return result; ++} ++/* $ANTLR end query */ ++ ++/** ++ * $ANTLR start expr ++ * RSP2SQL.g:74:1: expr returns [ pANTLR3_STRING result, int valid ] : ( ^( AND a= expr b= expr ) | ^( OR a= expr b= expr ) | c= strcrit | ^( NOT c= strcrit ) | i= intcrit | ^( NOT i= intcrit ) | d= datecrit ); ++ */ ++static RSP2SQL_expr_return ++expr(pRSP2SQL ctx) ++{ ++ RSP2SQL_expr_return retval; ++ ++ RSP2SQL_expr_return a; ++ #undef RETURN_TYPE_a ++ #define RETURN_TYPE_a RSP2SQL_expr_return ++ ++ RSP2SQL_expr_return b; ++ #undef RETURN_TYPE_b ++ #define RETURN_TYPE_b RSP2SQL_expr_return ++ ++ RSP2SQL_strcrit_return c; ++ #undef RETURN_TYPE_c ++ #define RETURN_TYPE_c RSP2SQL_strcrit_return ++ ++ RSP2SQL_intcrit_return i; ++ #undef RETURN_TYPE_i ++ #define RETURN_TYPE_i RSP2SQL_intcrit_return ++ ++ RSP2SQL_datecrit_return d; ++ #undef RETURN_TYPE_d ++ #define RETURN_TYPE_d RSP2SQL_datecrit_return ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ retval.result= NULL; retval.valid= 1; ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ { ++ { ++ // RSP2SQL.g:76:2: ( ^( AND a= expr b= expr ) | ^( OR a= expr b= expr ) | c= strcrit | ^( NOT c= strcrit ) | i= intcrit | ^( NOT i= intcrit ) | d= datecrit ) ++ ++ ANTLR3_UINT32 alt1; ++ ++ alt1=7; ++ ++ switch ( LA(1) ) ++ { ++ case AND: ++ { ++ alt1=1; ++ } ++ break; ++ case OR: ++ { ++ alt1=2; ++ } ++ break; ++ case EQUAL: ++ { ++ switch ( LA(2) ) ++ { ++ case DOWN: ++ { ++ switch ( LA(3) ) ++ { ++ case FIELD: ++ { ++ switch ( LA(4) ) ++ { ++ case INT: ++ { ++ alt1=5; ++ } ++ break; ++ case STR: ++ { ++ alt1=3; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 1; ++ EXCEPTION->state = 10; ++ ++ ++ goto ruleexprEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 1; ++ EXCEPTION->state = 8; ++ ++ ++ goto ruleexprEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 1; ++ EXCEPTION->state = 3; ++ ++ ++ goto ruleexprEx; ++ } ++ ++ } ++ break; ++ case INCLUDES: ++ case STARTSW: ++ case ENDSW: ++ { ++ alt1=3; ++ } ++ break; ++ case NOT: ++ { ++ switch ( LA(2) ) ++ { ++ case DOWN: ++ { ++ switch ( LA(3) ) ++ { ++ case EQUAL: ++ { ++ switch ( LA(4) ) ++ { ++ case DOWN: ++ { ++ switch ( LA(5) ) ++ { ++ case FIELD: ++ { ++ switch ( LA(6) ) ++ { ++ case STR: ++ { ++ alt1=4; ++ } ++ break; ++ case INT: ++ { ++ alt1=6; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 1; ++ EXCEPTION->state = 15; ++ ++ ++ goto ruleexprEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 1; ++ EXCEPTION->state = 14; ++ ++ ++ goto ruleexprEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 1; ++ EXCEPTION->state = 11; ++ ++ ++ goto ruleexprEx; ++ } ++ ++ } ++ break; ++ case LESS: ++ case GREATER: ++ case LTE: ++ case GTE: ++ { ++ alt1=6; ++ } ++ break; ++ case INCLUDES: ++ case STARTSW: ++ case ENDSW: ++ { ++ alt1=4; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 1; ++ EXCEPTION->state = 9; ++ ++ ++ goto ruleexprEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 1; ++ EXCEPTION->state = 5; ++ ++ ++ goto ruleexprEx; ++ } ++ ++ } ++ break; ++ case LESS: ++ case GREATER: ++ case LTE: ++ case GTE: ++ { ++ alt1=5; ++ } ++ break; ++ case BEFORE: ++ case AFTER: ++ { ++ alt1=7; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 1; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleexprEx; ++ } ++ ++ switch (alt1) ++ { ++ case 1: ++ // RSP2SQL.g:76:4: ^( AND a= expr b= expr ) ++ { ++ MATCHT(AND, &FOLLOW_AND_in_expr95); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_DOWN, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ FOLLOWPUSH(FOLLOW_expr_in_expr101); ++ a=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ FOLLOWPUSH(FOLLOW_expr_in_expr107); ++ b=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_UP, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ { ++ ++ if (!a.valid || !b.valid) ++ { ++ retval.valid= 0; ++ } ++ else ++ { ++ retval.result= a.result->factory->newRaw(a.result->factory); ++ retval.result->append8(retval.result, "("); ++ retval.result->appendS(retval.result, a.result); ++ retval.result->append8(retval.result, " AND "); ++ retval.result->appendS(retval.result, b.result); ++ retval.result->append8(retval.result, ")"); ++ } ++ ++ } ++ ++ } ++ break; ++ case 2: ++ // RSP2SQL.g:92:4: ^( OR a= expr b= expr ) ++ { ++ MATCHT(OR, &FOLLOW_OR_in_expr118); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_DOWN, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ FOLLOWPUSH(FOLLOW_expr_in_expr124); ++ a=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ FOLLOWPUSH(FOLLOW_expr_in_expr130); ++ b=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_UP, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ { ++ ++ if (!a.valid || !b.valid) ++ { ++ retval.valid= 0; ++ } ++ else ++ { ++ retval.result= a.result->factory->newRaw(a.result->factory); ++ retval.result->append8(retval.result, "("); ++ retval.result->appendS(retval.result, a.result); ++ retval.result->append8(retval.result, " OR "); ++ retval.result->appendS(retval.result, b.result); ++ retval.result->append8(retval.result, ")"); ++ } ++ ++ } ++ ++ } ++ break; ++ case 3: ++ // RSP2SQL.g:108:4: c= strcrit ++ { ++ FOLLOWPUSH(FOLLOW_strcrit_in_expr144); ++ c=strcrit(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ { ++ ++ retval.valid= c.valid; ++ retval.result= c.result; ++ ++ } ++ ++ } ++ break; ++ case 4: ++ // RSP2SQL.g:113:4: ^( NOT c= strcrit ) ++ { ++ MATCHT(NOT, &FOLLOW_NOT_in_expr154); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_DOWN, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ FOLLOWPUSH(FOLLOW_strcrit_in_expr160); ++ c=strcrit(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_UP, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ { ++ ++ if (!c.valid) ++ { ++ retval.valid= 0; ++ } ++ else ++ { ++ retval.result= c.result->factory->newRaw(c.result->factory); ++ retval.result->append8(retval.result, "(NOT "); ++ retval.result->appendS(retval.result, c.result); ++ retval.result->append8(retval.result, ")"); ++ } ++ ++ } ++ ++ } ++ break; ++ case 5: ++ // RSP2SQL.g:127:4: i= intcrit ++ { ++ FOLLOWPUSH(FOLLOW_intcrit_in_expr174); ++ i=intcrit(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ { ++ ++ retval.valid= i.valid; ++ retval.result= i.result; ++ ++ } ++ ++ } ++ break; ++ case 6: ++ // RSP2SQL.g:132:4: ^( NOT i= intcrit ) ++ { ++ MATCHT(NOT, &FOLLOW_NOT_in_expr184); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_DOWN, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ FOLLOWPUSH(FOLLOW_intcrit_in_expr190); ++ i=intcrit(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_UP, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ { ++ ++ if (!i.valid) ++ { ++ retval.valid= 0; ++ } ++ else ++ { ++ retval.result= i.result->factory->newRaw(i.result->factory); ++ retval.result->append8(retval.result, "(NOT "); ++ retval.result->appendS(retval.result, i.result); ++ retval.result->append8(retval.result, ")"); ++ } ++ ++ } ++ ++ } ++ break; ++ case 7: ++ // RSP2SQL.g:146:4: d= datecrit ++ { ++ FOLLOWPUSH(FOLLOW_datecrit_in_expr204); ++ d=datecrit(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ { ++ ++ retval.valid= d.valid; ++ retval.result= d.result; ++ ++ } ++ ++ } ++ break; ++ ++ } ++ } ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleexprEx; /* Prevent compiler warnings */ ++ ruleexprEx: ; ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end expr */ ++ ++/** ++ * $ANTLR start strcrit ++ * RSP2SQL.g:153:1: strcrit returns [ pANTLR3_STRING result, int valid ] : ^(o= strop f= FIELD s= STR ) ; ++ */ ++static RSP2SQL_strcrit_return ++strcrit(pRSP2SQL ctx) ++{ ++ RSP2SQL_strcrit_return retval; ++ ++ pANTLR3_BASE_TREE f; ++ pANTLR3_BASE_TREE s; ++ pANTLR3_COMMON_TOKEN o; ++ #undef RETURN_TYPE_o ++ #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ retval.result= NULL; retval.valid= 1; ++ f = NULL; ++ s = NULL; ++ o = NULL; ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ { ++ // RSP2SQL.g:155:2: ( ^(o= strop f= FIELD s= STR ) ) ++ // RSP2SQL.g:155:4: ^(o= strop f= FIELD s= STR ) ++ { ++ FOLLOWPUSH(FOLLOW_strop_in_strcrit233); ++ o=strop(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto rulestrcritEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_DOWN, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto rulestrcritEx; ++ } ++ ++ f = (pANTLR3_BASE_TREE) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit239); ++ if (HASEXCEPTION()) ++ { ++ goto rulestrcritEx; ++ } ++ ++ s = (pANTLR3_BASE_TREE) MATCHT(STR, &FOLLOW_STR_in_strcrit245); ++ if (HASEXCEPTION()) ++ { ++ goto rulestrcritEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_UP, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto rulestrcritEx; ++ } ++ ++ { ++ ++ char *op; ++ const struct rsp_query_field_map *rqfp; ++ pANTLR3_STRING field; ++ char *escaped; ++ ANTLR3_UINT32 optok; ++ ++ escaped = NULL; ++ ++ op = NULL; ++ optok = o->getType(o); ++ switch (optok) ++ { ++ case EQUAL: ++ op = " = "; ++ break; ++ ++ case INCLUDES: ++ case STARTSW: ++ case ENDSW: ++ op = " LIKE "; ++ break; ++ } ++ ++ field = f->getText(f); ++ ++ /* Field lookup */ ++ rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars)); ++ if (!rqfp) ++ { ++ DPRINTF(E_LOG, L_RSP, "Field '%s' is not a valid field in queries\n", field->chars); ++ retval.valid= 0; ++ goto strcrit_valid_0; /* ABORT */ ++ } ++ ++ /* Check field type */ ++ if (rqfp->field_type != RSP_TYPE_STRING) ++ { ++ DPRINTF(E_LOG, L_RSP, "Field '%s' is not a string field\n", field->chars); ++ retval.valid= 0; ++ goto strcrit_valid_0; /* ABORT */ ++ } ++ ++ escaped = db_escape_string((char *)s->getText(s)->chars); ++ if (!escaped) ++ { ++ DPRINTF(E_LOG, L_RSP, "Could not escape value\n"); ++ retval.valid= 0; ++ goto strcrit_valid_0; /* ABORT */ ++ } ++ ++ retval.result= field->factory->newRaw(field->factory); ++ retval.result->append8(retval.result, "f."); ++ retval.result->appendS(retval.result, field); ++ retval.result->append8(retval.result, op); ++ retval.result->append8(retval.result, "'"); ++ if ((optok == INCLUDES) || (optok == STARTSW)) ++ retval.result->append8(retval.result, "%"); ++ ++ retval.result->append8(retval.result, escaped); ++ ++ if ((optok == INCLUDES) || (optok == ENDSW)) ++ retval.result->append8(retval.result, "%"); ++ retval.result->append8(retval.result, "'"); ++ ++ strcrit_valid_0: ++ ; ++ ++ if (escaped) ++ free(escaped); ++ ++ } ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto rulestrcritEx; /* Prevent compiler warnings */ ++ rulestrcritEx: ; ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end strcrit */ ++ ++/** ++ * $ANTLR start strop ++ * RSP2SQL.g:229:1: strop returns [ pANTLR3_COMMON_TOKEN op ] : (n= EQUAL | n= INCLUDES | n= STARTSW | n= ENDSW ); ++ */ ++static pANTLR3_COMMON_TOKEN ++strop(pRSP2SQL ctx) ++{ ++ pANTLR3_COMMON_TOKEN op = NULL; ++ ++ pANTLR3_BASE_TREE n; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ op= NULL; ++ n = NULL; ++ ++ { ++ { ++ // RSP2SQL.g:231:2: (n= EQUAL | n= INCLUDES | n= STARTSW | n= ENDSW ) ++ ++ ANTLR3_UINT32 alt2; ++ ++ alt2=4; ++ ++ switch ( LA(1) ) ++ { ++ case EQUAL: ++ { ++ alt2=1; ++ } ++ break; ++ case INCLUDES: ++ { ++ alt2=2; ++ } ++ break; ++ case STARTSW: ++ { ++ alt2=3; ++ } ++ break; ++ case ENDSW: ++ { ++ alt2=4; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 2; ++ EXCEPTION->state = 0; ++ ++ ++ goto rulestropEx; ++ } ++ ++ switch (alt2) ++ { ++ case 1: ++ // RSP2SQL.g:231:4: n= EQUAL ++ { ++ n = (pANTLR3_BASE_TREE) MATCHT(EQUAL, &FOLLOW_EQUAL_in_strop274); ++ if (HASEXCEPTION()) ++ { ++ goto rulestropEx; ++ } ++ ++ { ++ op= n->getToken(n); ++ } ++ ++ } ++ break; ++ case 2: ++ // RSP2SQL.g:233:4: n= INCLUDES ++ { ++ n = (pANTLR3_BASE_TREE) MATCHT(INCLUDES, &FOLLOW_INCLUDES_in_strop287); ++ if (HASEXCEPTION()) ++ { ++ goto rulestropEx; ++ } ++ ++ { ++ op= n->getToken(n); ++ } ++ ++ } ++ break; ++ case 3: ++ // RSP2SQL.g:235:4: n= STARTSW ++ { ++ n = (pANTLR3_BASE_TREE) MATCHT(STARTSW, &FOLLOW_STARTSW_in_strop300); ++ if (HASEXCEPTION()) ++ { ++ goto rulestropEx; ++ } ++ ++ { ++ op= n->getToken(n); ++ } ++ ++ } ++ break; ++ case 4: ++ // RSP2SQL.g:237:4: n= ENDSW ++ { ++ n = (pANTLR3_BASE_TREE) MATCHT(ENDSW, &FOLLOW_ENDSW_in_strop313); ++ if (HASEXCEPTION()) ++ { ++ goto rulestropEx; ++ } ++ ++ { ++ op= n->getToken(n); ++ } ++ ++ } ++ break; ++ ++ } ++ } ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto rulestropEx; /* Prevent compiler warnings */ ++ rulestropEx: ; ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ } ++ ++ ++ return op; ++} ++/* $ANTLR end strop */ ++ ++/** ++ * $ANTLR start intcrit ++ * RSP2SQL.g:241:1: intcrit returns [ pANTLR3_STRING result, int valid ] : ^(o= intop f= FIELD i= INT ) ; ++ */ ++static RSP2SQL_intcrit_return ++intcrit(pRSP2SQL ctx) ++{ ++ RSP2SQL_intcrit_return retval; ++ ++ pANTLR3_BASE_TREE f; ++ pANTLR3_BASE_TREE i; ++ pANTLR3_COMMON_TOKEN o; ++ #undef RETURN_TYPE_o ++ #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ retval.result= NULL; retval.valid= 1; ++ f = NULL; ++ i = NULL; ++ o = NULL; ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ { ++ // RSP2SQL.g:243:2: ( ^(o= intop f= FIELD i= INT ) ) ++ // RSP2SQL.g:243:4: ^(o= intop f= FIELD i= INT ) ++ { ++ FOLLOWPUSH(FOLLOW_intop_in_intcrit342); ++ o=intop(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintcritEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_DOWN, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintcritEx; ++ } ++ ++ f = (pANTLR3_BASE_TREE) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit348); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintcritEx; ++ } ++ ++ i = (pANTLR3_BASE_TREE) MATCHT(INT, &FOLLOW_INT_in_intcrit354); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintcritEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_UP, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintcritEx; ++ } ++ ++ { ++ ++ char *op; ++ const struct rsp_query_field_map *rqfp; ++ pANTLR3_STRING field; ++ ++ op = NULL; ++ switch (o->getType(o)) ++ { ++ case EQUAL: ++ op = " = "; ++ break; ++ ++ case LESS: ++ op = " < "; ++ break; ++ ++ case GREATER: ++ op = " > "; ++ break; ++ ++ case LTE: ++ op = " <= "; ++ break; ++ ++ case GTE: ++ op = " >= "; ++ break; ++ } ++ ++ field = f->getText(f); ++ ++ /* Field lookup */ ++ rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars)); ++ if (!rqfp) ++ { ++ DPRINTF(E_LOG, L_RSP, "Field '%s' is not a valid field in queries\n", field->chars); ++ retval.valid= 0; ++ goto intcrit_valid_0; /* ABORT */ ++ } ++ ++ /* Check field type */ ++ if (rqfp->field_type != RSP_TYPE_INT) ++ { ++ DPRINTF(E_LOG, L_RSP, "Field '%s' is not an integer field\n", field->chars); ++ retval.valid= 0; ++ goto intcrit_valid_0; /* ABORT */ ++ } ++ ++ retval.result= field->factory->newRaw(field->factory); ++ retval.result->append8(retval.result, "f."); ++ retval.result->appendS(retval.result, field); ++ retval.result->append8(retval.result, op); ++ retval.result->appendS(retval.result, i->getText(i)); ++ ++ intcrit_valid_0: ++ ; ++ ++ } ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleintcritEx; /* Prevent compiler warnings */ ++ ruleintcritEx: ; ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end intcrit */ ++ ++/** ++ * $ANTLR start intop ++ * RSP2SQL.g:303:1: intop returns [ pANTLR3_COMMON_TOKEN op ] : (n= EQUAL | n= LESS | n= GREATER | n= LTE | n= GTE ); ++ */ ++static pANTLR3_COMMON_TOKEN ++intop(pRSP2SQL ctx) ++{ ++ pANTLR3_COMMON_TOKEN op = NULL; ++ ++ pANTLR3_BASE_TREE n; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ op= NULL; ++ n = NULL; ++ ++ { ++ { ++ // RSP2SQL.g:305:2: (n= EQUAL | n= LESS | n= GREATER | n= LTE | n= GTE ) ++ ++ ANTLR3_UINT32 alt3; ++ ++ alt3=5; ++ ++ switch ( LA(1) ) ++ { ++ case EQUAL: ++ { ++ alt3=1; ++ } ++ break; ++ case LESS: ++ { ++ alt3=2; ++ } ++ break; ++ case GREATER: ++ { ++ alt3=3; ++ } ++ break; ++ case LTE: ++ { ++ alt3=4; ++ } ++ break; ++ case GTE: ++ { ++ alt3=5; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 3; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleintopEx; ++ } ++ ++ switch (alt3) ++ { ++ case 1: ++ // RSP2SQL.g:305:4: n= EQUAL ++ { ++ n = (pANTLR3_BASE_TREE) MATCHT(EQUAL, &FOLLOW_EQUAL_in_intop383); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintopEx; ++ } ++ ++ { ++ op= n->getToken(n); ++ } ++ ++ } ++ break; ++ case 2: ++ // RSP2SQL.g:307:4: n= LESS ++ { ++ n = (pANTLR3_BASE_TREE) MATCHT(LESS, &FOLLOW_LESS_in_intop396); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintopEx; ++ } ++ ++ { ++ op= n->getToken(n); ++ } ++ ++ } ++ break; ++ case 3: ++ // RSP2SQL.g:309:4: n= GREATER ++ { ++ n = (pANTLR3_BASE_TREE) MATCHT(GREATER, &FOLLOW_GREATER_in_intop409); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintopEx; ++ } ++ ++ { ++ op= n->getToken(n); ++ } ++ ++ } ++ break; ++ case 4: ++ // RSP2SQL.g:311:4: n= LTE ++ { ++ n = (pANTLR3_BASE_TREE) MATCHT(LTE, &FOLLOW_LTE_in_intop422); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintopEx; ++ } ++ ++ { ++ op= n->getToken(n); ++ } ++ ++ } ++ break; ++ case 5: ++ // RSP2SQL.g:313:4: n= GTE ++ { ++ n = (pANTLR3_BASE_TREE) MATCHT(GTE, &FOLLOW_GTE_in_intop435); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintopEx; ++ } ++ ++ { ++ op= n->getToken(n); ++ } ++ ++ } ++ break; ++ ++ } ++ } ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleintopEx; /* Prevent compiler warnings */ ++ ruleintopEx: ; ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ } ++ ++ ++ return op; ++} ++/* $ANTLR end intop */ ++ ++/** ++ * $ANTLR start datecrit ++ * RSP2SQL.g:317:1: datecrit returns [ pANTLR3_STRING result, int valid ] : ^(o= dateop f= FIELD d= datespec ) ; ++ */ ++static RSP2SQL_datecrit_return ++datecrit(pRSP2SQL ctx) ++{ ++ RSP2SQL_datecrit_return retval; ++ ++ pANTLR3_BASE_TREE f; ++ pANTLR3_COMMON_TOKEN o; ++ #undef RETURN_TYPE_o ++ #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN ++ ++ RSP2SQL_datespec_return d; ++ #undef RETURN_TYPE_d ++ #define RETURN_TYPE_d RSP2SQL_datespec_return ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ retval.result= NULL; retval.valid= 1; ++ f = NULL; ++ o = NULL; ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ { ++ // RSP2SQL.g:319:2: ( ^(o= dateop f= FIELD d= datespec ) ) ++ // RSP2SQL.g:319:4: ^(o= dateop f= FIELD d= datespec ) ++ { ++ FOLLOWPUSH(FOLLOW_dateop_in_datecrit464); ++ o=dateop(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatecritEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_DOWN, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatecritEx; ++ } ++ ++ f = (pANTLR3_BASE_TREE) MATCHT(FIELD, &FOLLOW_FIELD_in_datecrit470); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatecritEx; ++ } ++ ++ FOLLOWPUSH(FOLLOW_datespec_in_datecrit476); ++ d=datespec(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatecritEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_UP, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatecritEx; ++ } ++ ++ { ++ ++ char *op; ++ const struct rsp_query_field_map *rqfp; ++ pANTLR3_STRING field; ++ char buf[32]; ++ int ret; ++ ++ op = NULL; ++ switch (o->getType(o)) ++ { ++ case BEFORE: ++ op = " < "; ++ break; ++ ++ case AFTER: ++ op = " > "; ++ break; ++ } ++ ++ field = f->getText(f); ++ ++ /* Field lookup */ ++ rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars)); ++ if (!rqfp) ++ { ++ DPRINTF(E_LOG, L_RSP, "Field '%s' is not a valid field in queries\n", field->chars); ++ retval.valid= 0; ++ goto datecrit_valid_0; /* ABORT */ ++ } ++ ++ /* Check field type */ ++ if (rqfp->field_type != RSP_TYPE_DATE) ++ { ++ DPRINTF(E_LOG, L_RSP, "Field '%s' is not a date field\n", field->chars); ++ retval.valid= 0; ++ goto datecrit_valid_0; /* ABORT */ ++ } ++ ++ ret = snprintf(buf, sizeof(buf), "%ld", d.date); ++ if ((ret < 0) || (ret >= sizeof(buf))) ++ { ++ DPRINTF(E_LOG, L_RSP, "Date %ld too large for buffer, oops!\n", d.date); ++ retval.valid= 0; ++ goto datecrit_valid_0; /* ABORT */ ++ } ++ ++ retval.result= field->factory->newRaw(field->factory); ++ retval.result->append8(retval.result, "f."); ++ retval.result->appendS(retval.result, field); ++ retval.result->append8(retval.result, op); ++ retval.result->append8(retval.result, buf); ++ ++ datecrit_valid_0: ++ ; ++ ++ } ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruledatecritEx; /* Prevent compiler warnings */ ++ ruledatecritEx: ; ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end datecrit */ ++ ++/** ++ * $ANTLR start dateop ++ * RSP2SQL.g:377:1: dateop returns [ pANTLR3_COMMON_TOKEN op ] : (n= BEFORE | n= AFTER ); ++ */ ++static pANTLR3_COMMON_TOKEN ++dateop(pRSP2SQL ctx) ++{ ++ pANTLR3_COMMON_TOKEN op = NULL; ++ ++ pANTLR3_BASE_TREE n; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ op= NULL; ++ n = NULL; ++ ++ { ++ { ++ // RSP2SQL.g:379:2: (n= BEFORE | n= AFTER ) ++ ++ ANTLR3_UINT32 alt4; ++ ++ alt4=2; ++ ++ switch ( LA(1) ) ++ { ++ case BEFORE: ++ { ++ alt4=1; ++ } ++ break; ++ case AFTER: ++ { ++ alt4=2; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 4; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruledateopEx; ++ } ++ ++ switch (alt4) ++ { ++ case 1: ++ // RSP2SQL.g:379:4: n= BEFORE ++ { ++ n = (pANTLR3_BASE_TREE) MATCHT(BEFORE, &FOLLOW_BEFORE_in_dateop505); ++ if (HASEXCEPTION()) ++ { ++ goto ruledateopEx; ++ } ++ ++ { ++ op= n->getToken(n); ++ } ++ ++ } ++ break; ++ case 2: ++ // RSP2SQL.g:381:4: n= AFTER ++ { ++ n = (pANTLR3_BASE_TREE) MATCHT(AFTER, &FOLLOW_AFTER_in_dateop518); ++ if (HASEXCEPTION()) ++ { ++ goto ruledateopEx; ++ } ++ ++ { ++ op= n->getToken(n); ++ } ++ ++ } ++ break; ++ ++ } ++ } ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruledateopEx; /* Prevent compiler warnings */ ++ ruledateopEx: ; ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ } ++ ++ ++ return op; ++} ++/* $ANTLR end dateop */ ++ ++/** ++ * $ANTLR start datespec ++ * RSP2SQL.g:385:1: datespec returns [ time_t date, int valid ] : (r= dateref | ^(o= dateop r= dateref m= INT i= dateintval ) ); ++ */ ++static RSP2SQL_datespec_return ++datespec(pRSP2SQL ctx) ++{ ++ RSP2SQL_datespec_return retval; ++ ++ pANTLR3_BASE_TREE m; ++ RSP2SQL_dateref_return r; ++ #undef RETURN_TYPE_r ++ #define RETURN_TYPE_r RSP2SQL_dateref_return ++ ++ pANTLR3_COMMON_TOKEN o; ++ #undef RETURN_TYPE_o ++ #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN ++ ++ RSP2SQL_dateintval_return i; ++ #undef RETURN_TYPE_i ++ #define RETURN_TYPE_i RSP2SQL_dateintval_return ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ retval.date= 0; retval.valid= 1; ++ m = NULL; ++ o = NULL; ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ { ++ { ++ // RSP2SQL.g:387:2: (r= dateref | ^(o= dateop r= dateref m= INT i= dateintval ) ) ++ ++ ANTLR3_UINT32 alt5; ++ ++ alt5=2; ++ ++ switch ( LA(1) ) ++ { ++ case DATE: ++ case TODAY: ++ { ++ alt5=1; ++ } ++ break; ++ case BEFORE: ++ case AFTER: ++ { ++ alt5=2; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 5; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruledatespecEx; ++ } ++ ++ switch (alt5) ++ { ++ case 1: ++ // RSP2SQL.g:387:4: r= dateref ++ { ++ FOLLOWPUSH(FOLLOW_dateref_in_datespec546); ++ r=dateref(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatespecEx; ++ } ++ ++ { ++ ++ if (!r.valid) ++ retval.valid= 0; ++ else ++ retval.date= r.date; ++ ++ } ++ ++ } ++ break; ++ case 2: ++ // RSP2SQL.g:394:4: ^(o= dateop r= dateref m= INT i= dateintval ) ++ { ++ FOLLOWPUSH(FOLLOW_dateop_in_datespec560); ++ o=dateop(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatespecEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_DOWN, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatespecEx; ++ } ++ ++ FOLLOWPUSH(FOLLOW_dateref_in_datespec566); ++ r=dateref(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatespecEx; ++ } ++ ++ m = (pANTLR3_BASE_TREE) MATCHT(INT, &FOLLOW_INT_in_datespec572); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatespecEx; ++ } ++ ++ FOLLOWPUSH(FOLLOW_dateintval_in_datespec578); ++ i=dateintval(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatespecEx; ++ } ++ ++ ++ MATCHT(ANTLR3_TOKEN_UP, NULL); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatespecEx; ++ } ++ ++ { ++ ++ int32_t val; ++ int ret; ++ ++ if (!r.valid || !i.valid) ++ { ++ retval.valid= 0; ++ goto datespec_valid_0; /* ABORT */ ++ } ++ ++ ret = safe_atoi32((char *)m->getText(m)->chars, &val); ++ if (ret < 0) ++ { ++ DPRINTF(E_LOG, L_RSP, "Could not convert '%s' to integer\n", (char *)m->getText(m)); ++ retval.valid= 0; ++ goto datespec_valid_0; /* ABORT */ ++ } ++ ++ switch (o->getType(o)) ++ { ++ case BEFORE: ++ retval.date= r.date - (val * i.period); ++ break; ++ ++ case AFTER: ++ retval.date= r.date + (val * i.period); ++ break; ++ } ++ ++ datespec_valid_0: ++ ; ++ ++ } ++ ++ } ++ break; ++ ++ } ++ } ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruledatespecEx; /* Prevent compiler warnings */ ++ ruledatespecEx: ; ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end datespec */ ++ ++/** ++ * $ANTLR start dateref ++ * RSP2SQL.g:429:1: dateref returns [ time_t date, int valid ] : (n= DATE | TODAY ); ++ */ ++static RSP2SQL_dateref_return ++dateref(pRSP2SQL ctx) ++{ ++ RSP2SQL_dateref_return retval; ++ ++ pANTLR3_BASE_TREE n; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ retval.date= 0; retval.valid= 1; ++ n = NULL; ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ { ++ { ++ // RSP2SQL.g:431:2: (n= DATE | TODAY ) ++ ++ ANTLR3_UINT32 alt6; ++ ++ alt6=2; ++ ++ switch ( LA(1) ) ++ { ++ case DATE: ++ { ++ alt6=1; ++ } ++ break; ++ case TODAY: ++ { ++ alt6=2; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 6; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruledaterefEx; ++ } ++ ++ switch (alt6) ++ { ++ case 1: ++ // RSP2SQL.g:431:4: n= DATE ++ { ++ n = (pANTLR3_BASE_TREE) MATCHT(DATE, &FOLLOW_DATE_in_dateref607); ++ if (HASEXCEPTION()) ++ { ++ goto ruledaterefEx; ++ } ++ ++ { ++ ++ struct tm tm; ++ char *ret; ++ ++ ret = strptime((char *)n->getText(n), "%Y-%m-%d", &tm); ++ if (!ret) ++ { ++ DPRINTF(E_LOG, L_RSP, "Date '%s' could not be interpreted\n", (char *)n->getText(n)); ++ retval.valid= 0; ++ goto dateref_valid_0; /* ABORT */ ++ } ++ else ++ { ++ if (*ret != '\0') ++ DPRINTF(E_LOG, L_RSP, "Garbage at end of date '%s' ?!\n", (char *)n->getText(n)); ++ ++ retval.date= mktime(&tm); ++ if (retval.date == (time_t) -1) ++ { ++ DPRINTF(E_LOG, L_RSP, "Date '%s' could not be converted to an epoch\n", (char *)n->getText(n)); ++ retval.valid= 0; ++ goto dateref_valid_0; /* ABORT */ ++ } ++ } ++ ++ dateref_valid_0: ++ ; ++ ++ } ++ ++ } ++ break; ++ case 2: ++ // RSP2SQL.g:460:4: TODAY ++ { ++ MATCHT(TODAY, &FOLLOW_TODAY_in_dateref616); ++ if (HASEXCEPTION()) ++ { ++ goto ruledaterefEx; ++ } ++ ++ { ++ retval.date= time(NULL); ++ } ++ ++ } ++ break; ++ ++ } ++ } ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruledaterefEx; /* Prevent compiler warnings */ ++ ruledaterefEx: ; ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end dateref */ ++ ++/** ++ * $ANTLR start dateintval ++ * RSP2SQL.g:464:1: dateintval returns [ time_t period, int valid ] : ( DAY | WEEK | MONTH | YEAR ); ++ */ ++static RSP2SQL_dateintval_return ++dateintval(pRSP2SQL ctx) ++{ ++ RSP2SQL_dateintval_return retval; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ retval.period= 0; retval.valid= 1; ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ { ++ { ++ // RSP2SQL.g:466:2: ( DAY | WEEK | MONTH | YEAR ) ++ ++ ANTLR3_UINT32 alt7; ++ ++ alt7=4; ++ ++ switch ( LA(1) ) ++ { ++ case DAY: ++ { ++ alt7=1; ++ } ++ break; ++ case WEEK: ++ { ++ alt7=2; ++ } ++ break; ++ case MONTH: ++ { ++ alt7=3; ++ } ++ break; ++ case YEAR: ++ { ++ alt7=4; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 7; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruledateintvalEx; ++ } ++ ++ switch (alt7) ++ { ++ case 1: ++ // RSP2SQL.g:466:4: DAY ++ { ++ MATCHT(DAY, &FOLLOW_DAY_in_dateintval640); ++ if (HASEXCEPTION()) ++ { ++ goto ruledateintvalEx; ++ } ++ ++ { ++ retval.period= 24 * 60 * 60; ++ } ++ ++ } ++ break; ++ case 2: ++ // RSP2SQL.g:468:4: WEEK ++ { ++ MATCHT(WEEK, &FOLLOW_WEEK_in_dateintval649); ++ if (HASEXCEPTION()) ++ { ++ goto ruledateintvalEx; ++ } ++ ++ { ++ retval.period= 7 * 24 * 60 * 60; ++ } ++ ++ } ++ break; ++ case 3: ++ // RSP2SQL.g:470:4: MONTH ++ { ++ MATCHT(MONTH, &FOLLOW_MONTH_in_dateintval658); ++ if (HASEXCEPTION()) ++ { ++ goto ruledateintvalEx; ++ } ++ ++ { ++ retval.period= 30 * 24 * 60 * 60; ++ } ++ ++ } ++ break; ++ case 4: ++ // RSP2SQL.g:472:4: YEAR ++ { ++ MATCHT(YEAR, &FOLLOW_YEAR_in_dateintval667); ++ if (HASEXCEPTION()) ++ { ++ goto ruledateintvalEx; ++ } ++ ++ { ++ retval.period= 365 * 24 * 60 * 60; ++ } ++ ++ } ++ break; ++ ++ } ++ } ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruledateintvalEx; /* Prevent compiler warnings */ ++ ruledateintvalEx: ; ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end dateintval */ ++/* End of parsing rules ++ * ============================================== ++ */ ++ ++/* ============================================== ++ * Syntactic predicates ++ */ ++/* End of syntactic predicates ++ * ============================================== ++ */ ++ ++ ++ ++ ++ ++ ++/* End of code ++ * ============================================================================= ++ */ +diff --git a/src/pregen/RSP2SQL.h b/src/pregen/RSP2SQL.h +new file mode 100644 +index 0000000..2789fc7 +--- /dev/null ++++ b/src/pregen/RSP2SQL.h +@@ -0,0 +1,291 @@ ++/** \file ++ * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3 ++ * ++ * - From the grammar source file : RSP2SQL.g ++ * - On : 2014-09-30 21:42:42 ++ * - for the tree parser : RSP2SQLTreeParser * ++ * Editing it, at least manually, is not wise. ++ * ++ * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. ++ * ++ * ++ * The tree parser RSP2SQL has the callable functions (rules) shown below, ++ * which will invoke the code for the associated rule in the source grammar ++ * assuming that the input stream is pointing to a token/text stream that could begin ++ * this rule. ++ * ++ * For instance if you call the first (topmost) rule in a parser grammar, you will ++ * get the results of a full parse, but calling a rule half way through the grammar will ++ * allow you to pass part of a full token stream to the parser, such as for syntax checking ++ * in editors and so on. ++ * ++ * The parser entry points are called indirectly (by function pointer to function) via ++ * a parser context typedef pRSP2SQL, which is returned from a call to RSP2SQLNew(). ++ * ++ * The methods in pRSP2SQL are as follows: ++ * ++ * - pANTLR3_STRING pRSP2SQL->query(pRSP2SQL) ++ * - RSP2SQL_expr_return pRSP2SQL->expr(pRSP2SQL) ++ * - RSP2SQL_strcrit_return pRSP2SQL->strcrit(pRSP2SQL) ++ * - pANTLR3_COMMON_TOKEN pRSP2SQL->strop(pRSP2SQL) ++ * - RSP2SQL_intcrit_return pRSP2SQL->intcrit(pRSP2SQL) ++ * - pANTLR3_COMMON_TOKEN pRSP2SQL->intop(pRSP2SQL) ++ * - RSP2SQL_datecrit_return pRSP2SQL->datecrit(pRSP2SQL) ++ * - pANTLR3_COMMON_TOKEN pRSP2SQL->dateop(pRSP2SQL) ++ * - RSP2SQL_datespec_return pRSP2SQL->datespec(pRSP2SQL) ++ * - RSP2SQL_dateref_return pRSP2SQL->dateref(pRSP2SQL) ++ * - RSP2SQL_dateintval_return pRSP2SQL->dateintval(pRSP2SQL) ++ * ++ * The return type for any particular rule is of course determined by the source ++ * grammar file. ++ */ ++// [The "BSD licence"] ++// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC ++// http://www.temporal-wave.com ++// http://www.linkedin.com/in/jimidle ++// ++// All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions ++// are met: ++// 1. Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// 2. Redistributions in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// 3. The name of the author may not be used to endorse or promote products ++// derived from this software without specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++#ifndef _RSP2SQL_H ++#define _RSP2SQL_H ++/* ============================================================================= ++ * Standard antlr3 C runtime definitions ++ */ ++#include ++ ++/* End of standard antlr 3 runtime definitions ++ * ============================================================================= ++ */ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++// Forward declare the context typedef so that we can use it before it is ++// properly defined. Delegators and delegates (from import statements) are ++// interdependent and their context structures contain pointers to each other ++// C only allows such things to be declared if you pre-declare the typedef. ++// ++typedef struct RSP2SQL_Ctx_struct RSP2SQL, * pRSP2SQL; ++ ++ ++ ++ /* Needs #define _GNU_SOURCE for strptime() */ ++ ++ #include ++ #include ++ #include ++ #include ++ ++ #include "logger.h" ++ #include "db.h" ++ #include "misc.h" ++ #include "rsp_query.h" ++ ++ ++#ifdef ANTLR3_WINDOWS ++// Disable: Unreferenced parameter, - Rules with parameters that are not used ++// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) ++// initialized but unused variable - tree rewrite variables declared but not needed ++// Unreferenced local variable - lexer rule declares but does not always use _type ++// potentially unitialized variable used - retval always returned from a rule ++// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns ++// ++// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at ++// and the codegen must generate some of these warnings by necessity, apart from 4100, which is ++// usually generated when a parser rule is given a parameter that it does not use. Mostly though ++// this is a matter of orthogonality hence I disable that one. ++// ++#pragma warning( disable : 4100 ) ++#pragma warning( disable : 4101 ) ++#pragma warning( disable : 4127 ) ++#pragma warning( disable : 4189 ) ++#pragma warning( disable : 4505 ) ++#pragma warning( disable : 4701 ) ++#endif ++typedef struct RSP2SQL_expr_return_struct ++{ ++ pANTLR3_BASE_TREE start; ++ pANTLR3_BASE_TREE stop; ++ pANTLR3_STRING result; ++ int valid; ++} ++ RSP2SQL_expr_return; ++ ++typedef struct RSP2SQL_strcrit_return_struct ++{ ++ pANTLR3_BASE_TREE start; ++ pANTLR3_BASE_TREE stop; ++ pANTLR3_STRING result; ++ int valid; ++} ++ RSP2SQL_strcrit_return; ++ ++typedef struct RSP2SQL_intcrit_return_struct ++{ ++ pANTLR3_BASE_TREE start; ++ pANTLR3_BASE_TREE stop; ++ pANTLR3_STRING result; ++ int valid; ++} ++ RSP2SQL_intcrit_return; ++ ++typedef struct RSP2SQL_datecrit_return_struct ++{ ++ pANTLR3_BASE_TREE start; ++ pANTLR3_BASE_TREE stop; ++ pANTLR3_STRING result; ++ int valid; ++} ++ RSP2SQL_datecrit_return; ++ ++typedef struct RSP2SQL_datespec_return_struct ++{ ++ pANTLR3_BASE_TREE start; ++ pANTLR3_BASE_TREE stop; ++ time_t date; ++ int valid; ++} ++ RSP2SQL_datespec_return; ++ ++typedef struct RSP2SQL_dateref_return_struct ++{ ++ pANTLR3_BASE_TREE start; ++ pANTLR3_BASE_TREE stop; ++ time_t date; ++ int valid; ++} ++ RSP2SQL_dateref_return; ++ ++typedef struct RSP2SQL_dateintval_return_struct ++{ ++ pANTLR3_BASE_TREE start; ++ pANTLR3_BASE_TREE stop; ++ time_t period; ++ int valid; ++} ++ RSP2SQL_dateintval_return; ++ ++ ++ ++/** Context tracking structure for RSP2SQL ++ */ ++struct RSP2SQL_Ctx_struct ++{ ++ /** Built in ANTLR3 context tracker contains all the generic elements ++ * required for context tracking. ++ */ ++ pANTLR3_TREE_PARSER pTreeParser; ++ ++ ++ pANTLR3_STRING (*query) (struct RSP2SQL_Ctx_struct * ctx); ++ RSP2SQL_expr_return (*expr) (struct RSP2SQL_Ctx_struct * ctx); ++ RSP2SQL_strcrit_return (*strcrit) (struct RSP2SQL_Ctx_struct * ctx); ++ pANTLR3_COMMON_TOKEN (*strop) (struct RSP2SQL_Ctx_struct * ctx); ++ RSP2SQL_intcrit_return (*intcrit) (struct RSP2SQL_Ctx_struct * ctx); ++ pANTLR3_COMMON_TOKEN (*intop) (struct RSP2SQL_Ctx_struct * ctx); ++ RSP2SQL_datecrit_return (*datecrit) (struct RSP2SQL_Ctx_struct * ctx); ++ pANTLR3_COMMON_TOKEN (*dateop) (struct RSP2SQL_Ctx_struct * ctx); ++ RSP2SQL_datespec_return (*datespec) (struct RSP2SQL_Ctx_struct * ctx); ++ RSP2SQL_dateref_return (*dateref) (struct RSP2SQL_Ctx_struct * ctx); ++ RSP2SQL_dateintval_return (*dateintval) (struct RSP2SQL_Ctx_struct * ctx); ++ // Delegated rules ++ const char * (*getGrammarFileName)(); ++ void (*free) (struct RSP2SQL_Ctx_struct * ctx); ++ ++}; ++ ++// Function protoypes for the constructor functions that external translation units ++// such as delegators and delegates may wish to call. ++// ++ANTLR3_API pRSP2SQL RSP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream); ++ANTLR3_API pRSP2SQL RSP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); ++ ++/** Symbolic definitions of all the tokens that the tree parser will work with. ++ * \{ ++ * ++ * Antlr will define EOF, but we can't use that as it it is too common in ++ * in C header files and that would be confusing. There is no way to filter this out at the moment ++ * so we just undef it here for now. That isn't the value we get back from C recognizers ++ * anyway. We are looking for ANTLR3_TOKEN_EOF. ++ */ ++#ifdef EOF ++#undef EOF ++#endif ++#ifdef Tokens ++#undef Tokens ++#endif ++#define STARTSW 14 ++#define WEEK 26 ++#define TODAY 24 ++#define YEAR 28 ++#define ENDSW 15 ++#define GTE 20 ++#define BEFORE 21 ++#define DAY 25 ++#define INT 16 ++#define NOT 11 ++#define AFTER 22 ++#define AND 6 ++#define EOF -1 ++#define LTE 19 ++#define MONTH 27 ++#define DIGIT19 31 ++#define INCLUDES 13 ++#define STR 10 ++#define QUOTE 29 ++#define GREATER 18 ++#define WS 30 ++#define LPAR 7 ++#define NEWLINE 4 ++#define EQUAL 12 ++#define OR 5 ++#define LESS 17 ++#define FIELD 9 ++#define RPAR 8 ++#define ESCAPED 33 ++#define DATE 23 ++#define DIGIT09 32 ++#ifdef EOF ++#undef EOF ++#define EOF ANTLR3_TOKEN_EOF ++#endif ++ ++#ifndef TOKENSOURCE ++#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource ++#endif ++ ++/* End of token definitions for RSP2SQL ++ * ============================================================================= ++ */ ++/** \} */ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif ++ ++/* END - Note:Keep extra line feed to satisfy UNIX systems */ +diff --git a/src/pregen/RSP2SQL.u b/src/pregen/RSP2SQL.u +new file mode 100644 +index 0000000..53d8cda +--- /dev/null ++++ b/src/pregen/RSP2SQL.u +@@ -0,0 +1,5 @@ ++RSP2SQL.g: RSP.tokens ++RSP2SQL.c : RSP2SQL.g ++./RSP2SQL.tokens : RSP2SQL.g ++RSP2SQL.h : RSP2SQL.g ++ANTLR_PRODUCTS += RSP2SQL.c ./RSP2SQL.tokens RSP2SQL.h +\ No newline at end of file +diff --git a/src/pregen/RSPLexer.c b/src/pregen/RSPLexer.c +new file mode 100644 +index 0000000..ee23c08 +--- /dev/null ++++ b/src/pregen/RSPLexer.c +@@ -0,0 +1,4867 @@ ++/** \file ++ * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3 ++ * ++ * - From the grammar source file : RSP.g ++ * - On : 2014-09-30 21:42:41 ++ * - for the lexer : RSPLexerLexer * ++ * Editing it, at least manually, is not wise. ++ * ++ * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. ++ * ++ * ++*/ ++// [The "BSD licence"] ++// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC ++// http://www.temporal-wave.com ++// http://www.linkedin.com/in/jimidle ++// ++// All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions ++// are met: ++// 1. Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// 2. Redistributions in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// 3. The name of the author may not be used to endorse or promote products ++// derived from this software without specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++/* ----------------------------------------- ++ * Include the ANTLR3 generated header file. ++ */ ++#include "RSPLexer.h" ++/* ----------------------------------------- */ ++ ++ ++/** String literals used by RSPLexer that we must do things like MATCHS() with. ++ * C will normally just lay down 8 bit characters, and you can use L"xxx" to ++ * get wchar_t, but wchar_t is 16 bits on Windows, which is not UTF32 and so ++ * we perform this little trick of defining the literals as arrays of UINT32 ++ * and passing in the address of these. ++ */ ++static ANTLR3_UCHAR lit_1[] = { 0x61, 0x6E, 0x64, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_2[] = { 0x6F, 0x72, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_3[] = { 0x69, 0x6E, 0x63, 0x6C, 0x75, 0x64, 0x65, 0x73, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_4[] = { 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x77, 0x69, 0x74, 0x68, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_5[] = { 0x65, 0x6E, 0x64, 0x73, 0x77, 0x69, 0x74, 0x68, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_6[] = { 0x3E, 0x3D, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_7[] = { 0x3C, 0x3D, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_8[] = { 0x62, 0x65, 0x66, 0x6F, 0x72, 0x65, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_9[] = { 0x61, 0x66, 0x74, 0x65, 0x72, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_10[] = { 0x64, 0x61, 0x79, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_11[] = { 0x64, 0x61, 0x79, 0x73, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_12[] = { 0x77, 0x65, 0x65, 0x6B, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_13[] = { 0x77, 0x65, 0x65, 0x6B, 0x73, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_14[] = { 0x6D, 0x6F, 0x6E, 0x74, 0x68, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_15[] = { 0x6D, 0x6F, 0x6E, 0x74, 0x68, 0x73, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_16[] = { 0x79, 0x65, 0x61, 0x72, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_17[] = { 0x79, 0x65, 0x61, 0x72, 0x73, ANTLR3_STRING_TERMINATOR}; ++static ANTLR3_UCHAR lit_18[] = { 0x74, 0x6F, 0x64, 0x61, 0x79, ANTLR3_STRING_TERMINATOR}; ++ ++ ++ ++ ++/* MACROS that hide the C interface implementations from the ++ * generated code, which makes it a little more understandable to the human eye. ++ * I am very much against using C pre-processor macros for function calls and bits ++ * of code as you cannot see what is happening when single stepping in debuggers ++ * and so on. The exception (in my book at least) is for generated code, where you are ++ * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() ++ * hides some indirect calls, but is always referring to the input stream. This is ++ * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig ++ * the runtime interfaces without changing the generated code too often, without ++ * confusing the reader of the generated output, who may not wish to know the gory ++ * details of the interface inheritance. ++ */ ++ ++#define CTX ctx ++ ++/* Aids in accessing scopes for grammar programmers ++ */ ++#undef SCOPE_TYPE ++#undef SCOPE_STACK ++#undef SCOPE_TOP ++#define SCOPE_TYPE(scope) pRSPLexer_##scope##_SCOPE ++#define SCOPE_STACK(scope) pRSPLexer_##scope##Stack ++#define SCOPE_TOP(scope) ctx->pRSPLexer_##scope##Top ++#define SCOPE_SIZE(scope) ctx->pRSPLexer_##scope##Stack_limit ++#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) ++ ++ ++/* Macros for accessing things in a lexer ++ */ ++#undef LEXER ++#undef RECOGNIZER ++#undef RULEMEMO ++#undef GETCHARINDEX ++#undef GETLINE ++#undef GETCHARPOSITIONINLINE ++#undef EMIT ++#undef EMITNEW ++#undef MATCHC ++#undef MATCHS ++#undef MATCHRANGE ++#undef LTOKEN ++#undef HASFAILED ++#undef FAILEDFLAG ++#undef INPUT ++#undef STRSTREAM ++#undef LA ++#undef HASEXCEPTION ++#undef EXCEPTION ++#undef CONSTRUCTEX ++#undef CONSUME ++#undef LRECOVER ++#undef MARK ++#undef REWIND ++#undef REWINDLAST ++#undef BACKTRACKING ++#undef MATCHANY ++#undef MEMOIZE ++#undef HAVEPARSEDRULE ++#undef GETTEXT ++#undef INDEX ++#undef SEEK ++#undef PUSHSTREAM ++#undef POPSTREAM ++#undef SETTEXT ++#undef SETTEXT8 ++ ++#define LEXER ctx->pLexer ++#define RECOGNIZER LEXER->rec ++#define LEXSTATE RECOGNIZER->state ++#define TOKSOURCE LEXSTATE->tokSource ++#define GETCHARINDEX() LEXER->getCharIndex(LEXER) ++#define GETLINE() LEXER->getLine(LEXER) ++#define GETTEXT() LEXER->getText(LEXER) ++#define GETCHARPOSITIONINLINE() LEXER->getCharPositionInLine(LEXER) ++#define EMIT() LEXSTATE->type = _type; LEXER->emit(LEXER) ++#define EMITNEW(t) LEXER->emitNew(LEXER, t) ++#define MATCHC(c) LEXER->matchc(LEXER, c) ++#define MATCHS(s) LEXER->matchs(LEXER, s) ++#define MATCHRANGE(c1,c2) LEXER->matchRange(LEXER, c1, c2) ++#define MATCHANY() LEXER->matchAny(LEXER) ++#define LTOKEN LEXSTATE->token ++#define HASFAILED() (LEXSTATE->failed == ANTLR3_TRUE) ++#define BACKTRACKING LEXSTATE->backtracking ++#define FAILEDFLAG LEXSTATE->failed ++#define INPUT LEXER->input ++#define STRSTREAM INPUT ++#define ISTREAM INPUT->istream ++#define INDEX() ISTREAM->index(ISTREAM) ++#define SEEK(n) ISTREAM->seek(ISTREAM, n) ++#define EOF_TOKEN &(LEXSTATE->tokSource->eofToken) ++#define HASEXCEPTION() (LEXSTATE->error == ANTLR3_TRUE) ++#define EXCEPTION LEXSTATE->exception ++#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) ++#define LRECOVER() LEXER->recover(LEXER) ++#define MARK() ISTREAM->mark(ISTREAM) ++#define REWIND(m) ISTREAM->rewind(ISTREAM, m) ++#define REWINDLAST() ISTREAM->rewindLast(ISTREAM) ++#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si) ++#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) ++#define PUSHSTREAM(str) LEXER->pushCharStream(LEXER, str) ++#define POPSTREAM() LEXER->popCharStream(LEXER) ++#define SETTEXT(str) LEXSTATE->text = str ++#define SKIP() LEXSTATE->token = &(TOKSOURCE->skipToken) ++#define USER1 LEXSTATE->user1 ++#define USER2 LEXSTATE->user2 ++#define USER3 LEXSTATE->user3 ++#define CUSTOM LEXSTATE->custom ++#define RULEMEMO LEXSTATE->ruleMemo ++#define DBG RECOGNIZER->debugger ++ ++/* If we have been told we can rely on the standard 8 bit or 16 bit input ++ * stream, then we can define our macros to use the direct pointers ++ * in the input object, which is much faster than indirect calls. This ++ * is really only significant to lexers with a lot of fragment rules (which ++ * do not place LA(1) in a temporary at the moment) and even then ++ * only if there is a lot of input (order of say 1M or so). ++ */ ++#if defined(ANTLR3_INLINE_INPUT_ASCII) || defined(ANTLR3_INLINE_INPUT_UTF16) ++ ++# ifdef ANTLR3_INLINE_INPUT_ASCII ++ ++/* 8 bit "ASCII" (actually any 8 bit character set) */ ++ ++# define NEXTCHAR ((pANTLR3_UINT8)(INPUT->nextChar)) ++# define DATAP ((pANTLR3_UINT8)(INPUT->data)) ++ ++# else ++ ++# define NEXTCHAR ((pANTLR3_UINT16)(INPUT->nextChar)) ++# define DATAP ((pANTLR3_UINT16)(INPUT->data)) ++ ++# endif ++ ++# define LA(n) ((NEXTCHAR + n) > (DATAP + INPUT->sizeBuf) ? ANTLR3_CHARSTREAM_EOF : (ANTLR3_UCHAR)(*(NEXTCHAR + n - 1))) ++# define CONSUME() \ ++{ \ ++ if (NEXTCHAR < (DATAP + INPUT->sizeBuf)) \ ++ { \ ++ INPUT->charPositionInLine++; \ ++ if ((ANTLR3_UCHAR)(*NEXTCHAR) == INPUT->newlineChar) \ ++ { \ ++ INPUT->line++; \ ++ INPUT->charPositionInLine = 0; \ ++ INPUT->currentLine = (void *)(NEXTCHAR + 1); \ ++ } \ ++ INPUT->nextChar = (void *)(NEXTCHAR + 1); \ ++ } \ ++} ++ ++#else ++ ++// Pick up the input character by calling the input stream implementation. ++// ++#define CONSUME() INPUT->istream->consume(INPUT->istream) ++#define LA(n) INPUT->istream->_LA(INPUT->istream, n) ++ ++#endif ++#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt ++ ++/* The 4 tokens defined below may well clash with your own #defines or token types. If so ++ * then for the present you must use different names for your defines as these are hard coded ++ * in the code generator. It would be better not to use such names internally, and maybe ++ * we can change this in a forthcoming release. I deliberately do not #undef these ++ * here as this will at least give you a redefined error somewhere if they clash. ++ */ ++#define UP ANTLR3_TOKEN_UP ++#define DOWN ANTLR3_TOKEN_DOWN ++#define EOR ANTLR3_TOKEN_EOR ++#define INVALID ANTLR3_TOKEN_INVALID ++ ++ ++/* ============================================================================= ++ * Functions to create and destroy scopes. First come the rule scopes, followed ++ * by the global declared scopes. ++ */ ++ ++ ++ ++/* ============================================================================= */ ++ ++/* ============================================================================= ++ * Start of recognizer ++ */ ++ ++ ++/* Forward declare the locally static matching functions we have generated and any predicate functions. ++ */ ++static ANTLR3_INLINE void mQUOTE (pRSPLexer ctx); ++static ANTLR3_INLINE void mLPAR (pRSPLexer ctx); ++static ANTLR3_INLINE void mRPAR (pRSPLexer ctx); ++static ANTLR3_INLINE void mAND (pRSPLexer ctx); ++static ANTLR3_INLINE void mOR (pRSPLexer ctx); ++static ANTLR3_INLINE void mNOT (pRSPLexer ctx); ++static ANTLR3_INLINE void mEQUAL (pRSPLexer ctx); ++static ANTLR3_INLINE void mINCLUDES (pRSPLexer ctx); ++static ANTLR3_INLINE void mSTARTSW (pRSPLexer ctx); ++static ANTLR3_INLINE void mENDSW (pRSPLexer ctx); ++static ANTLR3_INLINE void mGREATER (pRSPLexer ctx); ++static ANTLR3_INLINE void mLESS (pRSPLexer ctx); ++static ANTLR3_INLINE void mGTE (pRSPLexer ctx); ++static ANTLR3_INLINE void mLTE (pRSPLexer ctx); ++static ANTLR3_INLINE void mBEFORE (pRSPLexer ctx); ++static ANTLR3_INLINE void mAFTER (pRSPLexer ctx); ++static ANTLR3_INLINE void mDAY (pRSPLexer ctx); ++static ANTLR3_INLINE void mWEEK (pRSPLexer ctx); ++static ANTLR3_INLINE void mMONTH (pRSPLexer ctx); ++static ANTLR3_INLINE void mYEAR (pRSPLexer ctx); ++static ANTLR3_INLINE void mTODAY (pRSPLexer ctx); ++static ANTLR3_INLINE void mNEWLINE (pRSPLexer ctx); ++static ANTLR3_INLINE void mWS (pRSPLexer ctx); ++static ANTLR3_INLINE void mFIELD (pRSPLexer ctx); ++static ANTLR3_INLINE void mINT (pRSPLexer ctx); ++static ANTLR3_INLINE void mDATE (pRSPLexer ctx); ++static ANTLR3_INLINE void mSTR (pRSPLexer ctx); ++static ANTLR3_INLINE void mESCAPED (pRSPLexer ctx); ++static ANTLR3_INLINE void mDIGIT09 (pRSPLexer ctx); ++static ANTLR3_INLINE void mDIGIT19 (pRSPLexer ctx); ++static ANTLR3_INLINE void mTokens (pRSPLexer ctx); ++static void RSPLexerFree(pRSPLexer ctx); ++ ++/* ========================================================================= ++ * Lexer matching rules end. ++ * ========================================================================= ++ */ ++ ++ ++ ++static void ++RSPLexerFree (pRSPLexer ctx) ++{ ++ LEXER->free(LEXER); ++ ++ ANTLR3_FREE(ctx); ++} ++ ++/** \brief Name of the grammar file that generated this code ++ */ ++static const char fileName[] = "RSP.g"; ++ ++/** \brief Return the name of the grammar file that generated this code. ++ */ ++static const char * getGrammarFileName() ++{ ++ return fileName; ++} ++ ++/** \brief Create a new lexer called RSPLexer ++ * ++ * \param[in] instream Pointer to an initialized input stream ++ * \return ++ * - Success pRSPLexer initialized for the lex start ++ * - Fail NULL ++ */ ++ANTLR3_API pRSPLexer RSPLexerNew ++(pANTLR3_INPUT_STREAM instream) ++{ ++ // See if we can create a new lexer with the standard constructor ++ // ++ return RSPLexerNewSSD(instream, NULL); ++} ++ ++/** \brief Create a new lexer called RSPLexer ++ * ++ * \param[in] instream Pointer to an initialized input stream ++ * \param[state] state Previously created shared recognizer stat ++ * \return ++ * - Success pRSPLexer initialized for the lex start ++ * - Fail NULL ++ */ ++ANTLR3_API pRSPLexer RSPLexerNewSSD ++(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) ++{ ++ pRSPLexer ctx; // Context structure we will build and return ++ ++ ctx = (pRSPLexer) ANTLR3_CALLOC(1, sizeof(RSPLexer)); ++ ++ if (ctx == NULL) ++ { ++ // Failed to allocate memory for lexer context ++ return NULL; ++ } ++ ++ /* ------------------------------------------------------------------- ++ * Memory for basic structure is allocated, now to fill in ++ * in base ANTLR3 structures. We initialize the function pointers ++ * for the standard ANTLR3 lexer function set, but upon return ++ * from here, the programmer may set the pointers to provide custom ++ * implementations of each function. ++ * ++ * We don't use the macros defined in RSPLexer.h here so you can get a sense ++ * of what goes where. ++ */ ++ ++ /* Create a base lexer, using the supplied input stream ++ */ ++ ctx->pLexer = antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state); ++ ++ /* Check that we allocated the memory correctly ++ */ ++ if (ctx->pLexer == NULL) ++ { ++ ANTLR3_FREE(ctx); ++ return NULL; ++ } ++ /* Install the implementation of our RSPLexer interface ++ */ ++ ctx->mQUOTE = mQUOTE; ++ ctx->mLPAR = mLPAR; ++ ctx->mRPAR = mRPAR; ++ ctx->mAND = mAND; ++ ctx->mOR = mOR; ++ ctx->mNOT = mNOT; ++ ctx->mEQUAL = mEQUAL; ++ ctx->mINCLUDES = mINCLUDES; ++ ctx->mSTARTSW = mSTARTSW; ++ ctx->mENDSW = mENDSW; ++ ctx->mGREATER = mGREATER; ++ ctx->mLESS = mLESS; ++ ctx->mGTE = mGTE; ++ ctx->mLTE = mLTE; ++ ctx->mBEFORE = mBEFORE; ++ ctx->mAFTER = mAFTER; ++ ctx->mDAY = mDAY; ++ ctx->mWEEK = mWEEK; ++ ctx->mMONTH = mMONTH; ++ ctx->mYEAR = mYEAR; ++ ctx->mTODAY = mTODAY; ++ ctx->mNEWLINE = mNEWLINE; ++ ctx->mWS = mWS; ++ ctx->mFIELD = mFIELD; ++ ctx->mINT = mINT; ++ ctx->mDATE = mDATE; ++ ctx->mSTR = mSTR; ++ ctx->mESCAPED = mESCAPED; ++ ctx->mDIGIT09 = mDIGIT09; ++ ctx->mDIGIT19 = mDIGIT19; ++ ctx->mTokens = mTokens; ++ ++ /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE ++ * it will call mTokens() in this generated code, and will pass it the ctx ++ * pointer of this lexer, not the context of the base lexer, so store that now. ++ */ ++ ctx->pLexer->ctx = ctx; ++ ++ /**Install the token matching function ++ */ ++ ctx->pLexer->mTokens = (void (*) (void *))(mTokens); ++ ++ ctx->getGrammarFileName = getGrammarFileName; ++ ctx->free = RSPLexerFree; ++ ++ ++ ++ ++ ++ /* Return the newly built lexer to the caller ++ */ ++ return ctx; ++} ++ ++ ++/* ========================================================================= ++ * Functions to match the lexer grammar defined tokens from the input stream ++ */ ++ ++// Comes from: 85:7: ( '\"' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start QUOTE ++ * ++ * Looks to match the characters the constitute the token QUOTE ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mQUOTE(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = QUOTE; ++ ++ ++ // RSP.g:85:7: ( '\"' ) ++ // RSP.g:85:9: '\"' ++ { ++ MATCHC('"'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleQUOTEEx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleQUOTEEx; /* Prevent compiler warnings */ ++ ruleQUOTEEx: ; ++ ++} ++// $ANTLR end QUOTE ++ ++// Comes from: 86:6: ( '(' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start LPAR ++ * ++ * Looks to match the characters the constitute the token LPAR ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mLPAR(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = LPAR; ++ ++ ++ // RSP.g:86:6: ( '(' ) ++ // RSP.g:86:8: '(' ++ { ++ MATCHC('('); ++ if (HASEXCEPTION()) ++ { ++ goto ruleLPAREx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleLPAREx; /* Prevent compiler warnings */ ++ ruleLPAREx: ; ++ ++} ++// $ANTLR end LPAR ++ ++// Comes from: 87:6: ( ')' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start RPAR ++ * ++ * Looks to match the characters the constitute the token RPAR ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mRPAR(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = RPAR; ++ ++ ++ // RSP.g:87:6: ( ')' ) ++ // RSP.g:87:8: ')' ++ { ++ MATCHC(')'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleRPAREx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleRPAREx; /* Prevent compiler warnings */ ++ ruleRPAREx: ; ++ ++} ++// $ANTLR end RPAR ++ ++// Comes from: 89:5: ( 'and' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start AND ++ * ++ * Looks to match the characters the constitute the token AND ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mAND(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = AND; ++ ++ ++ // RSP.g:89:5: ( 'and' ) ++ // RSP.g:89:7: 'and' ++ { ++ MATCHS(lit_1); ++ if (HASEXCEPTION()) ++ { ++ goto ruleANDEx; ++ } ++ ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleANDEx; /* Prevent compiler warnings */ ++ ruleANDEx: ; ++ ++} ++// $ANTLR end AND ++ ++// Comes from: 90:4: ( 'or' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start OR ++ * ++ * Looks to match the characters the constitute the token OR ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mOR(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = OR; ++ ++ ++ // RSP.g:90:4: ( 'or' ) ++ // RSP.g:90:6: 'or' ++ { ++ MATCHS(lit_2); ++ if (HASEXCEPTION()) ++ { ++ goto ruleOREx; ++ } ++ ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleOREx; /* Prevent compiler warnings */ ++ ruleOREx: ; ++ ++} ++// $ANTLR end OR ++ ++// Comes from: 91:5: ( '!' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start NOT ++ * ++ * Looks to match the characters the constitute the token NOT ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mNOT(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = NOT; ++ ++ ++ // RSP.g:91:5: ( '!' ) ++ // RSP.g:91:7: '!' ++ { ++ MATCHC('!'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleNOTEx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleNOTEx; /* Prevent compiler warnings */ ++ ruleNOTEx: ; ++ ++} ++// $ANTLR end NOT ++ ++// Comes from: 94:7: ( '=' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start EQUAL ++ * ++ * Looks to match the characters the constitute the token EQUAL ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mEQUAL(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = EQUAL; ++ ++ ++ // RSP.g:94:7: ( '=' ) ++ // RSP.g:94:9: '=' ++ { ++ MATCHC('='); ++ if (HASEXCEPTION()) ++ { ++ goto ruleEQUALEx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleEQUALEx; /* Prevent compiler warnings */ ++ ruleEQUALEx: ; ++ ++} ++// $ANTLR end EQUAL ++ ++// Comes from: 97:9: ( 'includes' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start INCLUDES ++ * ++ * Looks to match the characters the constitute the token INCLUDES ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mINCLUDES(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = INCLUDES; ++ ++ ++ // RSP.g:97:9: ( 'includes' ) ++ // RSP.g:97:11: 'includes' ++ { ++ MATCHS(lit_3); ++ if (HASEXCEPTION()) ++ { ++ goto ruleINCLUDESEx; ++ } ++ ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleINCLUDESEx; /* Prevent compiler warnings */ ++ ruleINCLUDESEx: ; ++ ++} ++// $ANTLR end INCLUDES ++ ++// Comes from: 98:9: ( 'startswith' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start STARTSW ++ * ++ * Looks to match the characters the constitute the token STARTSW ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mSTARTSW(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = STARTSW; ++ ++ ++ // RSP.g:98:9: ( 'startswith' ) ++ // RSP.g:98:11: 'startswith' ++ { ++ MATCHS(lit_4); ++ if (HASEXCEPTION()) ++ { ++ goto ruleSTARTSWEx; ++ } ++ ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleSTARTSWEx; /* Prevent compiler warnings */ ++ ruleSTARTSWEx: ; ++ ++} ++// $ANTLR end STARTSW ++ ++// Comes from: 99:7: ( 'endswith' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start ENDSW ++ * ++ * Looks to match the characters the constitute the token ENDSW ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mENDSW(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = ENDSW; ++ ++ ++ // RSP.g:99:7: ( 'endswith' ) ++ // RSP.g:99:9: 'endswith' ++ { ++ MATCHS(lit_5); ++ if (HASEXCEPTION()) ++ { ++ goto ruleENDSWEx; ++ } ++ ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleENDSWEx; /* Prevent compiler warnings */ ++ ruleENDSWEx: ; ++ ++} ++// $ANTLR end ENDSW ++ ++// Comes from: 102:9: ( '>' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start GREATER ++ * ++ * Looks to match the characters the constitute the token GREATER ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mGREATER(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = GREATER; ++ ++ ++ // RSP.g:102:9: ( '>' ) ++ // RSP.g:102:11: '>' ++ { ++ MATCHC('>'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleGREATEREx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleGREATEREx; /* Prevent compiler warnings */ ++ ruleGREATEREx: ; ++ ++} ++// $ANTLR end GREATER ++ ++// Comes from: 103:6: ( '<' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start LESS ++ * ++ * Looks to match the characters the constitute the token LESS ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mLESS(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = LESS; ++ ++ ++ // RSP.g:103:6: ( '<' ) ++ // RSP.g:103:8: '<' ++ { ++ MATCHC('<'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleLESSEx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleLESSEx; /* Prevent compiler warnings */ ++ ruleLESSEx: ; ++ ++} ++// $ANTLR end LESS ++ ++// Comes from: 104:5: ( '>=' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start GTE ++ * ++ * Looks to match the characters the constitute the token GTE ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mGTE(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = GTE; ++ ++ ++ // RSP.g:104:5: ( '>=' ) ++ // RSP.g:104:7: '>=' ++ { ++ MATCHS(lit_6); ++ if (HASEXCEPTION()) ++ { ++ goto ruleGTEEx; ++ } ++ ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleGTEEx; /* Prevent compiler warnings */ ++ ruleGTEEx: ; ++ ++} ++// $ANTLR end GTE ++ ++// Comes from: 105:5: ( '<=' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start LTE ++ * ++ * Looks to match the characters the constitute the token LTE ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mLTE(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = LTE; ++ ++ ++ // RSP.g:105:5: ( '<=' ) ++ // RSP.g:105:7: '<=' ++ { ++ MATCHS(lit_7); ++ if (HASEXCEPTION()) ++ { ++ goto ruleLTEEx; ++ } ++ ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleLTEEx; /* Prevent compiler warnings */ ++ ruleLTEEx: ; ++ ++} ++// $ANTLR end LTE ++ ++// Comes from: 108:8: ( 'before' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start BEFORE ++ * ++ * Looks to match the characters the constitute the token BEFORE ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mBEFORE(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = BEFORE; ++ ++ ++ // RSP.g:108:8: ( 'before' ) ++ // RSP.g:108:10: 'before' ++ { ++ MATCHS(lit_8); ++ if (HASEXCEPTION()) ++ { ++ goto ruleBEFOREEx; ++ } ++ ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleBEFOREEx; /* Prevent compiler warnings */ ++ ruleBEFOREEx: ; ++ ++} ++// $ANTLR end BEFORE ++ ++// Comes from: 109:7: ( 'after' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start AFTER ++ * ++ * Looks to match the characters the constitute the token AFTER ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mAFTER(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = AFTER; ++ ++ ++ // RSP.g:109:7: ( 'after' ) ++ // RSP.g:109:9: 'after' ++ { ++ MATCHS(lit_9); ++ if (HASEXCEPTION()) ++ { ++ goto ruleAFTEREx; ++ } ++ ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleAFTEREx; /* Prevent compiler warnings */ ++ ruleAFTEREx: ; ++ ++} ++// $ANTLR end AFTER ++ ++// Comes from: 110:5: ( 'day' | 'days' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start DAY ++ * ++ * Looks to match the characters the constitute the token DAY ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mDAY(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = DAY; ++ ++ ++ { ++ // RSP.g:110:5: ( 'day' | 'days' ) ++ ++ ANTLR3_UINT32 alt1; ++ ++ alt1=2; ++ ++ switch ( LA(1) ) ++ { ++ case 'd': ++ { ++ switch ( LA(2) ) ++ { ++ case 'a': ++ { ++ switch ( LA(3) ) ++ { ++ case 'y': ++ { ++ switch ( LA(4) ) ++ { ++ case 's': ++ { ++ alt1=2; ++ } ++ break; ++ ++ default: ++ alt1=1;} ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 1; ++ EXCEPTION->state = 2; ++ ++ ++ goto ruleDAYEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 1; ++ EXCEPTION->state = 1; ++ ++ ++ goto ruleDAYEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 1; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleDAYEx; ++ } ++ ++ switch (alt1) ++ { ++ case 1: ++ // RSP.g:110:7: 'day' ++ { ++ MATCHS(lit_10); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDAYEx; ++ } ++ ++ ++ ++ } ++ break; ++ case 2: ++ // RSP.g:110:15: 'days' ++ { ++ MATCHS(lit_11); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDAYEx; ++ } ++ ++ ++ ++ } ++ break; ++ ++ } ++ } ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleDAYEx; /* Prevent compiler warnings */ ++ ruleDAYEx: ; ++ ++} ++// $ANTLR end DAY ++ ++// Comes from: 111:6: ( 'week' | 'weeks' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start WEEK ++ * ++ * Looks to match the characters the constitute the token WEEK ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mWEEK(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = WEEK; ++ ++ ++ { ++ // RSP.g:111:6: ( 'week' | 'weeks' ) ++ ++ ANTLR3_UINT32 alt2; ++ ++ alt2=2; ++ ++ switch ( LA(1) ) ++ { ++ case 'w': ++ { ++ switch ( LA(2) ) ++ { ++ case 'e': ++ { ++ switch ( LA(3) ) ++ { ++ case 'e': ++ { ++ switch ( LA(4) ) ++ { ++ case 'k': ++ { ++ switch ( LA(5) ) ++ { ++ case 's': ++ { ++ alt2=2; ++ } ++ break; ++ ++ default: ++ alt2=1;} ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 2; ++ EXCEPTION->state = 3; ++ ++ ++ goto ruleWEEKEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 2; ++ EXCEPTION->state = 2; ++ ++ ++ goto ruleWEEKEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 2; ++ EXCEPTION->state = 1; ++ ++ ++ goto ruleWEEKEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 2; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleWEEKEx; ++ } ++ ++ switch (alt2) ++ { ++ case 1: ++ // RSP.g:111:8: 'week' ++ { ++ MATCHS(lit_12); ++ if (HASEXCEPTION()) ++ { ++ goto ruleWEEKEx; ++ } ++ ++ ++ ++ } ++ break; ++ case 2: ++ // RSP.g:111:17: 'weeks' ++ { ++ MATCHS(lit_13); ++ if (HASEXCEPTION()) ++ { ++ goto ruleWEEKEx; ++ } ++ ++ ++ ++ } ++ break; ++ ++ } ++ } ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleWEEKEx; /* Prevent compiler warnings */ ++ ruleWEEKEx: ; ++ ++} ++// $ANTLR end WEEK ++ ++// Comes from: 112:7: ( 'month' | 'months' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start MONTH ++ * ++ * Looks to match the characters the constitute the token MONTH ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mMONTH(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = MONTH; ++ ++ ++ { ++ // RSP.g:112:7: ( 'month' | 'months' ) ++ ++ ANTLR3_UINT32 alt3; ++ ++ alt3=2; ++ ++ switch ( LA(1) ) ++ { ++ case 'm': ++ { ++ switch ( LA(2) ) ++ { ++ case 'o': ++ { ++ switch ( LA(3) ) ++ { ++ case 'n': ++ { ++ switch ( LA(4) ) ++ { ++ case 't': ++ { ++ switch ( LA(5) ) ++ { ++ case 'h': ++ { ++ switch ( LA(6) ) ++ { ++ case 's': ++ { ++ alt3=2; ++ } ++ break; ++ ++ default: ++ alt3=1;} ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 3; ++ EXCEPTION->state = 4; ++ ++ ++ goto ruleMONTHEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 3; ++ EXCEPTION->state = 3; ++ ++ ++ goto ruleMONTHEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 3; ++ EXCEPTION->state = 2; ++ ++ ++ goto ruleMONTHEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 3; ++ EXCEPTION->state = 1; ++ ++ ++ goto ruleMONTHEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 3; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleMONTHEx; ++ } ++ ++ switch (alt3) ++ { ++ case 1: ++ // RSP.g:112:9: 'month' ++ { ++ MATCHS(lit_14); ++ if (HASEXCEPTION()) ++ { ++ goto ruleMONTHEx; ++ } ++ ++ ++ ++ } ++ break; ++ case 2: ++ // RSP.g:112:19: 'months' ++ { ++ MATCHS(lit_15); ++ if (HASEXCEPTION()) ++ { ++ goto ruleMONTHEx; ++ } ++ ++ ++ ++ } ++ break; ++ ++ } ++ } ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleMONTHEx; /* Prevent compiler warnings */ ++ ruleMONTHEx: ; ++ ++} ++// $ANTLR end MONTH ++ ++// Comes from: 113:6: ( 'year' | 'years' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start YEAR ++ * ++ * Looks to match the characters the constitute the token YEAR ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mYEAR(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = YEAR; ++ ++ ++ { ++ // RSP.g:113:6: ( 'year' | 'years' ) ++ ++ ANTLR3_UINT32 alt4; ++ ++ alt4=2; ++ ++ switch ( LA(1) ) ++ { ++ case 'y': ++ { ++ switch ( LA(2) ) ++ { ++ case 'e': ++ { ++ switch ( LA(3) ) ++ { ++ case 'a': ++ { ++ switch ( LA(4) ) ++ { ++ case 'r': ++ { ++ switch ( LA(5) ) ++ { ++ case 's': ++ { ++ alt4=2; ++ } ++ break; ++ ++ default: ++ alt4=1;} ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 4; ++ EXCEPTION->state = 3; ++ ++ ++ goto ruleYEAREx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 4; ++ EXCEPTION->state = 2; ++ ++ ++ goto ruleYEAREx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 4; ++ EXCEPTION->state = 1; ++ ++ ++ goto ruleYEAREx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 4; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleYEAREx; ++ } ++ ++ switch (alt4) ++ { ++ case 1: ++ // RSP.g:113:8: 'year' ++ { ++ MATCHS(lit_16); ++ if (HASEXCEPTION()) ++ { ++ goto ruleYEAREx; ++ } ++ ++ ++ ++ } ++ break; ++ case 2: ++ // RSP.g:113:17: 'years' ++ { ++ MATCHS(lit_17); ++ if (HASEXCEPTION()) ++ { ++ goto ruleYEAREx; ++ } ++ ++ ++ ++ } ++ break; ++ ++ } ++ } ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleYEAREx; /* Prevent compiler warnings */ ++ ruleYEAREx: ; ++ ++} ++// $ANTLR end YEAR ++ ++// Comes from: 114:7: ( 'today' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start TODAY ++ * ++ * Looks to match the characters the constitute the token TODAY ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mTODAY(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = TODAY; ++ ++ ++ // RSP.g:114:7: ( 'today' ) ++ // RSP.g:114:9: 'today' ++ { ++ MATCHS(lit_18); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTODAYEx; ++ } ++ ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleTODAYEx; /* Prevent compiler warnings */ ++ ruleTODAYEx: ; ++ ++} ++// $ANTLR end TODAY ++ ++// Comes from: 116:9: ( ( '\\r' )? '\\n' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start NEWLINE ++ * ++ * Looks to match the characters the constitute the token NEWLINE ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mNEWLINE(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = NEWLINE; ++ ++ ++ // RSP.g:116:9: ( ( '\\r' )? '\\n' ) ++ // RSP.g:116:11: ( '\\r' )? '\\n' ++ { ++ ++ // RSP.g:116:11: ( '\\r' )? ++ { ++ int alt5=2; ++ switch ( LA(1) ) ++ { ++ case '\r': ++ { ++ alt5=1; ++ } ++ break; ++ } ++ ++ switch (alt5) ++ { ++ case 1: ++ // RSP.g:116:11: '\\r' ++ { ++ MATCHC('\r'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleNEWLINEEx; ++ } ++ ++ ++ } ++ break; ++ ++ } ++ } ++ MATCHC('\n'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleNEWLINEEx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleNEWLINEEx; /* Prevent compiler warnings */ ++ ruleNEWLINEEx: ; ++ ++} ++// $ANTLR end NEWLINE ++ ++// Comes from: 118:4: ( ( ' ' | '\\t' ) ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start WS ++ * ++ * Looks to match the characters the constitute the token WS ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mWS(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = WS; ++ ++ ++ // RSP.g:118:4: ( ( ' ' | '\\t' ) ) ++ // RSP.g:118:6: ( ' ' | '\\t' ) ++ { ++ if ( LA(1) == '\t' || LA(1) == ' ' ) ++ { ++ CONSUME(); ++ ++ } ++ else ++ { ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; ++ EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; ++ ++ LRECOVER(); goto ruleWSEx; ++ } ++ ++ { ++ LEXSTATE->channel = HIDDEN; ++ } ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleWSEx; /* Prevent compiler warnings */ ++ ruleWSEx: ; ++ ++} ++// $ANTLR end WS ++ ++// Comes from: 120:7: ( 'a' .. 'z' ( 'a' .. 'z' | '_' )* 'a' .. 'z' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start FIELD ++ * ++ * Looks to match the characters the constitute the token FIELD ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mFIELD(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = FIELD; ++ ++ ++ // RSP.g:120:7: ( 'a' .. 'z' ( 'a' .. 'z' | '_' )* 'a' .. 'z' ) ++ // RSP.g:120:9: 'a' .. 'z' ( 'a' .. 'z' | '_' )* 'a' .. 'z' ++ { ++ MATCHRANGE('a', 'z'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleFIELDEx; ++ } ++ ++ ++ // RSP.g:120:18: ( 'a' .. 'z' | '_' )* ++ ++ for (;;) ++ { ++ int alt6=2; ++ switch ( LA(1) ) ++ { ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ switch ( LA(2) ) ++ { ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt6=1; ++ } ++ break; ++ ++ } ++ ++ } ++ break; ++ case '_': ++ { ++ alt6=1; ++ } ++ break; ++ ++ } ++ ++ switch (alt6) ++ { ++ case 1: ++ // RSP.g: ++ { ++ if ( LA(1) == '_' || ((LA(1) >= 'a') && (LA(1) <= 'z')) ) ++ { ++ CONSUME(); ++ ++ } ++ else ++ { ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; ++ EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; ++ ++ LRECOVER(); goto ruleFIELDEx; ++ } ++ ++ ++ } ++ break; ++ ++ default: ++ goto loop6; /* break out of the loop */ ++ break; ++ } ++ } ++ loop6: ; /* Jump out to here if this rule does not match */ ++ ++ MATCHRANGE('a', 'z'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleFIELDEx; ++ } ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleFIELDEx; /* Prevent compiler warnings */ ++ ruleFIELDEx: ; ++ ++} ++// $ANTLR end FIELD ++ ++// Comes from: 122:5: ( DIGIT19 ( DIGIT09 )* ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start INT ++ * ++ * Looks to match the characters the constitute the token INT ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mINT(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = INT; ++ ++ ++ // RSP.g:122:5: ( DIGIT19 ( DIGIT09 )* ) ++ // RSP.g:122:7: DIGIT19 ( DIGIT09 )* ++ { ++ /* 122:7: DIGIT19 ( DIGIT09 )* */ ++ mDIGIT19(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleINTEx; ++ } ++ ++ ++ // RSP.g:122:15: ( DIGIT09 )* ++ ++ for (;;) ++ { ++ int alt7=2; ++ switch ( LA(1) ) ++ { ++ case '0': ++ case '1': ++ case '2': ++ case '3': ++ case '4': ++ case '5': ++ case '6': ++ case '7': ++ case '8': ++ case '9': ++ { ++ alt7=1; ++ } ++ break; ++ ++ } ++ ++ switch (alt7) ++ { ++ case 1: ++ // RSP.g:122:15: DIGIT09 ++ { ++ /* 122:15: DIGIT09 */ ++ mDIGIT09(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleINTEx; ++ } ++ ++ ++ } ++ break; ++ ++ default: ++ goto loop7; /* break out of the loop */ ++ break; ++ } ++ } ++ loop7: ; /* Jump out to here if this rule does not match */ ++ ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleINTEx; /* Prevent compiler warnings */ ++ ruleINTEx: ; ++ ++} ++// $ANTLR end INT ++ ++// Comes from: 125:6: ( DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start DATE ++ * ++ * Looks to match the characters the constitute the token DATE ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mDATE(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ _type = DATE; ++ ++ ++ // RSP.g:125:6: ( DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) ) ++ // RSP.g:125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) ++ { ++ /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */ ++ mDIGIT19(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */ ++ mDIGIT09(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */ ++ mDIGIT09(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */ ++ mDIGIT09(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ MATCHC('-'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ ++ // RSP.g:125:44: ( '0' DIGIT19 | '1' '0' .. '2' ) ++ { ++ int alt8=2; ++ switch ( LA(1) ) ++ { ++ case '0': ++ { ++ alt8=1; ++ } ++ break; ++ case '1': ++ { ++ alt8=2; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 8; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleDATEEx; ++ } ++ ++ switch (alt8) ++ { ++ case 1: ++ // RSP.g:125:45: '0' DIGIT19 ++ { ++ MATCHC('0'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ /* 125:45: '0' DIGIT19 */ ++ mDIGIT19(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ ++ } ++ break; ++ case 2: ++ // RSP.g:125:59: '1' '0' .. '2' ++ { ++ MATCHC('1'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ MATCHRANGE('0', '2'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ ++ } ++ break; ++ ++ } ++ } ++ MATCHC('-'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ ++ // RSP.g:125:77: ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) ++ { ++ int alt9=3; ++ switch ( LA(1) ) ++ { ++ case '0': ++ { ++ alt9=1; ++ } ++ break; ++ case '1': ++ case '2': ++ { ++ alt9=2; ++ } ++ break; ++ case '3': ++ { ++ alt9=3; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 9; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleDATEEx; ++ } ++ ++ switch (alt9) ++ { ++ case 1: ++ // RSP.g:125:78: '0' DIGIT19 ++ { ++ MATCHC('0'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ /* 125:78: '0' DIGIT19 */ ++ mDIGIT19(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ ++ } ++ break; ++ case 2: ++ // RSP.g:125:92: '1' .. '2' DIGIT09 ++ { ++ MATCHRANGE('1', '2'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ /* 125:92: '1' .. '2' DIGIT09 */ ++ mDIGIT09(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ ++ } ++ break; ++ case 3: ++ // RSP.g:125:111: '3' '0' .. '1' ++ { ++ MATCHC('3'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ MATCHRANGE('0', '1'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDATEEx; ++ } ++ ++ ++ } ++ break; ++ ++ } ++ } ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleDATEEx; /* Prevent compiler warnings */ ++ ruleDATEEx: ; ++ ++} ++// $ANTLR end DATE ++ ++// Comes from: 133:2: ( QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start STR ++ * ++ * Looks to match the characters the constitute the token STR ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mSTR(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ pANTLR3_COMMON_TOKEN esc; ++ ANTLR3_UINT32 reg; ++ ++ ++ esc = NULL; ++ ++ _type = STR; ++ ++ pANTLR3_STRING unesc = GETTEXT()->factory->newRaw(GETTEXT()->factory); ++ ++ // RSP.g:133:2: ( QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE ) ++ // RSP.g:133:4: QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE ++ { ++ /* 133:4: QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE */ ++ mQUOTE(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleSTREx; ++ } ++ ++ // RSP.g:133:10: (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ ++ { ++ int cnt10=0; ++ ++ for (;;) ++ { ++ int alt10=3; ++ { ++ /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) ++ */ ++ int LA10_0 = LA(1); ++ if ( (((LA10_0 >= 0x0000) && (LA10_0 <= '!')) || ((LA10_0 >= '#') && (LA10_0 <= '[')) || ((LA10_0 >= ']') && (LA10_0 <= 0xFFFF))) ) ++ { ++ alt10=1; ++ } ++ else if ( (LA10_0 == '\\') ) ++ { ++ alt10=2; ++ } ++ ++ } ++ switch (alt10) ++ { ++ case 1: ++ // RSP.g:133:12: reg=~ ( '\\\\' | '\"' ) ++ { ++ reg= LA(1); ++ if ( ((LA(1) >= 0x0000) && (LA(1) <= '!')) || ((LA(1) >= '#') && (LA(1) <= '[')) || ((LA(1) >= ']') && (LA(1) <= 0xFFFF)) ) ++ { ++ CONSUME(); ++ ++ } ++ else ++ { ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; ++ EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; ++ ++ LRECOVER(); goto ruleSTREx; ++ } ++ ++ { ++ unesc->addc(unesc, reg); ++ } ++ ++ } ++ break; ++ case 2: ++ // RSP.g:134:6: esc= ESCAPED ++ { ++ /* 134:6: esc= ESCAPED */ ++ { ++ ANTLR3_MARKER escStart381 = GETCHARINDEX(); ++ mESCAPED(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleSTREx; ++ } ++ ++ esc = LEXSTATE->tokFactory->newToken(LEXSTATE->tokFactory); ++ esc->setType(esc, ANTLR3_TOKEN_INVALID); ++ esc->setStartIndex(esc, escStart381); ++ esc->setStopIndex(esc, GETCHARINDEX()-1); ++ esc->input = INPUT; ++ } ++ { ++ unesc->appendS(unesc, GETTEXT()); ++ } ++ ++ } ++ break; ++ ++ default: ++ ++ if ( cnt10 >= 1 ) ++ { ++ goto loop10; ++ } ++ /* mismatchedSetEx() ++ */ ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; ++ EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; ++ ++ ++ goto ruleSTREx; ++ } ++ cnt10++; ++ } ++ loop10: ; /* Jump to here if this rule does not match */ ++ } ++ /* 133:4: QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE */ ++ mQUOTE(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleSTREx; ++ } ++ ++ { ++ SETTEXT(unesc); ++ } ++ ++ } ++ ++ LEXSTATE->type = _type; ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleSTREx; /* Prevent compiler warnings */ ++ ruleSTREx: ; ++ ++ esc = NULL; ++ ++} ++// $ANTLR end STR ++ ++// Comes from: 138:9: ( '\\\\' ( '\\\\' | '\"' ) ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start ESCAPED ++ * ++ * Looks to match the characters the constitute the token ESCAPED ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mESCAPED(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ ++ // RSP.g:138:9: ( '\\\\' ( '\\\\' | '\"' ) ) ++ // RSP.g:138:11: '\\\\' ( '\\\\' | '\"' ) ++ { ++ MATCHC('\\'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleESCAPEDEx; ++ } ++ ++ ++ // RSP.g:139:3: ( '\\\\' | '\"' ) ++ { ++ int alt11=2; ++ switch ( LA(1) ) ++ { ++ case '\\': ++ { ++ alt11=1; ++ } ++ break; ++ case '"': ++ { ++ alt11=2; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 11; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleESCAPEDEx; ++ } ++ ++ switch (alt11) ++ { ++ case 1: ++ // RSP.g:139:5: '\\\\' ++ { ++ MATCHC('\\'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleESCAPEDEx; ++ } ++ ++ { ++ SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\\")); ++ } ++ ++ } ++ break; ++ case 2: ++ // RSP.g:140:5: '\"' ++ { ++ MATCHC('"'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleESCAPEDEx; ++ } ++ ++ { ++ SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\"")); ++ } ++ ++ } ++ break; ++ ++ } ++ } ++ ++ } ++ ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleESCAPEDEx; /* Prevent compiler warnings */ ++ ruleESCAPEDEx: ; ++ ++} ++// $ANTLR end ESCAPED ++ ++// Comes from: 145:9: ( '0' .. '9' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start DIGIT09 ++ * ++ * Looks to match the characters the constitute the token DIGIT09 ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mDIGIT09(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ ++ // RSP.g:145:9: ( '0' .. '9' ) ++ // RSP.g:145:11: '0' .. '9' ++ { ++ MATCHRANGE('0', '9'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDIGIT09Ex; ++ } ++ ++ ++ } ++ ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleDIGIT09Ex; /* Prevent compiler warnings */ ++ ruleDIGIT09Ex: ; ++ ++} ++// $ANTLR end DIGIT09 ++ ++// Comes from: 148:9: ( '1' .. '9' ) ++/** \brief Lexer rule generated by ANTLR3 ++ * ++ * $ANTLR start DIGIT19 ++ * ++ * Looks to match the characters the constitute the token DIGIT19 ++ * from the attached input stream. ++ * ++ * ++ * \remark ++ * - lexer->error == ANTLR3_TRUE if an exception was thrown. ++ */ ++static ANTLR3_INLINE ++void mDIGIT19(pRSPLexer ctx) ++{ ++ ANTLR3_UINT32 _type; ++ ++ ++ // RSP.g:148:9: ( '1' .. '9' ) ++ // RSP.g:148:11: '1' .. '9' ++ { ++ MATCHRANGE('1', '9'); ++ if (HASEXCEPTION()) ++ { ++ goto ruleDIGIT19Ex; ++ } ++ ++ ++ } ++ ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleDIGIT19Ex; /* Prevent compiler warnings */ ++ ruleDIGIT19Ex: ; ++ ++} ++// $ANTLR end DIGIT19 ++ ++/** This is the entry point in to the lexer from an object that ++ * wants to generate the next token, such as a pCOMMON_TOKEN_STREAM ++ */ ++static void ++mTokens(pRSPLexer ctx) ++{ ++ { ++ // RSP.g:1:8: ( QUOTE | LPAR | RPAR | AND | OR | NOT | EQUAL | INCLUDES | STARTSW | ENDSW | GREATER | LESS | GTE | LTE | BEFORE | AFTER | DAY | WEEK | MONTH | YEAR | TODAY | NEWLINE | WS | FIELD | INT | DATE | STR ) ++ ++ ANTLR3_UINT32 alt12; ++ ++ alt12=27; ++ ++ switch ( LA(1) ) ++ { ++ case '"': ++ { ++ ++ { ++ int LA12_1 = LA(2); ++ if ( (((LA12_1 >= 0x0000) && (LA12_1 <= '!')) || ((LA12_1 >= '#') && (LA12_1 <= 0xFFFF))) ) ++ { ++ alt12=27; ++ } ++ else ++ { ++ alt12=1; } ++ } ++ } ++ break; ++ case '(': ++ { ++ alt12=2; ++ } ++ break; ++ case ')': ++ { ++ alt12=3; ++ } ++ break; ++ case 'a': ++ { ++ switch ( LA(2) ) ++ { ++ case 'n': ++ { ++ switch ( LA(3) ) ++ { ++ case 'd': ++ { ++ switch ( LA(4) ) ++ { ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=4;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ case 'f': ++ { ++ switch ( LA(3) ) ++ { ++ case 't': ++ { ++ switch ( LA(4) ) ++ { ++ case 'e': ++ { ++ switch ( LA(5) ) ++ { ++ case 'r': ++ { ++ switch ( LA(6) ) ++ { ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=16;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 12; ++ EXCEPTION->state = 4; ++ ++ ++ goto ruleTokensEx; ++ } ++ ++ } ++ break; ++ case 'o': ++ { ++ switch ( LA(2) ) ++ { ++ case 'r': ++ { ++ switch ( LA(3) ) ++ { ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=5;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 12; ++ EXCEPTION->state = 5; ++ ++ ++ goto ruleTokensEx; ++ } ++ ++ } ++ break; ++ case '!': ++ { ++ alt12=6; ++ } ++ break; ++ case '=': ++ { ++ alt12=7; ++ } ++ break; ++ case 'i': ++ { ++ switch ( LA(2) ) ++ { ++ case 'n': ++ { ++ switch ( LA(3) ) ++ { ++ case 'c': ++ { ++ switch ( LA(4) ) ++ { ++ case 'l': ++ { ++ switch ( LA(5) ) ++ { ++ case 'u': ++ { ++ switch ( LA(6) ) ++ { ++ case 'd': ++ { ++ switch ( LA(7) ) ++ { ++ case 'e': ++ { ++ switch ( LA(8) ) ++ { ++ case 's': ++ { ++ switch ( LA(9) ) ++ { ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=8;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 12; ++ EXCEPTION->state = 8; ++ ++ ++ goto ruleTokensEx; ++ } ++ ++ } ++ break; ++ case 's': ++ { ++ switch ( LA(2) ) ++ { ++ case 't': ++ { ++ switch ( LA(3) ) ++ { ++ case 'a': ++ { ++ switch ( LA(4) ) ++ { ++ case 'r': ++ { ++ switch ( LA(5) ) ++ { ++ case 't': ++ { ++ switch ( LA(6) ) ++ { ++ case 's': ++ { ++ switch ( LA(7) ) ++ { ++ case 'w': ++ { ++ switch ( LA(8) ) ++ { ++ case 'i': ++ { ++ switch ( LA(9) ) ++ { ++ case 't': ++ { ++ switch ( LA(10) ) ++ { ++ case 'h': ++ { ++ switch ( LA(11) ) ++ { ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=9;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 12; ++ EXCEPTION->state = 9; ++ ++ ++ goto ruleTokensEx; ++ } ++ ++ } ++ break; ++ case 'e': ++ { ++ switch ( LA(2) ) ++ { ++ case 'n': ++ { ++ switch ( LA(3) ) ++ { ++ case 'd': ++ { ++ switch ( LA(4) ) ++ { ++ case 's': ++ { ++ switch ( LA(5) ) ++ { ++ case 'w': ++ { ++ switch ( LA(6) ) ++ { ++ case 'i': ++ { ++ switch ( LA(7) ) ++ { ++ case 't': ++ { ++ switch ( LA(8) ) ++ { ++ case 'h': ++ { ++ switch ( LA(9) ) ++ { ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=10;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 12; ++ EXCEPTION->state = 10; ++ ++ ++ goto ruleTokensEx; ++ } ++ ++ } ++ break; ++ case '>': ++ { ++ switch ( LA(2) ) ++ { ++ case '=': ++ { ++ alt12=13; ++ } ++ break; ++ ++ default: ++ alt12=11;} ++ ++ } ++ break; ++ case '<': ++ { ++ switch ( LA(2) ) ++ { ++ case '=': ++ { ++ alt12=14; ++ } ++ break; ++ ++ default: ++ alt12=12;} ++ ++ } ++ break; ++ case 'b': ++ { ++ switch ( LA(2) ) ++ { ++ case 'e': ++ { ++ switch ( LA(3) ) ++ { ++ case 'f': ++ { ++ switch ( LA(4) ) ++ { ++ case 'o': ++ { ++ switch ( LA(5) ) ++ { ++ case 'r': ++ { ++ switch ( LA(6) ) ++ { ++ case 'e': ++ { ++ switch ( LA(7) ) ++ { ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=15;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 12; ++ EXCEPTION->state = 13; ++ ++ ++ goto ruleTokensEx; ++ } ++ ++ } ++ break; ++ case 'd': ++ { ++ switch ( LA(2) ) ++ { ++ case 'a': ++ { ++ switch ( LA(3) ) ++ { ++ case 'y': ++ { ++ switch ( LA(4) ) ++ { ++ case 's': ++ { ++ switch ( LA(5) ) ++ { ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=17;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=17;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ case '_': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 12; ++ EXCEPTION->state = 14; ++ ++ ++ goto ruleTokensEx; ++ } ++ ++ } ++ break; ++ case 'w': ++ { ++ switch ( LA(2) ) ++ { ++ case 'e': ++ { ++ switch ( LA(3) ) ++ { ++ case 'e': ++ { ++ switch ( LA(4) ) ++ { ++ case 'k': ++ { ++ switch ( LA(5) ) ++ { ++ case 's': ++ { ++ switch ( LA(6) ) ++ { ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=18;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=18;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 12; ++ EXCEPTION->state = 15; ++ ++ ++ goto ruleTokensEx; ++ } ++ ++ } ++ break; ++ case 'm': ++ { ++ switch ( LA(2) ) ++ { ++ case 'o': ++ { ++ switch ( LA(3) ) ++ { ++ case 'n': ++ { ++ switch ( LA(4) ) ++ { ++ case 't': ++ { ++ switch ( LA(5) ) ++ { ++ case 'h': ++ { ++ switch ( LA(6) ) ++ { ++ case 's': ++ { ++ switch ( LA(7) ) ++ { ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=19;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=19;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 12; ++ EXCEPTION->state = 16; ++ ++ ++ goto ruleTokensEx; ++ } ++ ++ } ++ break; ++ case 'y': ++ { ++ switch ( LA(2) ) ++ { ++ case 'e': ++ { ++ switch ( LA(3) ) ++ { ++ case 'a': ++ { ++ switch ( LA(4) ) ++ { ++ case 'r': ++ { ++ switch ( LA(5) ) ++ { ++ case 's': ++ { ++ switch ( LA(6) ) ++ { ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=20;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=20;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 12; ++ EXCEPTION->state = 17; ++ ++ ++ goto ruleTokensEx; ++ } ++ ++ } ++ break; ++ case 't': ++ { ++ switch ( LA(2) ) ++ { ++ case 'o': ++ { ++ switch ( LA(3) ) ++ { ++ case 'd': ++ { ++ switch ( LA(4) ) ++ { ++ case 'a': ++ { ++ switch ( LA(5) ) ++ { ++ case 'y': ++ { ++ switch ( LA(6) ) ++ { ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ alt12=21;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ ++ default: ++ alt12=24;} ++ ++ } ++ break; ++ case '_': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 12; ++ EXCEPTION->state = 18; ++ ++ ++ goto ruleTokensEx; ++ } ++ ++ } ++ break; ++ case '\n': ++ case '\r': ++ { ++ alt12=22; ++ } ++ break; ++ case '\t': ++ case ' ': ++ { ++ alt12=23; ++ } ++ break; ++ case 'c': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'n': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 'u': ++ case 'v': ++ case 'x': ++ case 'z': ++ { ++ alt12=24; ++ } ++ break; ++ case '1': ++ case '2': ++ case '3': ++ case '4': ++ case '5': ++ case '6': ++ case '7': ++ case '8': ++ case '9': ++ { ++ switch ( LA(2) ) ++ { ++ case '0': ++ case '1': ++ case '2': ++ case '3': ++ case '4': ++ case '5': ++ case '6': ++ case '7': ++ case '8': ++ case '9': ++ { ++ switch ( LA(3) ) ++ { ++ case '0': ++ case '1': ++ case '2': ++ case '3': ++ case '4': ++ case '5': ++ case '6': ++ case '7': ++ case '8': ++ case '9': ++ { ++ switch ( LA(4) ) ++ { ++ case '0': ++ case '1': ++ case '2': ++ case '3': ++ case '4': ++ case '5': ++ case '6': ++ case '7': ++ case '8': ++ case '9': ++ { ++ switch ( LA(5) ) ++ { ++ case '-': ++ { ++ alt12=26; ++ } ++ break; ++ ++ default: ++ alt12=25;} ++ ++ } ++ break; ++ ++ default: ++ alt12=25;} ++ ++ } ++ break; ++ ++ default: ++ alt12=25;} ++ ++ } ++ break; ++ ++ default: ++ alt12=25;} ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 12; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleTokensEx; ++ } ++ ++ switch (alt12) ++ { ++ case 1: ++ // RSP.g:1:10: QUOTE ++ { ++ /* 1:10: QUOTE */ ++ mQUOTE(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 2: ++ // RSP.g:1:16: LPAR ++ { ++ /* 1:16: LPAR */ ++ mLPAR(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 3: ++ // RSP.g:1:21: RPAR ++ { ++ /* 1:21: RPAR */ ++ mRPAR(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 4: ++ // RSP.g:1:26: AND ++ { ++ /* 1:26: AND */ ++ mAND(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 5: ++ // RSP.g:1:30: OR ++ { ++ /* 1:30: OR */ ++ mOR(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 6: ++ // RSP.g:1:33: NOT ++ { ++ /* 1:33: NOT */ ++ mNOT(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 7: ++ // RSP.g:1:37: EQUAL ++ { ++ /* 1:37: EQUAL */ ++ mEQUAL(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 8: ++ // RSP.g:1:43: INCLUDES ++ { ++ /* 1:43: INCLUDES */ ++ mINCLUDES(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 9: ++ // RSP.g:1:52: STARTSW ++ { ++ /* 1:52: STARTSW */ ++ mSTARTSW(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 10: ++ // RSP.g:1:60: ENDSW ++ { ++ /* 1:60: ENDSW */ ++ mENDSW(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 11: ++ // RSP.g:1:66: GREATER ++ { ++ /* 1:66: GREATER */ ++ mGREATER(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 12: ++ // RSP.g:1:74: LESS ++ { ++ /* 1:74: LESS */ ++ mLESS(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 13: ++ // RSP.g:1:79: GTE ++ { ++ /* 1:79: GTE */ ++ mGTE(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 14: ++ // RSP.g:1:83: LTE ++ { ++ /* 1:83: LTE */ ++ mLTE(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 15: ++ // RSP.g:1:87: BEFORE ++ { ++ /* 1:87: BEFORE */ ++ mBEFORE(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 16: ++ // RSP.g:1:94: AFTER ++ { ++ /* 1:94: AFTER */ ++ mAFTER(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 17: ++ // RSP.g:1:100: DAY ++ { ++ /* 1:100: DAY */ ++ mDAY(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 18: ++ // RSP.g:1:104: WEEK ++ { ++ /* 1:104: WEEK */ ++ mWEEK(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 19: ++ // RSP.g:1:109: MONTH ++ { ++ /* 1:109: MONTH */ ++ mMONTH(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 20: ++ // RSP.g:1:115: YEAR ++ { ++ /* 1:115: YEAR */ ++ mYEAR(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 21: ++ // RSP.g:1:120: TODAY ++ { ++ /* 1:120: TODAY */ ++ mTODAY(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 22: ++ // RSP.g:1:126: NEWLINE ++ { ++ /* 1:126: NEWLINE */ ++ mNEWLINE(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 23: ++ // RSP.g:1:134: WS ++ { ++ /* 1:134: WS */ ++ mWS(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 24: ++ // RSP.g:1:137: FIELD ++ { ++ /* 1:137: FIELD */ ++ mFIELD(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 25: ++ // RSP.g:1:143: INT ++ { ++ /* 1:143: INT */ ++ mINT(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 26: ++ // RSP.g:1:147: DATE ++ { ++ /* 1:147: DATE */ ++ mDATE(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ case 27: ++ // RSP.g:1:152: STR ++ { ++ /* 1:152: STR */ ++ mSTR(ctx ); ++ if (HASEXCEPTION()) ++ { ++ goto ruleTokensEx; ++ } ++ ++ ++ } ++ break; ++ ++ } ++ } ++ ++ ++ goto ruleTokensEx; /* Prevent compiler warnings */ ++ruleTokensEx: ; ++} ++ ++/* ========================================================================= ++ * Lexer matching rules end. ++ * ========================================================================= ++ */ ++/* End of Lexer code ++ * ================================================ ++ * ================================================ ++ */ ++ ++ ++/* End of code ++ * ============================================================================= ++ */ +diff --git a/src/pregen/RSPLexer.h b/src/pregen/RSPLexer.h +new file mode 100644 +index 0000000..4f4d06b +--- /dev/null ++++ b/src/pregen/RSPLexer.h +@@ -0,0 +1,254 @@ ++/** \file ++ * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3 ++ * ++ * - From the grammar source file : RSP.g ++ * - On : 2014-09-30 21:42:41 ++ * - for the lexer : RSPLexerLexer * ++ * Editing it, at least manually, is not wise. ++ * ++ * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. ++ * ++ * ++ * The lexer RSPLexer has the callable functions (rules) shown below, ++ * which will invoke the code for the associated rule in the source grammar ++ * assuming that the input stream is pointing to a token/text stream that could begin ++ * this rule. ++ * ++ * For instance if you call the first (topmost) rule in a parser grammar, you will ++ * get the results of a full parse, but calling a rule half way through the grammar will ++ * allow you to pass part of a full token stream to the parser, such as for syntax checking ++ * in editors and so on. ++ * ++ * The parser entry points are called indirectly (by function pointer to function) via ++ * a parser context typedef pRSPLexer, which is returned from a call to RSPLexerNew(). ++ * ++ * As this is a generated lexer, it is unlikely you will call it 'manually'. However ++ * the methods are provided anyway. ++ * * The methods in pRSPLexer are as follows: ++ * ++ * - void pRSPLexer->QUOTE(pRSPLexer) ++ * - void pRSPLexer->LPAR(pRSPLexer) ++ * - void pRSPLexer->RPAR(pRSPLexer) ++ * - void pRSPLexer->AND(pRSPLexer) ++ * - void pRSPLexer->OR(pRSPLexer) ++ * - void pRSPLexer->NOT(pRSPLexer) ++ * - void pRSPLexer->EQUAL(pRSPLexer) ++ * - void pRSPLexer->INCLUDES(pRSPLexer) ++ * - void pRSPLexer->STARTSW(pRSPLexer) ++ * - void pRSPLexer->ENDSW(pRSPLexer) ++ * - void pRSPLexer->GREATER(pRSPLexer) ++ * - void pRSPLexer->LESS(pRSPLexer) ++ * - void pRSPLexer->GTE(pRSPLexer) ++ * - void pRSPLexer->LTE(pRSPLexer) ++ * - void pRSPLexer->BEFORE(pRSPLexer) ++ * - void pRSPLexer->AFTER(pRSPLexer) ++ * - void pRSPLexer->DAY(pRSPLexer) ++ * - void pRSPLexer->WEEK(pRSPLexer) ++ * - void pRSPLexer->MONTH(pRSPLexer) ++ * - void pRSPLexer->YEAR(pRSPLexer) ++ * - void pRSPLexer->TODAY(pRSPLexer) ++ * - void pRSPLexer->NEWLINE(pRSPLexer) ++ * - void pRSPLexer->WS(pRSPLexer) ++ * - void pRSPLexer->FIELD(pRSPLexer) ++ * - void pRSPLexer->INT(pRSPLexer) ++ * - void pRSPLexer->DATE(pRSPLexer) ++ * - void pRSPLexer->STR(pRSPLexer) ++ * - void pRSPLexer->ESCAPED(pRSPLexer) ++ * - void pRSPLexer->DIGIT09(pRSPLexer) ++ * - void pRSPLexer->DIGIT19(pRSPLexer) ++ * - void pRSPLexer->Tokens(pRSPLexer) ++ * ++ * The return type for any particular rule is of course determined by the source ++ * grammar file. ++ */ ++// [The "BSD licence"] ++// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC ++// http://www.temporal-wave.com ++// http://www.linkedin.com/in/jimidle ++// ++// All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions ++// are met: ++// 1. Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// 2. Redistributions in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// 3. The name of the author may not be used to endorse or promote products ++// derived from this software without specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++#ifndef _RSPLexer_H ++#define _RSPLexer_H ++/* ============================================================================= ++ * Standard antlr3 C runtime definitions ++ */ ++#include ++ ++/* End of standard antlr 3 runtime definitions ++ * ============================================================================= ++ */ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++// Forward declare the context typedef so that we can use it before it is ++// properly defined. Delegators and delegates (from import statements) are ++// interdependent and their context structures contain pointers to each other ++// C only allows such things to be declared if you pre-declare the typedef. ++// ++typedef struct RSPLexer_Ctx_struct RSPLexer, * pRSPLexer; ++ ++ ++ ++#ifdef ANTLR3_WINDOWS ++// Disable: Unreferenced parameter, - Rules with parameters that are not used ++// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) ++// initialized but unused variable - tree rewrite variables declared but not needed ++// Unreferenced local variable - lexer rule declares but does not always use _type ++// potentially unitialized variable used - retval always returned from a rule ++// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns ++// ++// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at ++// and the codegen must generate some of these warnings by necessity, apart from 4100, which is ++// usually generated when a parser rule is given a parameter that it does not use. Mostly though ++// this is a matter of orthogonality hence I disable that one. ++// ++#pragma warning( disable : 4100 ) ++#pragma warning( disable : 4101 ) ++#pragma warning( disable : 4127 ) ++#pragma warning( disable : 4189 ) ++#pragma warning( disable : 4505 ) ++#pragma warning( disable : 4701 ) ++#endif ++ ++/** Context tracking structure for RSPLexer ++ */ ++struct RSPLexer_Ctx_struct ++{ ++ /** Built in ANTLR3 context tracker contains all the generic elements ++ * required for context tracking. ++ */ ++ pANTLR3_LEXER pLexer; ++ ++ ++ void (*mQUOTE) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mLPAR) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mRPAR) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mAND) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mOR) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mNOT) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mEQUAL) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mINCLUDES) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mSTARTSW) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mENDSW) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mGREATER) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mLESS) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mGTE) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mLTE) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mBEFORE) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mAFTER) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mDAY) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mWEEK) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mMONTH) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mYEAR) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mTODAY) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mNEWLINE) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mWS) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mFIELD) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mINT) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mDATE) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mSTR) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mESCAPED) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mDIGIT09) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mDIGIT19) (struct RSPLexer_Ctx_struct * ctx); ++ void (*mTokens) (struct RSPLexer_Ctx_struct * ctx); const char * (*getGrammarFileName)(); ++ void (*free) (struct RSPLexer_Ctx_struct * ctx); ++ ++}; ++ ++// Function protoypes for the constructor functions that external translation units ++// such as delegators and delegates may wish to call. ++// ++ANTLR3_API pRSPLexer RSPLexerNew (pANTLR3_INPUT_STREAM instream); ++ANTLR3_API pRSPLexer RSPLexerNewSSD (pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); ++ ++/** Symbolic definitions of all the tokens that the lexer will work with. ++ * \{ ++ * ++ * Antlr will define EOF, but we can't use that as it it is too common in ++ * in C header files and that would be confusing. There is no way to filter this out at the moment ++ * so we just undef it here for now. That isn't the value we get back from C recognizers ++ * anyway. We are looking for ANTLR3_TOKEN_EOF. ++ */ ++#ifdef EOF ++#undef EOF ++#endif ++#ifdef Tokens ++#undef Tokens ++#endif ++#define STARTSW 14 ++#define WEEK 26 ++#define TODAY 24 ++#define YEAR 28 ++#define ENDSW 15 ++#define GTE 20 ++#define BEFORE 21 ++#define DAY 25 ++#define INT 16 ++#define NOT 11 ++#define AFTER 22 ++#define AND 6 ++#define EOF -1 ++#define LTE 19 ++#define MONTH 27 ++#define DIGIT19 31 ++#define INCLUDES 13 ++#define STR 10 ++#define QUOTE 29 ++#define GREATER 18 ++#define WS 30 ++#define LPAR 7 ++#define NEWLINE 4 ++#define EQUAL 12 ++#define OR 5 ++#define LESS 17 ++#define FIELD 9 ++#define RPAR 8 ++#define ESCAPED 33 ++#define DATE 23 ++#define DIGIT09 32 ++#ifdef EOF ++#undef EOF ++#define EOF ANTLR3_TOKEN_EOF ++#endif ++ ++#ifndef TOKENSOURCE ++#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource ++#endif ++ ++/* End of token definitions for RSPLexer ++ * ============================================================================= ++ */ ++/** \} */ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif ++ ++/* END - Note:Keep extra line feed to satisfy UNIX systems */ +diff --git a/src/pregen/RSPParser.c b/src/pregen/RSPParser.c +new file mode 100644 +index 0000000..c538e49 +--- /dev/null ++++ b/src/pregen/RSPParser.c +@@ -0,0 +1,2684 @@ ++/** \file ++ * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3 ++ * ++ * - From the grammar source file : RSP.g ++ * - On : 2014-09-30 21:42:40 ++ * - for the parser : RSPParserParser * ++ * Editing it, at least manually, is not wise. ++ * ++ * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. ++ * ++ * ++*/ ++// [The "BSD licence"] ++// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC ++// http://www.temporal-wave.com ++// http://www.linkedin.com/in/jimidle ++// ++// All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions ++// are met: ++// 1. Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// 2. Redistributions in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// 3. The name of the author may not be used to endorse or promote products ++// derived from this software without specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++/* ----------------------------------------- ++ * Include the ANTLR3 generated header file. ++ */ ++#include "RSPParser.h" ++/* ----------------------------------------- */ ++ ++ ++ ++ ++ ++/* MACROS that hide the C interface implementations from the ++ * generated code, which makes it a little more understandable to the human eye. ++ * I am very much against using C pre-processor macros for function calls and bits ++ * of code as you cannot see what is happening when single stepping in debuggers ++ * and so on. The exception (in my book at least) is for generated code, where you are ++ * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() ++ * hides some indirect calls, but is always referring to the input stream. This is ++ * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig ++ * the runtime interfaces without changing the generated code too often, without ++ * confusing the reader of the generated output, who may not wish to know the gory ++ * details of the interface inheritance. ++ */ ++ ++#define CTX ctx ++ ++/* Aids in accessing scopes for grammar programmers ++ */ ++#undef SCOPE_TYPE ++#undef SCOPE_STACK ++#undef SCOPE_TOP ++#define SCOPE_TYPE(scope) pRSPParser_##scope##_SCOPE ++#define SCOPE_STACK(scope) pRSPParser_##scope##Stack ++#define SCOPE_TOP(scope) ctx->pRSPParser_##scope##Top ++#define SCOPE_SIZE(scope) ctx->pRSPParser_##scope##Stack_limit ++#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) ++ ++/* Macros for accessing things in the parser ++ */ ++ ++#undef PARSER ++#undef RECOGNIZER ++#undef HAVEPARSEDRULE ++#undef MEMOIZE ++#undef INPUT ++#undef STRSTREAM ++#undef HASEXCEPTION ++#undef EXCEPTION ++#undef MATCHT ++#undef MATCHANYT ++#undef FOLLOWSTACK ++#undef FOLLOWPUSH ++#undef FOLLOWPOP ++#undef PRECOVER ++#undef PREPORTERROR ++#undef LA ++#undef LT ++#undef CONSTRUCTEX ++#undef CONSUME ++#undef MARK ++#undef REWIND ++#undef REWINDLAST ++#undef PERRORRECOVERY ++#undef HASFAILED ++#undef FAILEDFLAG ++#undef RECOVERFROMMISMATCHEDSET ++#undef RECOVERFROMMISMATCHEDELEMENT ++#undef INDEX ++#undef ADAPTOR ++#undef SEEK ++#undef RULEMEMO ++#undef DBG ++ ++#define PARSER ctx->pParser ++#define RECOGNIZER PARSER->rec ++#define PSRSTATE RECOGNIZER->state ++#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) ++#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si) ++#define INPUT PARSER->tstream ++#define STRSTREAM INPUT ++#define ISTREAM INPUT->istream ++#define INDEX() ISTREAM->index(INPUT->istream) ++#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE) ++#define EXCEPTION PSRSTATE->exception ++#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs) ++#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER) ++#define FOLLOWSTACK PSRSTATE->following ++#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL) ++#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK) ++#define PRECOVER() RECOGNIZER->recover(RECOGNIZER) ++#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER) ++#define LA(n) INPUT->istream->_LA(ISTREAM, n) ++#define LT(n) INPUT->_LT(INPUT, n) ++#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) ++#define CONSUME() ISTREAM->consume(ISTREAM) ++#define MARK() ISTREAM->mark(ISTREAM) ++#define REWIND(m) ISTREAM->rewind(ISTREAM, m) ++#define REWINDLAST() ISTREAM->rewindLast(ISTREAM) ++#define SEEK(n) ISTREAM->seek(ISTREAM, n) ++#define PERRORRECOVERY PSRSTATE->errorRecovery ++#define FAILEDFLAG PSRSTATE->failed ++#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE) ++#define BACKTRACKING PSRSTATE->backtracking ++#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s) ++#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s) ++#define ADAPTOR ctx->adaptor ++#define RULEMEMO PSRSTATE->ruleMemo ++#define DBG RECOGNIZER->debugger ++ ++#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt ++ ++/* The 4 tokens defined below may well clash with your own #defines or token types. If so ++ * then for the present you must use different names for your defines as these are hard coded ++ * in the code generator. It would be better not to use such names internally, and maybe ++ * we can change this in a forthcoming release. I deliberately do not #undef these ++ * here as this will at least give you a redefined error somewhere if they clash. ++ */ ++#define UP ANTLR3_TOKEN_UP ++#define DOWN ANTLR3_TOKEN_DOWN ++#define EOR ANTLR3_TOKEN_EOR ++#define INVALID ANTLR3_TOKEN_INVALID ++ ++ ++/* ============================================================================= ++ * Functions to create and destroy scopes. First come the rule scopes, followed ++ * by the global declared scopes. ++ */ ++ ++ ++ ++/* ============================================================================= */ ++ ++/* ============================================================================= ++ * Start of recognizer ++ */ ++ ++ ++ ++/** \brief Table of all token names in symbolic order, mainly used for ++ * error reporting. ++ */ ++pANTLR3_UINT8 RSPParserTokenNames[30+4] ++ = { ++ (pANTLR3_UINT8) "", /* String to print to indicate an invalid token */ ++ (pANTLR3_UINT8) "", ++ (pANTLR3_UINT8) "", ++ (pANTLR3_UINT8) "", ++ (pANTLR3_UINT8) "NEWLINE", ++ (pANTLR3_UINT8) "OR", ++ (pANTLR3_UINT8) "AND", ++ (pANTLR3_UINT8) "LPAR", ++ (pANTLR3_UINT8) "RPAR", ++ (pANTLR3_UINT8) "FIELD", ++ (pANTLR3_UINT8) "STR", ++ (pANTLR3_UINT8) "NOT", ++ (pANTLR3_UINT8) "EQUAL", ++ (pANTLR3_UINT8) "INCLUDES", ++ (pANTLR3_UINT8) "STARTSW", ++ (pANTLR3_UINT8) "ENDSW", ++ (pANTLR3_UINT8) "INT", ++ (pANTLR3_UINT8) "LESS", ++ (pANTLR3_UINT8) "GREATER", ++ (pANTLR3_UINT8) "LTE", ++ (pANTLR3_UINT8) "GTE", ++ (pANTLR3_UINT8) "BEFORE", ++ (pANTLR3_UINT8) "AFTER", ++ (pANTLR3_UINT8) "DATE", ++ (pANTLR3_UINT8) "TODAY", ++ (pANTLR3_UINT8) "DAY", ++ (pANTLR3_UINT8) "WEEK", ++ (pANTLR3_UINT8) "MONTH", ++ (pANTLR3_UINT8) "YEAR", ++ (pANTLR3_UINT8) "QUOTE", ++ (pANTLR3_UINT8) "WS", ++ (pANTLR3_UINT8) "DIGIT19", ++ (pANTLR3_UINT8) "DIGIT09", ++ (pANTLR3_UINT8) "ESCAPED" ++ }; ++ ++ ++ ++// Forward declare the locally static matching functions we have generated. ++// ++static RSPParser_query_return query (pRSPParser ctx); ++static RSPParser_expr_return expr (pRSPParser ctx); ++static RSPParser_aexpr_return aexpr (pRSPParser ctx); ++static RSPParser_crit_return crit (pRSPParser ctx); ++static RSPParser_strcrit_return strcrit (pRSPParser ctx); ++static RSPParser_strop_return strop (pRSPParser ctx); ++static RSPParser_intcrit_return intcrit (pRSPParser ctx); ++static RSPParser_intop_return intop (pRSPParser ctx); ++static RSPParser_datecrit_return datecrit (pRSPParser ctx); ++static RSPParser_dateop_return dateop (pRSPParser ctx); ++static RSPParser_datespec_return datespec (pRSPParser ctx); ++static RSPParser_dateref_return dateref (pRSPParser ctx); ++static RSPParser_dateintval_return dateintval (pRSPParser ctx); ++static void RSPParserFree(pRSPParser ctx); ++/* For use in tree output where we are accumulating rule labels via label += ruleRef ++ * we need a function that knows how to free a return scope when the list is destroyed. ++ * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro. ++ */ ++static void ANTLR3_CDECL freeScope(void * scope) ++{ ++ ANTLR3_FREE(scope); ++} ++ ++/** \brief Name of the grammar file that generated this code ++ */ ++static const char fileName[] = "RSP.g"; ++ ++/** \brief Return the name of the grammar file that generated this code. ++ */ ++static const char * getGrammarFileName() ++{ ++ return fileName; ++} ++/** \brief Create a new RSPParser parser and return a context for it. ++ * ++ * \param[in] instream Pointer to an input stream interface. ++ * ++ * \return Pointer to new parser context upon success. ++ */ ++ANTLR3_API pRSPParser ++RSPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream) ++{ ++ // See if we can create a new parser with the standard constructor ++ // ++ return RSPParserNewSSD(instream, NULL); ++} ++ ++/** \brief Create a new RSPParser parser and return a context for it. ++ * ++ * \param[in] instream Pointer to an input stream interface. ++ * ++ * \return Pointer to new parser context upon success. ++ */ ++ANTLR3_API pRSPParser ++RSPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) ++{ ++ pRSPParser ctx; /* Context structure we will build and return */ ++ ++ ctx = (pRSPParser) ANTLR3_CALLOC(1, sizeof(RSPParser)); ++ ++ if (ctx == NULL) ++ { ++ // Failed to allocate memory for parser context ++ // ++ return NULL; ++ } ++ ++ /* ------------------------------------------------------------------- ++ * Memory for basic structure is allocated, now to fill in ++ * the base ANTLR3 structures. We initialize the function pointers ++ * for the standard ANTLR3 parser function set, but upon return ++ * from here, the programmer may set the pointers to provide custom ++ * implementations of each function. ++ * ++ * We don't use the macros defined in RSPParser.h here, in order that you can get a sense ++ * of what goes where. ++ */ ++ ++ /* Create a base parser/recognizer, using the supplied token stream ++ */ ++ ctx->pParser = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state); ++ /* Install the implementation of our RSPParser interface ++ */ ++ ctx->query = query; ++ ctx->expr = expr; ++ ctx->aexpr = aexpr; ++ ctx->crit = crit; ++ ctx->strcrit = strcrit; ++ ctx->strop = strop; ++ ctx->intcrit = intcrit; ++ ctx->intop = intop; ++ ctx->datecrit = datecrit; ++ ctx->dateop = dateop; ++ ctx->datespec = datespec; ++ ctx->dateref = dateref; ++ ctx->dateintval = dateintval; ++ ctx->free = RSPParserFree; ++ ctx->getGrammarFileName = getGrammarFileName; ++ ++ /* Install the scope pushing methods. ++ */ ++ ADAPTOR = ANTLR3_TREE_ADAPTORNew(instream->tstream->tokenSource->strFactory); ++ ctx->vectors = antlr3VectorFactoryNew(0); ++ ++ ++ ++ /* Install the token table ++ */ ++ PSRSTATE->tokenNames = RSPParserTokenNames; ++ ++ ++ /* Return the newly built parser to the caller ++ */ ++ return ctx; ++} ++ ++/** Free the parser resources ++ */ ++ static void ++ RSPParserFree(pRSPParser ctx) ++ { ++ /* Free any scope memory ++ */ ++ ++ ctx->vectors->close(ctx->vectors); ++ /* We created the adaptor so we must free it ++ */ ++ ADAPTOR->free(ADAPTOR); ++ // Free this parser ++ // ++ ctx->pParser->free(ctx->pParser); ++ ANTLR3_FREE(ctx); ++ ++ /* Everything is released, so we can return ++ */ ++ return; ++ } ++ ++/** Return token names used by this parser ++ * ++ * The returned pointer is used as an index into the token names table (using the token ++ * number as the index). ++ * ++ * \return Pointer to first char * in the table. ++ */ ++static pANTLR3_UINT8 *getTokenNames() ++{ ++ return RSPParserTokenNames; ++} ++ ++ ++/* Declare the bitsets ++ */ ++ ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query42 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_query42_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000010) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_query42 = { FOLLOW_expr_in_query42_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_NEWLINE_in_query44 */ ++static ANTLR3_BITWORD FOLLOW_NEWLINE_in_query44_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000000) }; ++static ANTLR3_BITSET_LIST FOLLOW_NEWLINE_in_query44 = { FOLLOW_NEWLINE_in_query44_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_EOF_in_query47 */ ++static ANTLR3_BITWORD FOLLOW_EOF_in_query47_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_EOF_in_query47 = { FOLLOW_EOF_in_query47_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr63 */ ++static ANTLR3_BITWORD FOLLOW_aexpr_in_expr63_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) }; ++static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr63 = { FOLLOW_aexpr_in_expr63_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_OR_in_expr66 */ ++static ANTLR3_BITWORD FOLLOW_OR_in_expr66_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) }; ++static ANTLR3_BITSET_LIST FOLLOW_OR_in_expr66 = { FOLLOW_OR_in_expr66_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr69 */ ++static ANTLR3_BITWORD FOLLOW_aexpr_in_expr69_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) }; ++static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr69 = { FOLLOW_aexpr_in_expr69_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr81 */ ++static ANTLR3_BITWORD FOLLOW_crit_in_aexpr81_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) }; ++static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr81 = { FOLLOW_crit_in_aexpr81_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_AND_in_aexpr84 */ ++static ANTLR3_BITWORD FOLLOW_AND_in_aexpr84_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) }; ++static ANTLR3_BITSET_LIST FOLLOW_AND_in_aexpr84 = { FOLLOW_AND_in_aexpr84_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr87 */ ++static ANTLR3_BITWORD FOLLOW_crit_in_aexpr87_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) }; ++static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr87 = { FOLLOW_crit_in_aexpr87_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_LPAR_in_crit99 */ ++static ANTLR3_BITWORD FOLLOW_LPAR_in_crit99_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) }; ++static ANTLR3_BITSET_LIST FOLLOW_LPAR_in_crit99 = { FOLLOW_LPAR_in_crit99_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_crit101 */ ++static ANTLR3_BITWORD FOLLOW_expr_in_crit101_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000100) }; ++static ANTLR3_BITSET_LIST FOLLOW_expr_in_crit101 = { FOLLOW_expr_in_crit101_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_RPAR_in_crit103 */ ++static ANTLR3_BITWORD FOLLOW_RPAR_in_crit103_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_RPAR_in_crit103 = { FOLLOW_RPAR_in_crit103_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_strcrit_in_crit114 */ ++static ANTLR3_BITWORD FOLLOW_strcrit_in_crit114_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_strcrit_in_crit114 = { FOLLOW_strcrit_in_crit114_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_intcrit_in_crit119 */ ++static ANTLR3_BITWORD FOLLOW_intcrit_in_crit119_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_intcrit_in_crit119 = { FOLLOW_intcrit_in_crit119_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_datecrit_in_crit124 */ ++static ANTLR3_BITWORD FOLLOW_datecrit_in_crit124_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_datecrit_in_crit124 = { FOLLOW_datecrit_in_crit124_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit134 */ ++static ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit134_bits[] = { ANTLR3_UINT64_LIT(0x000000000000F000) }; ++static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit134 = { FOLLOW_FIELD_in_strcrit134_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit136 */ ++static ANTLR3_BITWORD FOLLOW_strop_in_strcrit136_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000400) }; ++static ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit136 = { FOLLOW_strop_in_strcrit136_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit138 */ ++static ANTLR3_BITWORD FOLLOW_STR_in_strcrit138_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit138 = { FOLLOW_STR_in_strcrit138_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit155 */ ++static ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit155_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000800) }; ++static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit155 = { FOLLOW_FIELD_in_strcrit155_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_strcrit157 */ ++static ANTLR3_BITWORD FOLLOW_NOT_in_strcrit157_bits[] = { ANTLR3_UINT64_LIT(0x000000000000F000) }; ++static ANTLR3_BITSET_LIST FOLLOW_NOT_in_strcrit157 = { FOLLOW_NOT_in_strcrit157_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit159 */ ++static ANTLR3_BITWORD FOLLOW_strop_in_strcrit159_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000400) }; ++static ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit159 = { FOLLOW_strop_in_strcrit159_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit161 */ ++static ANTLR3_BITWORD FOLLOW_STR_in_strcrit161_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit161 = { FOLLOW_STR_in_strcrit161_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_strop0 */ ++static ANTLR3_BITWORD FOLLOW_set_in_strop0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_set_in_strop0 = { FOLLOW_set_in_strop0_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit211 */ ++static ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit211_bits[] = { ANTLR3_UINT64_LIT(0x00000000001E1000) }; ++static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit211 = { FOLLOW_FIELD_in_intcrit211_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit213 */ ++static ANTLR3_BITWORD FOLLOW_intop_in_intcrit213_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; ++static ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit213 = { FOLLOW_intop_in_intcrit213_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit215 */ ++static ANTLR3_BITWORD FOLLOW_INT_in_intcrit215_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit215 = { FOLLOW_INT_in_intcrit215_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit232 */ ++static ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit232_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000800) }; ++static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit232 = { FOLLOW_FIELD_in_intcrit232_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_intcrit234 */ ++static ANTLR3_BITWORD FOLLOW_NOT_in_intcrit234_bits[] = { ANTLR3_UINT64_LIT(0x00000000001E1000) }; ++static ANTLR3_BITSET_LIST FOLLOW_NOT_in_intcrit234 = { FOLLOW_NOT_in_intcrit234_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit236 */ ++static ANTLR3_BITWORD FOLLOW_intop_in_intcrit236_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; ++static ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit236 = { FOLLOW_intop_in_intcrit236_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit238 */ ++static ANTLR3_BITWORD FOLLOW_INT_in_intcrit238_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit238 = { FOLLOW_INT_in_intcrit238_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_intop0 */ ++static ANTLR3_BITWORD FOLLOW_set_in_intop0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_set_in_intop0 = { FOLLOW_set_in_intop0_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_datecrit292 */ ++static ANTLR3_BITWORD FOLLOW_FIELD_in_datecrit292_bits[] = { ANTLR3_UINT64_LIT(0x0000000000600000) }; ++static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_datecrit292 = { FOLLOW_FIELD_in_datecrit292_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datecrit294 */ ++static ANTLR3_BITWORD FOLLOW_dateop_in_datecrit294_bits[] = { ANTLR3_UINT64_LIT(0x0000000001810000) }; ++static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datecrit294 = { FOLLOW_dateop_in_datecrit294_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_datespec_in_datecrit296 */ ++static ANTLR3_BITWORD FOLLOW_datespec_in_datecrit296_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_datespec_in_datecrit296 = { FOLLOW_datespec_in_datecrit296_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_dateop0 */ ++static ANTLR3_BITWORD FOLLOW_set_in_dateop0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_set_in_dateop0 = { FOLLOW_set_in_dateop0_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec331 */ ++static ANTLR3_BITWORD FOLLOW_dateref_in_datespec331_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec331 = { FOLLOW_dateref_in_datespec331_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_datespec336 */ ++static ANTLR3_BITWORD FOLLOW_INT_in_datespec336_bits[] = { ANTLR3_UINT64_LIT(0x000000001E000000) }; ++static ANTLR3_BITSET_LIST FOLLOW_INT_in_datespec336 = { FOLLOW_INT_in_datespec336_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateintval_in_datespec338 */ ++static ANTLR3_BITWORD FOLLOW_dateintval_in_datespec338_bits[] = { ANTLR3_UINT64_LIT(0x0000000000600000) }; ++static ANTLR3_BITSET_LIST FOLLOW_dateintval_in_datespec338 = { FOLLOW_dateintval_in_datespec338_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datespec340 */ ++static ANTLR3_BITWORD FOLLOW_dateop_in_datespec340_bits[] = { ANTLR3_UINT64_LIT(0x0000000001800000) }; ++static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datespec340 = { FOLLOW_dateop_in_datespec340_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec342 */ ++static ANTLR3_BITWORD FOLLOW_dateref_in_datespec342_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec342 = { FOLLOW_dateref_in_datespec342_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_dateref0 */ ++static ANTLR3_BITWORD FOLLOW_set_in_dateref0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_set_in_dateref0 = { FOLLOW_set_in_dateref0_bits, 1 }; ++/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_dateintval0 */ ++static ANTLR3_BITWORD FOLLOW_set_in_dateintval0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; ++static ANTLR3_BITSET_LIST FOLLOW_set_in_dateintval0 = { FOLLOW_set_in_dateintval0_bits, 1 }; ++ ++ ++ ++ ++/* ============================================== ++ * Parsing rules ++ */ ++/** ++ * $ANTLR start query ++ * RSP.g:27:1: query : expr ( NEWLINE )? EOF -> expr ; ++ */ ++static RSPParser_query_return ++query(pRSPParser ctx) ++{ ++ RSPParser_query_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN NEWLINE2; ++ pANTLR3_COMMON_TOKEN EOF3; ++ RSPParser_expr_return expr1; ++ #undef RETURN_TYPE_expr1 ++ #define RETURN_TYPE_expr1 RSPParser_expr_return ++ ++ pANTLR3_BASE_TREE NEWLINE2_tree; ++ pANTLR3_BASE_TREE EOF3_tree; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NEWLINE; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_EOF; ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr; ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ NEWLINE2 = NULL; ++ EOF3 = NULL; ++ expr1.tree = NULL; ++ ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ NEWLINE2_tree = NULL; ++ EOF3_tree = NULL; ++ ++ stream_NEWLINE = NULL; ++ #define CREATE_stream_NEWLINE if (stream_NEWLINE == NULL) {stream_NEWLINE = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NEWLINE"); } ++ stream_EOF = NULL; ++ #define CREATE_stream_EOF if (stream_EOF == NULL) {stream_EOF = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token EOF"); } ++ stream_expr = NULL; ++ #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); } ++ ++ retval.tree = NULL; ++ { ++ // RSP.g:27:7: ( expr ( NEWLINE )? EOF -> expr ) ++ // RSP.g:27:9: expr ( NEWLINE )? EOF ++ { ++ FOLLOWPUSH(FOLLOW_expr_in_query42); ++ expr1=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto rulequeryEx; ++ } ++ ++ CREATE_stream_expr; stream_expr->add(stream_expr, expr1.tree, NULL); ++ ++ // RSP.g:27:14: ( NEWLINE )? ++ { ++ int alt1=2; ++ switch ( LA(1) ) ++ { ++ case NEWLINE: ++ { ++ alt1=1; ++ } ++ break; ++ } ++ ++ switch (alt1) ++ { ++ case 1: ++ // RSP.g:27:14: NEWLINE ++ { ++ NEWLINE2 = (pANTLR3_COMMON_TOKEN) MATCHT(NEWLINE, &FOLLOW_NEWLINE_in_query44); ++ if (HASEXCEPTION()) ++ { ++ goto rulequeryEx; ++ } ++ ++ CREATE_stream_NEWLINE; stream_NEWLINE->add(stream_NEWLINE, NEWLINE2, NULL); ++ ++ ++ } ++ break; ++ ++ } ++ } ++ EOF3 = (pANTLR3_COMMON_TOKEN) MATCHT(EOF, &FOLLOW_EOF_in_query47); ++ if (HASEXCEPTION()) ++ { ++ goto rulequeryEx; ++ } ++ ++ CREATE_stream_EOF; stream_EOF->add(stream_EOF, EOF3, NULL); ++ ++ ++ ++ /* AST REWRITE ++ * elements : expr ++ * token labels : ++ * rule labels : retval ++ * token list labels : ++ * rule list labels : ++ */ ++ { ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; ++ ++ stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); ++ ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ retval.tree = root_0; ++ // 27:28: -> expr ++ { ++ ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr)); ++ ++ } ++ ++ retval.tree = root_0; // set result root ++ if (stream_retval != NULL) stream_retval->free(stream_retval); ++ ++ ++ } ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto rulequeryEx; /* Prevent compiler warnings */ ++ rulequeryEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ if (stream_NEWLINE != NULL) stream_NEWLINE->free(stream_NEWLINE); ++ if (stream_EOF != NULL) stream_EOF->free(stream_EOF); ++ if (stream_expr != NULL) stream_expr->free(stream_expr); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end query */ ++ ++/** ++ * $ANTLR start expr ++ * RSP.g:30:1: expr : aexpr ( OR aexpr )* ; ++ */ ++static RSPParser_expr_return ++expr(pRSPParser ctx) ++{ ++ RSPParser_expr_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN OR5; ++ RSPParser_aexpr_return aexpr4; ++ #undef RETURN_TYPE_aexpr4 ++ #define RETURN_TYPE_aexpr4 RSPParser_aexpr_return ++ ++ RSPParser_aexpr_return aexpr6; ++ #undef RETURN_TYPE_aexpr6 ++ #define RETURN_TYPE_aexpr6 RSPParser_aexpr_return ++ ++ pANTLR3_BASE_TREE OR5_tree; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ OR5 = NULL; ++ aexpr4.tree = NULL; ++ ++ aexpr6.tree = NULL; ++ ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ OR5_tree = NULL; ++ ++ ++ retval.tree = NULL; ++ { ++ // RSP.g:30:6: ( aexpr ( OR aexpr )* ) ++ // RSP.g:30:8: aexpr ( OR aexpr )* ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ FOLLOWPUSH(FOLLOW_aexpr_in_expr63); ++ aexpr4=aexpr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, aexpr4.tree); ++ ++ // RSP.g:30:14: ( OR aexpr )* ++ ++ for (;;) ++ { ++ int alt2=2; ++ switch ( LA(1) ) ++ { ++ case OR: ++ { ++ alt2=1; ++ } ++ break; ++ ++ } ++ ++ switch (alt2) ++ { ++ case 1: ++ // RSP.g:30:15: OR aexpr ++ { ++ OR5 = (pANTLR3_COMMON_TOKEN) MATCHT(OR, &FOLLOW_OR_in_expr66); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ OR5_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OR5)); ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OR5_tree, root_0)); ++ ++ FOLLOWPUSH(FOLLOW_aexpr_in_expr69); ++ aexpr6=aexpr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleexprEx; ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, aexpr6.tree); ++ ++ } ++ break; ++ ++ default: ++ goto loop2; /* break out of the loop */ ++ break; ++ } ++ } ++ loop2: ; /* Jump out to here if this rule does not match */ ++ ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleexprEx; /* Prevent compiler warnings */ ++ ruleexprEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end expr */ ++ ++/** ++ * $ANTLR start aexpr ++ * RSP.g:33:1: aexpr : crit ( AND crit )* ; ++ */ ++static RSPParser_aexpr_return ++aexpr(pRSPParser ctx) ++{ ++ RSPParser_aexpr_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN AND8; ++ RSPParser_crit_return crit7; ++ #undef RETURN_TYPE_crit7 ++ #define RETURN_TYPE_crit7 RSPParser_crit_return ++ ++ RSPParser_crit_return crit9; ++ #undef RETURN_TYPE_crit9 ++ #define RETURN_TYPE_crit9 RSPParser_crit_return ++ ++ pANTLR3_BASE_TREE AND8_tree; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ AND8 = NULL; ++ crit7.tree = NULL; ++ ++ crit9.tree = NULL; ++ ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ AND8_tree = NULL; ++ ++ ++ retval.tree = NULL; ++ { ++ // RSP.g:33:7: ( crit ( AND crit )* ) ++ // RSP.g:33:9: crit ( AND crit )* ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ FOLLOWPUSH(FOLLOW_crit_in_aexpr81); ++ crit7=crit(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleaexprEx; ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, crit7.tree); ++ ++ // RSP.g:33:14: ( AND crit )* ++ ++ for (;;) ++ { ++ int alt3=2; ++ switch ( LA(1) ) ++ { ++ case AND: ++ { ++ alt3=1; ++ } ++ break; ++ ++ } ++ ++ switch (alt3) ++ { ++ case 1: ++ // RSP.g:33:15: AND crit ++ { ++ AND8 = (pANTLR3_COMMON_TOKEN) MATCHT(AND, &FOLLOW_AND_in_aexpr84); ++ if (HASEXCEPTION()) ++ { ++ goto ruleaexprEx; ++ } ++ ++ AND8_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, AND8)); ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, AND8_tree, root_0)); ++ ++ FOLLOWPUSH(FOLLOW_crit_in_aexpr87); ++ crit9=crit(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleaexprEx; ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, crit9.tree); ++ ++ } ++ break; ++ ++ default: ++ goto loop3; /* break out of the loop */ ++ break; ++ } ++ } ++ loop3: ; /* Jump out to here if this rule does not match */ ++ ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleaexprEx; /* Prevent compiler warnings */ ++ ruleaexprEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end aexpr */ ++ ++/** ++ * $ANTLR start crit ++ * RSP.g:36:1: crit : ( LPAR expr RPAR -> expr | strcrit | intcrit | datecrit ); ++ */ ++static RSPParser_crit_return ++crit(pRSPParser ctx) ++{ ++ RSPParser_crit_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN LPAR10; ++ pANTLR3_COMMON_TOKEN RPAR12; ++ RSPParser_expr_return expr11; ++ #undef RETURN_TYPE_expr11 ++ #define RETURN_TYPE_expr11 RSPParser_expr_return ++ ++ RSPParser_strcrit_return strcrit13; ++ #undef RETURN_TYPE_strcrit13 ++ #define RETURN_TYPE_strcrit13 RSPParser_strcrit_return ++ ++ RSPParser_intcrit_return intcrit14; ++ #undef RETURN_TYPE_intcrit14 ++ #define RETURN_TYPE_intcrit14 RSPParser_intcrit_return ++ ++ RSPParser_datecrit_return datecrit15; ++ #undef RETURN_TYPE_datecrit15 ++ #define RETURN_TYPE_datecrit15 RSPParser_datecrit_return ++ ++ pANTLR3_BASE_TREE LPAR10_tree; ++ pANTLR3_BASE_TREE RPAR12_tree; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_RPAR; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_LPAR; ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr; ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ LPAR10 = NULL; ++ RPAR12 = NULL; ++ expr11.tree = NULL; ++ ++ strcrit13.tree = NULL; ++ ++ intcrit14.tree = NULL; ++ ++ datecrit15.tree = NULL; ++ ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ LPAR10_tree = NULL; ++ RPAR12_tree = NULL; ++ ++ stream_RPAR = NULL; ++ #define CREATE_stream_RPAR if (stream_RPAR == NULL) {stream_RPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token RPAR"); } ++ stream_LPAR = NULL; ++ #define CREATE_stream_LPAR if (stream_LPAR == NULL) {stream_LPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token LPAR"); } ++ stream_expr = NULL; ++ #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); } ++ ++ retval.tree = NULL; ++ { ++ { ++ // RSP.g:36:6: ( LPAR expr RPAR -> expr | strcrit | intcrit | datecrit ) ++ ++ ANTLR3_UINT32 alt4; ++ ++ alt4=4; ++ ++ switch ( LA(1) ) ++ { ++ case LPAR: ++ { ++ alt4=1; ++ } ++ break; ++ case FIELD: ++ { ++ switch ( LA(2) ) ++ { ++ case NOT: ++ { ++ switch ( LA(3) ) ++ { ++ case EQUAL: ++ { ++ switch ( LA(4) ) ++ { ++ case STR: ++ { ++ alt4=2; ++ } ++ break; ++ case INT: ++ { ++ alt4=3; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 4; ++ EXCEPTION->state = 8; ++ ++ ++ goto rulecritEx; ++ } ++ ++ } ++ break; ++ case INCLUDES: ++ case STARTSW: ++ case ENDSW: ++ { ++ alt4=2; ++ } ++ break; ++ case LESS: ++ case GREATER: ++ case LTE: ++ case GTE: ++ { ++ alt4=3; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 4; ++ EXCEPTION->state = 3; ++ ++ ++ goto rulecritEx; ++ } ++ ++ } ++ break; ++ case EQUAL: ++ { ++ switch ( LA(3) ) ++ { ++ case INT: ++ { ++ alt4=3; ++ } ++ break; ++ case STR: ++ { ++ alt4=2; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 4; ++ EXCEPTION->state = 4; ++ ++ ++ goto rulecritEx; ++ } ++ ++ } ++ break; ++ case BEFORE: ++ case AFTER: ++ { ++ alt4=4; ++ } ++ break; ++ case LESS: ++ case GREATER: ++ case LTE: ++ case GTE: ++ { ++ alt4=3; ++ } ++ break; ++ case INCLUDES: ++ case STARTSW: ++ case ENDSW: ++ { ++ alt4=2; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 4; ++ EXCEPTION->state = 2; ++ ++ ++ goto rulecritEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 4; ++ EXCEPTION->state = 0; ++ ++ ++ goto rulecritEx; ++ } ++ ++ switch (alt4) ++ { ++ case 1: ++ // RSP.g:36:8: LPAR expr RPAR ++ { ++ LPAR10 = (pANTLR3_COMMON_TOKEN) MATCHT(LPAR, &FOLLOW_LPAR_in_crit99); ++ if (HASEXCEPTION()) ++ { ++ goto rulecritEx; ++ } ++ ++ CREATE_stream_LPAR; stream_LPAR->add(stream_LPAR, LPAR10, NULL); ++ ++ FOLLOWPUSH(FOLLOW_expr_in_crit101); ++ expr11=expr(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto rulecritEx; ++ } ++ ++ CREATE_stream_expr; stream_expr->add(stream_expr, expr11.tree, NULL); ++ RPAR12 = (pANTLR3_COMMON_TOKEN) MATCHT(RPAR, &FOLLOW_RPAR_in_crit103); ++ if (HASEXCEPTION()) ++ { ++ goto rulecritEx; ++ } ++ ++ CREATE_stream_RPAR; stream_RPAR->add(stream_RPAR, RPAR12, NULL); ++ ++ ++ ++ /* AST REWRITE ++ * elements : expr ++ * token labels : ++ * rule labels : retval ++ * token list labels : ++ * rule list labels : ++ */ ++ { ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; ++ ++ stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); ++ ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ retval.tree = root_0; ++ // 36:25: -> expr ++ { ++ ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr)); ++ ++ } ++ ++ retval.tree = root_0; // set result root ++ if (stream_retval != NULL) stream_retval->free(stream_retval); ++ ++ ++ } ++ } ++ break; ++ case 2: ++ // RSP.g:37:4: strcrit ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ FOLLOWPUSH(FOLLOW_strcrit_in_crit114); ++ strcrit13=strcrit(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto rulecritEx; ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, strcrit13.tree); ++ ++ } ++ break; ++ case 3: ++ // RSP.g:38:4: intcrit ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ FOLLOWPUSH(FOLLOW_intcrit_in_crit119); ++ intcrit14=intcrit(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto rulecritEx; ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, intcrit14.tree); ++ ++ } ++ break; ++ case 4: ++ // RSP.g:39:4: datecrit ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ FOLLOWPUSH(FOLLOW_datecrit_in_crit124); ++ datecrit15=datecrit(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto rulecritEx; ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, datecrit15.tree); ++ ++ } ++ break; ++ ++ } ++ } ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto rulecritEx; /* Prevent compiler warnings */ ++ rulecritEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ if (stream_RPAR != NULL) stream_RPAR->free(stream_RPAR); ++ if (stream_LPAR != NULL) stream_LPAR->free(stream_LPAR); ++ if (stream_expr != NULL) stream_expr->free(stream_expr); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end crit */ ++ ++/** ++ * $ANTLR start strcrit ++ * RSP.g:42:1: strcrit : ( FIELD strop STR -> ^( strop FIELD STR ) | FIELD NOT strop STR -> ^( NOT ^( strop FIELD STR ) ) ); ++ */ ++static RSPParser_strcrit_return ++strcrit(pRSPParser ctx) ++{ ++ RSPParser_strcrit_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN FIELD16; ++ pANTLR3_COMMON_TOKEN STR18; ++ pANTLR3_COMMON_TOKEN FIELD19; ++ pANTLR3_COMMON_TOKEN NOT20; ++ pANTLR3_COMMON_TOKEN STR22; ++ RSPParser_strop_return strop17; ++ #undef RETURN_TYPE_strop17 ++ #define RETURN_TYPE_strop17 RSPParser_strop_return ++ ++ RSPParser_strop_return strop21; ++ #undef RETURN_TYPE_strop21 ++ #define RETURN_TYPE_strop21 RSPParser_strop_return ++ ++ pANTLR3_BASE_TREE FIELD16_tree; ++ pANTLR3_BASE_TREE STR18_tree; ++ pANTLR3_BASE_TREE FIELD19_tree; ++ pANTLR3_BASE_TREE NOT20_tree; ++ pANTLR3_BASE_TREE STR22_tree; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_STR; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NOT; ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_strop; ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ FIELD16 = NULL; ++ STR18 = NULL; ++ FIELD19 = NULL; ++ NOT20 = NULL; ++ STR22 = NULL; ++ strop17.tree = NULL; ++ ++ strop21.tree = NULL; ++ ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ FIELD16_tree = NULL; ++ STR18_tree = NULL; ++ FIELD19_tree = NULL; ++ NOT20_tree = NULL; ++ STR22_tree = NULL; ++ ++ stream_STR = NULL; ++ #define CREATE_stream_STR if (stream_STR == NULL) {stream_STR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token STR"); } ++ stream_FIELD = NULL; ++ #define CREATE_stream_FIELD if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); } ++ stream_NOT = NULL; ++ #define CREATE_stream_NOT if (stream_NOT == NULL) {stream_NOT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NOT"); } ++ stream_strop = NULL; ++ #define CREATE_stream_strop if (stream_strop == NULL) {stream_strop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule strop"); } ++ ++ retval.tree = NULL; ++ { ++ { ++ // RSP.g:42:9: ( FIELD strop STR -> ^( strop FIELD STR ) | FIELD NOT strop STR -> ^( NOT ^( strop FIELD STR ) ) ) ++ ++ ANTLR3_UINT32 alt5; ++ ++ alt5=2; ++ ++ switch ( LA(1) ) ++ { ++ case FIELD: ++ { ++ switch ( LA(2) ) ++ { ++ case NOT: ++ { ++ alt5=2; ++ } ++ break; ++ case EQUAL: ++ case INCLUDES: ++ case STARTSW: ++ case ENDSW: ++ { ++ alt5=1; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 5; ++ EXCEPTION->state = 1; ++ ++ ++ goto rulestrcritEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 5; ++ EXCEPTION->state = 0; ++ ++ ++ goto rulestrcritEx; ++ } ++ ++ switch (alt5) ++ { ++ case 1: ++ // RSP.g:42:11: FIELD strop STR ++ { ++ FIELD16 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit134); ++ if (HASEXCEPTION()) ++ { ++ goto rulestrcritEx; ++ } ++ ++ CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD16, NULL); ++ ++ FOLLOWPUSH(FOLLOW_strop_in_strcrit136); ++ strop17=strop(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto rulestrcritEx; ++ } ++ ++ CREATE_stream_strop; stream_strop->add(stream_strop, strop17.tree, NULL); ++ STR18 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_strcrit138); ++ if (HASEXCEPTION()) ++ { ++ goto rulestrcritEx; ++ } ++ ++ CREATE_stream_STR; stream_STR->add(stream_STR, STR18, NULL); ++ ++ ++ ++ /* AST REWRITE ++ * elements : strop, STR, FIELD ++ * token labels : ++ * rule labels : retval ++ * token list labels : ++ * rule list labels : ++ */ ++ { ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; ++ ++ stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); ++ ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ retval.tree = root_0; ++ // 42:29: -> ^( strop FIELD STR ) ++ { ++ // RSP.g:42:32: ^( strop FIELD STR ) ++ { ++ pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_strop == NULL ? NULL : stream_strop->nextNode(stream_strop), root_1)); ++ ++ ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD)); ++ ADAPTOR->addChild(ADAPTOR, root_1, stream_STR == NULL ? NULL : stream_STR->nextNode(stream_STR)); ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, root_1); ++ } ++ ++ } ++ ++ retval.tree = root_0; // set result root ++ if (stream_retval != NULL) stream_retval->free(stream_retval); ++ ++ ++ } ++ } ++ break; ++ case 2: ++ // RSP.g:43:4: FIELD NOT strop STR ++ { ++ FIELD19 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit155); ++ if (HASEXCEPTION()) ++ { ++ goto rulestrcritEx; ++ } ++ ++ CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD19, NULL); ++ ++ NOT20 = (pANTLR3_COMMON_TOKEN) MATCHT(NOT, &FOLLOW_NOT_in_strcrit157); ++ if (HASEXCEPTION()) ++ { ++ goto rulestrcritEx; ++ } ++ ++ CREATE_stream_NOT; stream_NOT->add(stream_NOT, NOT20, NULL); ++ ++ FOLLOWPUSH(FOLLOW_strop_in_strcrit159); ++ strop21=strop(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto rulestrcritEx; ++ } ++ ++ CREATE_stream_strop; stream_strop->add(stream_strop, strop21.tree, NULL); ++ STR22 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_strcrit161); ++ if (HASEXCEPTION()) ++ { ++ goto rulestrcritEx; ++ } ++ ++ CREATE_stream_STR; stream_STR->add(stream_STR, STR22, NULL); ++ ++ ++ ++ /* AST REWRITE ++ * elements : NOT, FIELD, strop, STR ++ * token labels : ++ * rule labels : retval ++ * token list labels : ++ * rule list labels : ++ */ ++ { ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; ++ ++ stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); ++ ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ retval.tree = root_0; ++ // 43:25: -> ^( NOT ^( strop FIELD STR ) ) ++ { ++ // RSP.g:43:28: ^( NOT ^( strop FIELD STR ) ) ++ { ++ pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_NOT == NULL ? NULL : stream_NOT->nextNode(stream_NOT), root_1)); ++ ++ // RSP.g:43:34: ^( strop FIELD STR ) ++ { ++ pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_strop == NULL ? NULL : stream_strop->nextNode(stream_strop), root_2)); ++ ++ ADAPTOR->addChild(ADAPTOR, root_2, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD)); ++ ADAPTOR->addChild(ADAPTOR, root_2, stream_STR == NULL ? NULL : stream_STR->nextNode(stream_STR)); ++ ++ ADAPTOR->addChild(ADAPTOR, root_1, root_2); ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, root_1); ++ } ++ ++ } ++ ++ retval.tree = root_0; // set result root ++ if (stream_retval != NULL) stream_retval->free(stream_retval); ++ ++ ++ } ++ } ++ break; ++ ++ } ++ } ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto rulestrcritEx; /* Prevent compiler warnings */ ++ rulestrcritEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ if (stream_STR != NULL) stream_STR->free(stream_STR); ++ if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD); ++ if (stream_NOT != NULL) stream_NOT->free(stream_NOT); ++ if (stream_strop != NULL) stream_strop->free(stream_strop); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end strcrit */ ++ ++/** ++ * $ANTLR start strop ++ * RSP.g:46:1: strop : ( EQUAL | INCLUDES | STARTSW | ENDSW ); ++ */ ++static RSPParser_strop_return ++strop(pRSPParser ctx) ++{ ++ RSPParser_strop_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN set23; ++ ++ pANTLR3_BASE_TREE set23_tree; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ set23 = NULL; ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ set23_tree = NULL; ++ ++ ++ retval.tree = NULL; ++ { ++ // RSP.g:46:7: ( EQUAL | INCLUDES | STARTSW | ENDSW ) ++ // RSP.g: ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ set23=(pANTLR3_COMMON_TOKEN)LT(1); ++ if ( ((LA(1) >= EQUAL) && (LA(1) <= ENDSW)) ) ++ { ++ CONSUME(); ++ ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set23))); ++ PERRORRECOVERY=ANTLR3_FALSE; ++ } ++ else ++ { ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; ++ EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; ++ EXCEPTION->expectingSet = &FOLLOW_set_in_strop0; ++ RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_strop0); goto rulestropEx; ++ } ++ ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto rulestropEx; /* Prevent compiler warnings */ ++ rulestropEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end strop */ ++ ++/** ++ * $ANTLR start intcrit ++ * RSP.g:52:1: intcrit : ( FIELD intop INT -> ^( intop FIELD INT ) | FIELD NOT intop INT -> ^( NOT ^( intop FIELD INT ) ) ); ++ */ ++static RSPParser_intcrit_return ++intcrit(pRSPParser ctx) ++{ ++ RSPParser_intcrit_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN FIELD24; ++ pANTLR3_COMMON_TOKEN INT26; ++ pANTLR3_COMMON_TOKEN FIELD27; ++ pANTLR3_COMMON_TOKEN NOT28; ++ pANTLR3_COMMON_TOKEN INT30; ++ RSPParser_intop_return intop25; ++ #undef RETURN_TYPE_intop25 ++ #define RETURN_TYPE_intop25 RSPParser_intop_return ++ ++ RSPParser_intop_return intop29; ++ #undef RETURN_TYPE_intop29 ++ #define RETURN_TYPE_intop29 RSPParser_intop_return ++ ++ pANTLR3_BASE_TREE FIELD24_tree; ++ pANTLR3_BASE_TREE INT26_tree; ++ pANTLR3_BASE_TREE FIELD27_tree; ++ pANTLR3_BASE_TREE NOT28_tree; ++ pANTLR3_BASE_TREE INT30_tree; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_INT; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NOT; ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_intop; ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ FIELD24 = NULL; ++ INT26 = NULL; ++ FIELD27 = NULL; ++ NOT28 = NULL; ++ INT30 = NULL; ++ intop25.tree = NULL; ++ ++ intop29.tree = NULL; ++ ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ FIELD24_tree = NULL; ++ INT26_tree = NULL; ++ FIELD27_tree = NULL; ++ NOT28_tree = NULL; ++ INT30_tree = NULL; ++ ++ stream_FIELD = NULL; ++ #define CREATE_stream_FIELD if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); } ++ stream_INT = NULL; ++ #define CREATE_stream_INT if (stream_INT == NULL) {stream_INT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token INT"); } ++ stream_NOT = NULL; ++ #define CREATE_stream_NOT if (stream_NOT == NULL) {stream_NOT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NOT"); } ++ stream_intop = NULL; ++ #define CREATE_stream_intop if (stream_intop == NULL) {stream_intop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule intop"); } ++ ++ retval.tree = NULL; ++ { ++ { ++ // RSP.g:52:9: ( FIELD intop INT -> ^( intop FIELD INT ) | FIELD NOT intop INT -> ^( NOT ^( intop FIELD INT ) ) ) ++ ++ ANTLR3_UINT32 alt6; ++ ++ alt6=2; ++ ++ switch ( LA(1) ) ++ { ++ case FIELD: ++ { ++ switch ( LA(2) ) ++ { ++ case NOT: ++ { ++ alt6=2; ++ } ++ break; ++ case EQUAL: ++ case LESS: ++ case GREATER: ++ case LTE: ++ case GTE: ++ { ++ alt6=1; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 6; ++ EXCEPTION->state = 1; ++ ++ ++ goto ruleintcritEx; ++ } ++ ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 6; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruleintcritEx; ++ } ++ ++ switch (alt6) ++ { ++ case 1: ++ // RSP.g:52:11: FIELD intop INT ++ { ++ FIELD24 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit211); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintcritEx; ++ } ++ ++ CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD24, NULL); ++ ++ FOLLOWPUSH(FOLLOW_intop_in_intcrit213); ++ intop25=intop(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintcritEx; ++ } ++ ++ CREATE_stream_intop; stream_intop->add(stream_intop, intop25.tree, NULL); ++ INT26 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_intcrit215); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintcritEx; ++ } ++ ++ CREATE_stream_INT; stream_INT->add(stream_INT, INT26, NULL); ++ ++ ++ ++ /* AST REWRITE ++ * elements : FIELD, intop, INT ++ * token labels : ++ * rule labels : retval ++ * token list labels : ++ * rule list labels : ++ */ ++ { ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; ++ ++ stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); ++ ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ retval.tree = root_0; ++ // 52:29: -> ^( intop FIELD INT ) ++ { ++ // RSP.g:52:32: ^( intop FIELD INT ) ++ { ++ pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_intop == NULL ? NULL : stream_intop->nextNode(stream_intop), root_1)); ++ ++ ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD)); ++ ADAPTOR->addChild(ADAPTOR, root_1, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT)); ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, root_1); ++ } ++ ++ } ++ ++ retval.tree = root_0; // set result root ++ if (stream_retval != NULL) stream_retval->free(stream_retval); ++ ++ ++ } ++ } ++ break; ++ case 2: ++ // RSP.g:53:4: FIELD NOT intop INT ++ { ++ FIELD27 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit232); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintcritEx; ++ } ++ ++ CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD27, NULL); ++ ++ NOT28 = (pANTLR3_COMMON_TOKEN) MATCHT(NOT, &FOLLOW_NOT_in_intcrit234); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintcritEx; ++ } ++ ++ CREATE_stream_NOT; stream_NOT->add(stream_NOT, NOT28, NULL); ++ ++ FOLLOWPUSH(FOLLOW_intop_in_intcrit236); ++ intop29=intop(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintcritEx; ++ } ++ ++ CREATE_stream_intop; stream_intop->add(stream_intop, intop29.tree, NULL); ++ INT30 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_intcrit238); ++ if (HASEXCEPTION()) ++ { ++ goto ruleintcritEx; ++ } ++ ++ CREATE_stream_INT; stream_INT->add(stream_INT, INT30, NULL); ++ ++ ++ ++ /* AST REWRITE ++ * elements : NOT, INT, FIELD, intop ++ * token labels : ++ * rule labels : retval ++ * token list labels : ++ * rule list labels : ++ */ ++ { ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; ++ ++ stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); ++ ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ retval.tree = root_0; ++ // 53:25: -> ^( NOT ^( intop FIELD INT ) ) ++ { ++ // RSP.g:53:28: ^( NOT ^( intop FIELD INT ) ) ++ { ++ pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_NOT == NULL ? NULL : stream_NOT->nextNode(stream_NOT), root_1)); ++ ++ // RSP.g:53:34: ^( intop FIELD INT ) ++ { ++ pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_intop == NULL ? NULL : stream_intop->nextNode(stream_intop), root_2)); ++ ++ ADAPTOR->addChild(ADAPTOR, root_2, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD)); ++ ADAPTOR->addChild(ADAPTOR, root_2, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT)); ++ ++ ADAPTOR->addChild(ADAPTOR, root_1, root_2); ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, root_1); ++ } ++ ++ } ++ ++ retval.tree = root_0; // set result root ++ if (stream_retval != NULL) stream_retval->free(stream_retval); ++ ++ ++ } ++ } ++ break; ++ ++ } ++ } ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleintcritEx; /* Prevent compiler warnings */ ++ ruleintcritEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD); ++ if (stream_INT != NULL) stream_INT->free(stream_INT); ++ if (stream_NOT != NULL) stream_NOT->free(stream_NOT); ++ if (stream_intop != NULL) stream_intop->free(stream_intop); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end intcrit */ ++ ++/** ++ * $ANTLR start intop ++ * RSP.g:56:1: intop : ( EQUAL | LESS | GREATER | LTE | GTE ); ++ */ ++static RSPParser_intop_return ++intop(pRSPParser ctx) ++{ ++ RSPParser_intop_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN set31; ++ ++ pANTLR3_BASE_TREE set31_tree; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ set31 = NULL; ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ set31_tree = NULL; ++ ++ ++ retval.tree = NULL; ++ { ++ // RSP.g:56:7: ( EQUAL | LESS | GREATER | LTE | GTE ) ++ // RSP.g: ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ set31=(pANTLR3_COMMON_TOKEN)LT(1); ++ if ( LA(1) == EQUAL || ((LA(1) >= LESS) && (LA(1) <= GTE)) ) ++ { ++ CONSUME(); ++ ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set31))); ++ PERRORRECOVERY=ANTLR3_FALSE; ++ } ++ else ++ { ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; ++ EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; ++ EXCEPTION->expectingSet = &FOLLOW_set_in_intop0; ++ RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_intop0); goto ruleintopEx; ++ } ++ ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruleintopEx; /* Prevent compiler warnings */ ++ ruleintopEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end intop */ ++ ++/** ++ * $ANTLR start datecrit ++ * RSP.g:63:1: datecrit : FIELD dateop datespec -> ^( dateop FIELD datespec ) ; ++ */ ++static RSPParser_datecrit_return ++datecrit(pRSPParser ctx) ++{ ++ RSPParser_datecrit_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN FIELD32; ++ RSPParser_dateop_return dateop33; ++ #undef RETURN_TYPE_dateop33 ++ #define RETURN_TYPE_dateop33 RSPParser_dateop_return ++ ++ RSPParser_datespec_return datespec34; ++ #undef RETURN_TYPE_datespec34 ++ #define RETURN_TYPE_datespec34 RSPParser_datespec_return ++ ++ pANTLR3_BASE_TREE FIELD32_tree; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD; ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_datespec; ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateop; ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ FIELD32 = NULL; ++ dateop33.tree = NULL; ++ ++ datespec34.tree = NULL; ++ ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ FIELD32_tree = NULL; ++ ++ stream_FIELD = NULL; ++ #define CREATE_stream_FIELD if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); } ++ stream_datespec = NULL; ++ #define CREATE_stream_datespec if (stream_datespec == NULL) {stream_datespec = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule datespec"); } ++ stream_dateop = NULL; ++ #define CREATE_stream_dateop if (stream_dateop == NULL) {stream_dateop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateop"); } ++ ++ retval.tree = NULL; ++ { ++ // RSP.g:63:9: ( FIELD dateop datespec -> ^( dateop FIELD datespec ) ) ++ // RSP.g:63:11: FIELD dateop datespec ++ { ++ FIELD32 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_datecrit292); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatecritEx; ++ } ++ ++ CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD32, NULL); ++ ++ FOLLOWPUSH(FOLLOW_dateop_in_datecrit294); ++ dateop33=dateop(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatecritEx; ++ } ++ ++ CREATE_stream_dateop; stream_dateop->add(stream_dateop, dateop33.tree, NULL); ++ FOLLOWPUSH(FOLLOW_datespec_in_datecrit296); ++ datespec34=datespec(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatecritEx; ++ } ++ ++ CREATE_stream_datespec; stream_datespec->add(stream_datespec, datespec34.tree, NULL); ++ ++ ++ /* AST REWRITE ++ * elements : FIELD, datespec, dateop ++ * token labels : ++ * rule labels : retval ++ * token list labels : ++ * rule list labels : ++ */ ++ { ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; ++ ++ stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); ++ ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ retval.tree = root_0; ++ // 63:34: -> ^( dateop FIELD datespec ) ++ { ++ // RSP.g:63:37: ^( dateop FIELD datespec ) ++ { ++ pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_dateop == NULL ? NULL : stream_dateop->nextNode(stream_dateop), root_1)); ++ ++ ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD)); ++ ADAPTOR->addChild(ADAPTOR, root_1, stream_datespec == NULL ? NULL : stream_datespec->nextTree(stream_datespec)); ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, root_1); ++ } ++ ++ } ++ ++ retval.tree = root_0; // set result root ++ if (stream_retval != NULL) stream_retval->free(stream_retval); ++ ++ ++ } ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruledatecritEx; /* Prevent compiler warnings */ ++ ruledatecritEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD); ++ if (stream_datespec != NULL) stream_datespec->free(stream_datespec); ++ if (stream_dateop != NULL) stream_dateop->free(stream_dateop); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end datecrit */ ++ ++/** ++ * $ANTLR start dateop ++ * RSP.g:66:1: dateop : ( BEFORE | AFTER ); ++ */ ++static RSPParser_dateop_return ++dateop(pRSPParser ctx) ++{ ++ RSPParser_dateop_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN set35; ++ ++ pANTLR3_BASE_TREE set35_tree; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ set35 = NULL; ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ set35_tree = NULL; ++ ++ ++ retval.tree = NULL; ++ { ++ // RSP.g:66:8: ( BEFORE | AFTER ) ++ // RSP.g: ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ set35=(pANTLR3_COMMON_TOKEN)LT(1); ++ if ( ((LA(1) >= BEFORE) && (LA(1) <= AFTER)) ) ++ { ++ CONSUME(); ++ ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set35))); ++ PERRORRECOVERY=ANTLR3_FALSE; ++ } ++ else ++ { ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; ++ EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; ++ EXCEPTION->expectingSet = &FOLLOW_set_in_dateop0; ++ RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_dateop0); goto ruledateopEx; ++ } ++ ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruledateopEx; /* Prevent compiler warnings */ ++ ruledateopEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end dateop */ ++ ++/** ++ * $ANTLR start datespec ++ * RSP.g:70:1: datespec : ( dateref | INT dateintval dateop dateref -> ^( dateop dateref INT dateintval ) ); ++ */ ++static RSPParser_datespec_return ++datespec(pRSPParser ctx) ++{ ++ RSPParser_datespec_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN INT37; ++ RSPParser_dateref_return dateref36; ++ #undef RETURN_TYPE_dateref36 ++ #define RETURN_TYPE_dateref36 RSPParser_dateref_return ++ ++ RSPParser_dateintval_return dateintval38; ++ #undef RETURN_TYPE_dateintval38 ++ #define RETURN_TYPE_dateintval38 RSPParser_dateintval_return ++ ++ RSPParser_dateop_return dateop39; ++ #undef RETURN_TYPE_dateop39 ++ #define RETURN_TYPE_dateop39 RSPParser_dateop_return ++ ++ RSPParser_dateref_return dateref40; ++ #undef RETURN_TYPE_dateref40 ++ #define RETURN_TYPE_dateref40 RSPParser_dateref_return ++ ++ pANTLR3_BASE_TREE INT37_tree; ++ pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_INT; ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateintval; ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateref; ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateop; ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ INT37 = NULL; ++ dateref36.tree = NULL; ++ ++ dateintval38.tree = NULL; ++ ++ dateop39.tree = NULL; ++ ++ dateref40.tree = NULL; ++ ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ INT37_tree = NULL; ++ ++ stream_INT = NULL; ++ #define CREATE_stream_INT if (stream_INT == NULL) {stream_INT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token INT"); } ++ stream_dateintval = NULL; ++ #define CREATE_stream_dateintval if (stream_dateintval == NULL) {stream_dateintval = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateintval"); } ++ stream_dateref = NULL; ++ #define CREATE_stream_dateref if (stream_dateref == NULL) {stream_dateref = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateref"); } ++ stream_dateop = NULL; ++ #define CREATE_stream_dateop if (stream_dateop == NULL) {stream_dateop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateop"); } ++ ++ retval.tree = NULL; ++ { ++ { ++ // RSP.g:70:9: ( dateref | INT dateintval dateop dateref -> ^( dateop dateref INT dateintval ) ) ++ ++ ANTLR3_UINT32 alt7; ++ ++ alt7=2; ++ ++ switch ( LA(1) ) ++ { ++ case DATE: ++ case TODAY: ++ { ++ alt7=1; ++ } ++ break; ++ case INT: ++ { ++ alt7=2; ++ } ++ break; ++ ++ default: ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; ++ EXCEPTION->message = (void *)""; ++ EXCEPTION->decisionNum = 7; ++ EXCEPTION->state = 0; ++ ++ ++ goto ruledatespecEx; ++ } ++ ++ switch (alt7) ++ { ++ case 1: ++ // RSP.g:70:11: dateref ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ FOLLOWPUSH(FOLLOW_dateref_in_datespec331); ++ dateref36=dateref(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatespecEx; ++ } ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, dateref36.tree); ++ ++ } ++ break; ++ case 2: ++ // RSP.g:71:4: INT dateintval dateop dateref ++ { ++ INT37 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_datespec336); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatespecEx; ++ } ++ ++ CREATE_stream_INT; stream_INT->add(stream_INT, INT37, NULL); ++ ++ FOLLOWPUSH(FOLLOW_dateintval_in_datespec338); ++ dateintval38=dateintval(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatespecEx; ++ } ++ ++ CREATE_stream_dateintval; stream_dateintval->add(stream_dateintval, dateintval38.tree, NULL); ++ FOLLOWPUSH(FOLLOW_dateop_in_datespec340); ++ dateop39=dateop(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatespecEx; ++ } ++ ++ CREATE_stream_dateop; stream_dateop->add(stream_dateop, dateop39.tree, NULL); ++ FOLLOWPUSH(FOLLOW_dateref_in_datespec342); ++ dateref40=dateref(ctx); ++ ++ FOLLOWPOP(); ++ if (HASEXCEPTION()) ++ { ++ goto ruledatespecEx; ++ } ++ ++ CREATE_stream_dateref; stream_dateref->add(stream_dateref, dateref40.tree, NULL); ++ ++ ++ /* AST REWRITE ++ * elements : dateintval, INT, dateref, dateop ++ * token labels : ++ * rule labels : retval ++ * token list labels : ++ * rule list labels : ++ */ ++ { ++ pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; ++ ++ stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); ++ ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ retval.tree = root_0; ++ // 71:34: -> ^( dateop dateref INT dateintval ) ++ { ++ // RSP.g:71:37: ^( dateop dateref INT dateintval ) ++ { ++ pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_dateop == NULL ? NULL : stream_dateop->nextNode(stream_dateop), root_1)); ++ ++ ADAPTOR->addChild(ADAPTOR, root_1, stream_dateref == NULL ? NULL : stream_dateref->nextTree(stream_dateref)); ++ ADAPTOR->addChild(ADAPTOR, root_1, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT)); ++ ADAPTOR->addChild(ADAPTOR, root_1, stream_dateintval == NULL ? NULL : stream_dateintval->nextTree(stream_dateintval)); ++ ++ ADAPTOR->addChild(ADAPTOR, root_0, root_1); ++ } ++ ++ } ++ ++ retval.tree = root_0; // set result root ++ if (stream_retval != NULL) stream_retval->free(stream_retval); ++ ++ ++ } ++ } ++ break; ++ ++ } ++ } ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruledatespecEx; /* Prevent compiler warnings */ ++ ruledatespecEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ if (stream_INT != NULL) stream_INT->free(stream_INT); ++ if (stream_dateintval != NULL) stream_dateintval->free(stream_dateintval); ++ if (stream_dateref != NULL) stream_dateref->free(stream_dateref); ++ if (stream_dateop != NULL) stream_dateop->free(stream_dateop); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end datespec */ ++ ++/** ++ * $ANTLR start dateref ++ * RSP.g:74:1: dateref : ( DATE | TODAY ); ++ */ ++static RSPParser_dateref_return ++dateref(pRSPParser ctx) ++{ ++ RSPParser_dateref_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN set41; ++ ++ pANTLR3_BASE_TREE set41_tree; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ set41 = NULL; ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ set41_tree = NULL; ++ ++ ++ retval.tree = NULL; ++ { ++ // RSP.g:74:9: ( DATE | TODAY ) ++ // RSP.g: ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ set41=(pANTLR3_COMMON_TOKEN)LT(1); ++ if ( ((LA(1) >= DATE) && (LA(1) <= TODAY)) ) ++ { ++ CONSUME(); ++ ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set41))); ++ PERRORRECOVERY=ANTLR3_FALSE; ++ } ++ else ++ { ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; ++ EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; ++ EXCEPTION->expectingSet = &FOLLOW_set_in_dateref0; ++ RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_dateref0); goto ruledaterefEx; ++ } ++ ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruledaterefEx; /* Prevent compiler warnings */ ++ ruledaterefEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end dateref */ ++ ++/** ++ * $ANTLR start dateintval ++ * RSP.g:78:1: dateintval : ( DAY | WEEK | MONTH | YEAR ); ++ */ ++static RSPParser_dateintval_return ++dateintval(pRSPParser ctx) ++{ ++ RSPParser_dateintval_return retval; ++ ++ pANTLR3_BASE_TREE root_0; ++ ++ pANTLR3_COMMON_TOKEN set42; ++ ++ pANTLR3_BASE_TREE set42_tree; ++ ++ /* Initialize rule variables ++ */ ++ ++ ++ root_0 = NULL; ++ ++ set42 = NULL; ++ retval.start = LT(1); retval.stop = retval.start; ++ ++ set42_tree = NULL; ++ ++ ++ retval.tree = NULL; ++ { ++ // RSP.g:79:2: ( DAY | WEEK | MONTH | YEAR ) ++ // RSP.g: ++ { ++ root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); ++ ++ set42=(pANTLR3_COMMON_TOKEN)LT(1); ++ if ( ((LA(1) >= DAY) && (LA(1) <= YEAR)) ) ++ { ++ CONSUME(); ++ ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set42))); ++ PERRORRECOVERY=ANTLR3_FALSE; ++ } ++ else ++ { ++ CONSTRUCTEX(); ++ EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; ++ EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; ++ EXCEPTION->expectingSet = &FOLLOW_set_in_dateintval0; ++ RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_dateintval0); goto ruledateintvalEx; ++ } ++ ++ ++ } ++ ++ } ++ ++ ++ // This is where rules clean up and exit ++ // ++ goto ruledateintvalEx; /* Prevent compiler warnings */ ++ ruledateintvalEx: ; ++ retval.stop = LT(-1); ++ ++ retval.stop = LT(-1); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ++ ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); ++ ++ if (HASEXCEPTION()) ++ { ++ PREPORTERROR(); ++ PRECOVER(); ++ retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); ++ } ++ ++ ++ return retval; ++} ++/* $ANTLR end dateintval */ ++/* End of parsing rules ++ * ============================================== ++ */ ++ ++/* ============================================== ++ * Syntactic predicates ++ */ ++/* End of syntactic predicates ++ * ============================================== ++ */ ++ ++ ++ ++ ++ ++ ++/* End of code ++ * ============================================================================= ++ */ +diff --git a/src/pregen/RSPParser.h b/src/pregen/RSPParser.h +new file mode 100644 +index 0000000..d0744a2 +--- /dev/null ++++ b/src/pregen/RSPParser.h +@@ -0,0 +1,365 @@ ++/** \file ++ * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3 ++ * ++ * - From the grammar source file : RSP.g ++ * - On : 2014-09-30 21:42:40 ++ * - for the parser : RSPParserParser * ++ * Editing it, at least manually, is not wise. ++ * ++ * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. ++ * ++ * ++ * The parser RSPParser has the callable functions (rules) shown below, ++ * which will invoke the code for the associated rule in the source grammar ++ * assuming that the input stream is pointing to a token/text stream that could begin ++ * this rule. ++ * ++ * For instance if you call the first (topmost) rule in a parser grammar, you will ++ * get the results of a full parse, but calling a rule half way through the grammar will ++ * allow you to pass part of a full token stream to the parser, such as for syntax checking ++ * in editors and so on. ++ * ++ * The parser entry points are called indirectly (by function pointer to function) via ++ * a parser context typedef pRSPParser, which is returned from a call to RSPParserNew(). ++ * ++ * The methods in pRSPParser are as follows: ++ * ++ * - RSPParser_query_return pRSPParser->query(pRSPParser) ++ * - RSPParser_expr_return pRSPParser->expr(pRSPParser) ++ * - RSPParser_aexpr_return pRSPParser->aexpr(pRSPParser) ++ * - RSPParser_crit_return pRSPParser->crit(pRSPParser) ++ * - RSPParser_strcrit_return pRSPParser->strcrit(pRSPParser) ++ * - RSPParser_strop_return pRSPParser->strop(pRSPParser) ++ * - RSPParser_intcrit_return pRSPParser->intcrit(pRSPParser) ++ * - RSPParser_intop_return pRSPParser->intop(pRSPParser) ++ * - RSPParser_datecrit_return pRSPParser->datecrit(pRSPParser) ++ * - RSPParser_dateop_return pRSPParser->dateop(pRSPParser) ++ * - RSPParser_datespec_return pRSPParser->datespec(pRSPParser) ++ * - RSPParser_dateref_return pRSPParser->dateref(pRSPParser) ++ * - RSPParser_dateintval_return pRSPParser->dateintval(pRSPParser) ++ * ++ * The return type for any particular rule is of course determined by the source ++ * grammar file. ++ */ ++// [The "BSD licence"] ++// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC ++// http://www.temporal-wave.com ++// http://www.linkedin.com/in/jimidle ++// ++// All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions ++// are met: ++// 1. Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// 2. Redistributions in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// 3. The name of the author may not be used to endorse or promote products ++// derived from this software without specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++#ifndef _RSPParser_H ++#define _RSPParser_H ++/* ============================================================================= ++ * Standard antlr3 C runtime definitions ++ */ ++#include ++ ++/* End of standard antlr 3 runtime definitions ++ * ============================================================================= ++ */ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++// Forward declare the context typedef so that we can use it before it is ++// properly defined. Delegators and delegates (from import statements) are ++// interdependent and their context structures contain pointers to each other ++// C only allows such things to be declared if you pre-declare the typedef. ++// ++typedef struct RSPParser_Ctx_struct RSPParser, * pRSPParser; ++ ++ ++ ++#ifdef ANTLR3_WINDOWS ++// Disable: Unreferenced parameter, - Rules with parameters that are not used ++// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) ++// initialized but unused variable - tree rewrite variables declared but not needed ++// Unreferenced local variable - lexer rule declares but does not always use _type ++// potentially unitialized variable used - retval always returned from a rule ++// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns ++// ++// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at ++// and the codegen must generate some of these warnings by necessity, apart from 4100, which is ++// usually generated when a parser rule is given a parameter that it does not use. Mostly though ++// this is a matter of orthogonality hence I disable that one. ++// ++#pragma warning( disable : 4100 ) ++#pragma warning( disable : 4101 ) ++#pragma warning( disable : 4127 ) ++#pragma warning( disable : 4189 ) ++#pragma warning( disable : 4505 ) ++#pragma warning( disable : 4701 ) ++#endif ++typedef struct RSPParser_query_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ RSPParser_query_return; ++ ++typedef struct RSPParser_expr_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ RSPParser_expr_return; ++ ++typedef struct RSPParser_aexpr_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ RSPParser_aexpr_return; ++ ++typedef struct RSPParser_crit_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ RSPParser_crit_return; ++ ++typedef struct RSPParser_strcrit_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ RSPParser_strcrit_return; ++ ++typedef struct RSPParser_strop_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ RSPParser_strop_return; ++ ++typedef struct RSPParser_intcrit_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ RSPParser_intcrit_return; ++ ++typedef struct RSPParser_intop_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ RSPParser_intop_return; ++ ++typedef struct RSPParser_datecrit_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ RSPParser_datecrit_return; ++ ++typedef struct RSPParser_dateop_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ RSPParser_dateop_return; ++ ++typedef struct RSPParser_datespec_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ RSPParser_datespec_return; ++ ++typedef struct RSPParser_dateref_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ RSPParser_dateref_return; ++ ++typedef struct RSPParser_dateintval_return_struct ++{ ++ /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees ++ */ ++ pANTLR3_COMMON_TOKEN start; ++ pANTLR3_COMMON_TOKEN stop; ++ pANTLR3_BASE_TREE tree; ++ ++} ++ RSPParser_dateintval_return; ++ ++ ++ ++/** Context tracking structure for RSPParser ++ */ ++struct RSPParser_Ctx_struct ++{ ++ /** Built in ANTLR3 context tracker contains all the generic elements ++ * required for context tracking. ++ */ ++ pANTLR3_PARSER pParser; ++ ++ ++ RSPParser_query_return (*query) (struct RSPParser_Ctx_struct * ctx); ++ RSPParser_expr_return (*expr) (struct RSPParser_Ctx_struct * ctx); ++ RSPParser_aexpr_return (*aexpr) (struct RSPParser_Ctx_struct * ctx); ++ RSPParser_crit_return (*crit) (struct RSPParser_Ctx_struct * ctx); ++ RSPParser_strcrit_return (*strcrit) (struct RSPParser_Ctx_struct * ctx); ++ RSPParser_strop_return (*strop) (struct RSPParser_Ctx_struct * ctx); ++ RSPParser_intcrit_return (*intcrit) (struct RSPParser_Ctx_struct * ctx); ++ RSPParser_intop_return (*intop) (struct RSPParser_Ctx_struct * ctx); ++ RSPParser_datecrit_return (*datecrit) (struct RSPParser_Ctx_struct * ctx); ++ RSPParser_dateop_return (*dateop) (struct RSPParser_Ctx_struct * ctx); ++ RSPParser_datespec_return (*datespec) (struct RSPParser_Ctx_struct * ctx); ++ RSPParser_dateref_return (*dateref) (struct RSPParser_Ctx_struct * ctx); ++ RSPParser_dateintval_return (*dateintval) (struct RSPParser_Ctx_struct * ctx); ++ // Delegated rules ++ const char * (*getGrammarFileName)(); ++ void (*free) (struct RSPParser_Ctx_struct * ctx); ++ /* @headerFile.members() */ ++ pANTLR3_BASE_TREE_ADAPTOR adaptor; ++ pANTLR3_VECTOR_FACTORY vectors; ++ /* End @headerFile.members() */ ++}; ++ ++// Function protoypes for the constructor functions that external translation units ++// such as delegators and delegates may wish to call. ++// ++ANTLR3_API pRSPParser RSPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream); ++ANTLR3_API pRSPParser RSPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); ++ ++/** Symbolic definitions of all the tokens that the parser will work with. ++ * \{ ++ * ++ * Antlr will define EOF, but we can't use that as it it is too common in ++ * in C header files and that would be confusing. There is no way to filter this out at the moment ++ * so we just undef it here for now. That isn't the value we get back from C recognizers ++ * anyway. We are looking for ANTLR3_TOKEN_EOF. ++ */ ++#ifdef EOF ++#undef EOF ++#endif ++#ifdef Tokens ++#undef Tokens ++#endif ++#define STARTSW 14 ++#define WEEK 26 ++#define TODAY 24 ++#define YEAR 28 ++#define ENDSW 15 ++#define GTE 20 ++#define BEFORE 21 ++#define DAY 25 ++#define INT 16 ++#define NOT 11 ++#define AFTER 22 ++#define AND 6 ++#define EOF -1 ++#define LTE 19 ++#define MONTH 27 ++#define DIGIT19 31 ++#define INCLUDES 13 ++#define STR 10 ++#define QUOTE 29 ++#define WS 30 ++#define GREATER 18 ++#define NEWLINE 4 ++#define LPAR 7 ++#define EQUAL 12 ++#define OR 5 ++#define LESS 17 ++#define RPAR 8 ++#define FIELD 9 ++#define ESCAPED 33 ++#define DATE 23 ++#define DIGIT09 32 ++#ifdef EOF ++#undef EOF ++#define EOF ANTLR3_TOKEN_EOF ++#endif ++ ++#ifndef TOKENSOURCE ++#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource ++#endif ++ ++/* End of token definitions for RSPParser ++ * ============================================================================= ++ */ ++/** \} */ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif ++ ++/* END - Note:Keep extra line feed to satisfy UNIX systems */ From bfcfcc48c3b3fa939dae4214833a6aac03534138 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Sat, 18 Oct 2014 23:00:03 +0200 Subject: [PATCH 22/27] irssi: update to 0.8.17 Signed-off-by: Peter Wagner --- net/irssi/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/irssi/Makefile b/net/irssi/Makefile index 2f920498d..3fbfef115 100644 --- a/net/irssi/Makefile +++ b/net/irssi/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=irssi -PKG_VERSION:=0.8.16 +PKG_VERSION:=0.8.17 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=http://irssi.org/files/ -PKG_MD5SUM:=4346119c4c000d0198cda17666ff1f06 +PKG_MD5SUM:=ecf64be47978d89a742b435a81cb47db PKG_FIXUP:=autoreconf PKG_INSTALL:=1 From 1a911c1fe5d663e612b9659a85770dbd7388b24d Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 19 Oct 2014 00:35:17 +0200 Subject: [PATCH 23/27] lvm2: add from old repo and update Also add patch to fix blkid header location as suggested in #17877 Signed-off-by: Daniel Golle --- utils/lvm2/Makefile | 89 ++++++++++++++++++++++++ utils/lvm2/files/lvm2.init | 12 ++++ utils/lvm2/patches/000-compile.patch | 11 +++ utils/lvm2/patches/001-include_fix.patch | 12 ++++ 4 files changed, 124 insertions(+) create mode 100644 utils/lvm2/Makefile create mode 100644 utils/lvm2/files/lvm2.init create mode 100644 utils/lvm2/patches/000-compile.patch create mode 100644 utils/lvm2/patches/001-include_fix.patch diff --git a/utils/lvm2/Makefile b/utils/lvm2/Makefile new file mode 100644 index 000000000..1a0094493 --- /dev/null +++ b/utils/lvm2/Makefile @@ -0,0 +1,89 @@ +# +# Copyright (C) 2009-2010 Stefan Monnier +# Copyright (C) 2011-2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v3+. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=LVM2 +PKG_VERSION:=2.02.111 +PKG_RELEASE:=1 +PKG_LICENSE:=GPL-2.0 LGPL-2.1 + +PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz +PKG_SOURCE_URL:=ftp://sources.redhat.com/pub/lvm2 +PKG_MD5SUM:=02487ab2a9e02d1ee76fe217183df28a +PKG_MAINTAINER:=Daniel Golle +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME).$(PKG_VERSION) + +include $(INCLUDE_DIR)/package.mk + +define Package/libdevmapper + SECTION:=libs + CATEGORY:=Libraries + TITLE:=The Linux Kernel Device Mapper userspace library + URL:=http://sourceware.org/dm/ + DEPENDS:=+kmod-dm +libpthread +endef + +define Package/libdevmapper/description + The device-mapper is a component of the 2.6 linux kernel that supports logical + volume management. It is required by LVM2 and EVMS. +endef + +define Package/lvm2 + SECTION:=utils + CATEGORY:=Utilities + SUBMENU:=disc + TITLE:=The Linux Logical Volume Manager + URL:=http://sourceware.org/lvm2/ + DEPENDS:=+libdevmapper +libblkid +libreadline +libncurses +endef + +define Package/lvm2/description + LVM2 refers to a new userspace toolset that provide logical volume management + facilities on linux. It is reasonably backwards-compatible with the original + LVM toolset. +endef + +CONFIGURE_ARGS += --disable-o_direct + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(FPIC)" \ + DESTDIR="$(PKG_INSTALL_DIR)" \ + install +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/include/libdevmapper.h $(1)/usr/include + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libdevmapper.so* $(1)/usr/lib + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_BUILD_DIR)/libdm/libdevmapper.pc $(1)/usr/lib/pkgconfig +endef + +define Package/libdevmapper/install + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libdevmapper.so.* $(1)/usr/lib +endef + +define Package/lvm2/install + $(INSTALL_DIR) $(1)/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/lvm $(1)/sbin + $(INSTALL_DIR) $(1)/etc/lvm + $(INSTALL_CONF) $(PKG_BUILD_DIR)/conf/example.conf $(1)/etc/lvm/lvm.conf + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/lvm2.init $(1)/etc/init.d/lvm2 +endef + +define Package/lvm2/conffiles +/etc/lvm/lvm.conf +endef + +$(eval $(call BuildPackage,libdevmapper)) +$(eval $(call BuildPackage,lvm2)) diff --git a/utils/lvm2/files/lvm2.init b/utils/lvm2/files/lvm2.init new file mode 100644 index 000000000..3b542d023 --- /dev/null +++ b/utils/lvm2/files/lvm2.init @@ -0,0 +1,12 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2009 Stefan Monnier +START=15 + +start () { + /sbin/lvm vgscan --ignorelockingfailure --mknodes || : + /sbin/lvm vgchange -aly --ignorelockingfailure || return 2 +} + +stop () { + /sbin/lvm vgchange -aln --ignorelockingfailure || return 2 +} diff --git a/utils/lvm2/patches/000-compile.patch b/utils/lvm2/patches/000-compile.patch new file mode 100644 index 000000000..0c7dfea7f --- /dev/null +++ b/utils/lvm2/patches/000-compile.patch @@ -0,0 +1,11 @@ +--- a/make.tmpl.in ++++ b/make.tmpl.in +@@ -19,7 +19,7 @@ + + # Allow environment to override any built-in default value for CC. + # If there is a built-in default, CC is NOT set to @CC@ here. +-CC ?= @CC@ ++CC = @CC@ + + # If $(CC) holds the usual built-in default value of 'cc' then replace it with + # the configured value. diff --git a/utils/lvm2/patches/001-include_fix.patch b/utils/lvm2/patches/001-include_fix.patch new file mode 100644 index 000000000..0c79d5da1 --- /dev/null +++ b/utils/lvm2/patches/001-include_fix.patch @@ -0,0 +1,12 @@ +diff -urN LVM2.2.02.111.old/lib/device/dev-type.c LVM2.2.02.111/lib/device/dev-type.c +--- LVM2.2.02.111.old/lib/device/dev-type.c 2014-09-17 09:41:08.281821278 -0400 ++++ LVM2.2.02.111/lib/device/dev-type.c 2014-09-17 09:41:50.773821280 -0400 +@@ -22,7 +22,7 @@ + #include + + #ifdef BLKID_WIPING_SUPPORT +-#include ++#include + #endif + + #include "device-types.h" From 30bdda47fbbaef2a18b89cb4d7e527f0cc3cf0dc Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Sun, 19 Oct 2014 04:44:24 +0200 Subject: [PATCH 24/27] openssh: update to 6.7p1 Signed-off-by: Peter Wagner --- net/openssh/Makefile | 4 ++-- net/openssh/patches/100-no_cast_fix.patch | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/openssh/Makefile b/net/openssh/Makefile index ba4cb38c1..526759cf1 100644 --- a/net/openssh/Makefile +++ b/net/openssh/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=openssh -PKG_VERSION:=6.6p1 +PKG_VERSION:=6.7p1 PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/ \ http://ftp.belnet.be/pub/OpenBSD/OpenSSH/portable/ -PKG_MD5SUM:=3e9800e6bca1fbac0eea4d41baa7f239 +PKG_MD5SUM:=3246aa79317b1d23cae783a3bf8275d6 PKG_LICENSE:=BSD ISC PKG_LICENSE_FILE:=LICENCE diff --git a/net/openssh/patches/100-no_cast_fix.patch b/net/openssh/patches/100-no_cast_fix.patch index 751e5896f..5a4ecb122 100644 --- a/net/openssh/patches/100-no_cast_fix.patch +++ b/net/openssh/patches/100-no_cast_fix.patch @@ -1,6 +1,6 @@ --- a/cipher.c +++ b/cipher.c -@@ -80,8 +80,10 @@ static const struct Cipher ciphers[] = { +@@ -88,8 +88,10 @@ static const struct sshcipher ciphers[] { "3des-cbc", SSH_CIPHER_SSH2, 8, 24, 0, 0, 0, 1, EVP_des_ede3_cbc }, { "blowfish-cbc", SSH_CIPHER_SSH2, 8, 16, 0, 0, 0, 1, EVP_bf_cbc }, From 169c863286ea74f27f6644063d18d86452df6d4a Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Sun, 19 Oct 2014 04:57:17 +0200 Subject: [PATCH 25/27] dovecot: update to 2.2.14 Signed-off-by: Peter Wagner --- mail/dovecot/Makefile | 6 +++--- mail/dovecot/patches/001-configure_in.patch | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mail/dovecot/Makefile b/mail/dovecot/Makefile index 131ae7740..275fcb285 100644 --- a/mail/dovecot/Makefile +++ b/mail/dovecot/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=dovecot -PKG_VERSION:=2.2.13 -PKG_RELEASE:=2 +PKG_VERSION:=2.2.14 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://www.dovecot.org/releases/2.2 -PKG_MD5SUM:=a3eb1c0b1822c4f2b0fe9247776baa71 +PKG_MD5SUM:=03315255920ee1c4b11039945246a8af PKG_LICENSE:=LGPL-2.1 MIT BSD-3-Clause Unique PKG_LICENSE_FILES:=COPYING COPYING.LGPL COPYING.MIT diff --git a/mail/dovecot/patches/001-configure_in.patch b/mail/dovecot/patches/001-configure_in.patch index 69328cb7d..70642d648 100644 --- a/mail/dovecot/patches/001-configure_in.patch +++ b/mail/dovecot/patches/001-configure_in.patch @@ -12,7 +12,7 @@ int main() { return epoll_create(5) < 1; -@@ -675,7 +675,7 @@ fi +@@ -639,7 +639,7 @@ fi dnl * Old glibcs have broken posix_fallocate(). Make sure not to use it. dnl * It may also be broken in AIX. AC_CACHE_CHECK([whether posix_fallocate() works],i_cv_posix_fallocate_works,[ @@ -21,7 +21,7 @@ #define _XOPEN_SOURCE 600 #include #include -@@ -684,6 +684,7 @@ AC_CACHE_CHECK([whether posix_fallocate( +@@ -648,6 +648,7 @@ AC_CACHE_CHECK([whether posix_fallocate( #if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 7) possibly broken posix_fallocate #endif From 3285adb57241f9b8f2c551d57a938e8ccf8e0cbf Mon Sep 17 00:00:00 2001 From: Matthias-Christian Ott Date: Sat, 18 Oct 2014 21:59:23 +0200 Subject: [PATCH 26/27] knot: Split utils subpackage knot-utils consists of kdig, khost, knsec3hash and knsupdate. In order to reduce the size of software installed on a device it is useful to include a minimal collection of software and thus it should be possible to install the utilities individually. bind also creates a subpackage for each utility. Signed-off-by: Matthias-Christian Ott --- net/knot/Makefile | 61 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/net/knot/Makefile b/net/knot/Makefile index 23740b229..2b6c8f335 100644 --- a/net/knot/Makefile +++ b/net/knot/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=knot PKG_VERSION:=1.5.3 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) @@ -46,9 +46,27 @@ define Package/knot DEPENDS+=+knot-libknot endef -define Package/knot-utils +define Package/knot-dig $(call Package/knot/Default) - TITLE+= (utils) + TITLE+= lookup utility + DEPENDS+=+knot-libknot +endef + +define Package/knot-host + $(call Package/knot/Default) + TITLE+= simple DNS lookup utility + DEPENDS+=+knot-libknot +endef + +define Package/knot-nsec3hash + $(call Package/knot/Default) + TITLE+= simple NSEC3 hash utility + DEPENDS+=+knot-libknot +endef + +define Package/knot-nsupdate + $(call Package/knot/Default) + TITLE+= dynamic DNS update utility DEPENDS+=+knot-libknot endef @@ -66,8 +84,20 @@ define Package/knot/description High-performance authoritative-only DNS server. endef -define Package/knot-utils/description - DNS utilities: kdig, khost, knsupdate and knsec3hash. +define Package/knot-dig/description + Knot DNS lookup utility. +endef + +define Package/knot-host/description + Knot DNS simple DNS lookup utility. +endef + +define Package/knot-nsec3hash/description + Knot DNS simple utility to compute NSEC3 hash. +endef + +define Package/knot-nsupdate/description + Knot DNS dynamic DNS update utility. endef define Package/knot-tests/description @@ -114,14 +144,26 @@ define Package/knot/install $(INSTALL_BIN) ./files/knotd.init $(1)/etc/init.d/knotd endef -define Package/knot-utils/install +define Package/knot-dig/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/kdig $(1)/usr/bin/ +endef + +define Package/knot-host/install + $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/khost $(1)/usr/bin/ - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/knsupdate $(1)/usr/bin/ +endef + +define Package/knot-nsec3hash/install + $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/knsec3hash $(1)/usr/bin/ endef +define Package/knot-nsupdate/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/knsupdate $(1)/usr/bin/ +endef + define Package/knot-tests/install $(INSTALL_DIR) $(1)/usr/share/knot $(INSTALL_BIN) ./files/runtests.sh $(1)/usr/share/knot/ @@ -146,5 +188,8 @@ endef $(eval $(call BuildPackage,knot-libknot)) $(eval $(call BuildPackage,knot)) -$(eval $(call BuildPackage,knot-utils)) +$(eval $(call BuildPackage,knot-dig)) +$(eval $(call BuildPackage,knot-host)) +$(eval $(call BuildPackage,knot-nsec3hash)) +$(eval $(call BuildPackage,knot-nsupdate)) $(eval $(call BuildPackage,knot-tests)) From 0ecfc499ce764cc5d1e483879bc9345b3f22a59b Mon Sep 17 00:00:00 2001 From: Marty R Date: Sun, 19 Oct 2014 09:40:02 -0700 Subject: [PATCH 27/27] nut: Updated (c) notice Signed-off-by: Martin Rowe --- net/nut/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/nut/Makefile b/net/nut/Makefile index 0666dd0ee..a0125c487 100644 --- a/net/nut/Makefile +++ b/net/nut/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2006-2014 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information.