From be36c292cf875904599e45d49e4f8b2f8b4e9ca6 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 26 Nov 2009 07:55:42 +0000 Subject: [PATCH 1/1] I hate the Bison 2.3/2.4 split. --- Cycript.yy.in | 22 +++++++++++++--------- Filter.sh | 9 ++++++++- makefile | 2 ++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Cycript.yy.in b/Cycript.yy.in index ece104f..46cbd68 100644 --- a/Cycript.yy.in +++ b/Cycript.yy.in @@ -37,13 +37,15 @@ */ /* }}} */ -%{ +@if Bison23 %{ + +@if Bison24 %code top { #define cyscanner driver.scanner_ #define YYSTACKEXPANDABLE 1 #define yyerrok (yyerrstatus_ = 0) -%} +@if Bison24 } -%{ +@if Bison24 %code requires { #include "Parser.hpp" @begin ObjectiveC @@ -112,22 +114,24 @@ typedef struct { } YYSTYPE; #define YYSTYPE YYSTYPE +@if Bison24 } -%} - -%{ +@if Bison24 %code provides { int cylex(YYSTYPE *, cy::location *, void *); -%} +@if Bison24 } + +@if Bison23 %} %name-prefix="cy" -%skeleton "lalr1.cc" -%locations +@if Bison23 %skeleton "lalr1.cc" +@if Bison24 %language "C++" %initial-action { @$.begin.filename = @$.end.filename = &driver.filename_; }; +%locations %defines //%glr-parser diff --git a/Filter.sh b/Filter.sh index 7135d28..bb76b0a 100755 --- a/Filter.sh +++ b/Filter.sh @@ -3,7 +3,14 @@ filters=("$@") while IFS= read -r line; do - if [[ ${line} = @begin* ]]; then + if [[ ${line} = @if* ]]; then + line=${line#@if } + for name in "${filters[@]}"; do + if [[ ${line} = ${name}' '* ]]; then + echo "${line#${name} }" + fi + done + elif [[ ${line} = @begin* ]]; then set ${line}; shift filter= for name in "${filters[@]}"; do diff --git a/makefile b/makefile index 3100f0a..61768dd 100644 --- a/makefile +++ b/makefile @@ -64,6 +64,8 @@ flags += -I. -Iinclude -I$(shell apr-1-config --includedir) all += $(lib)cycript.$(dll) +filters += $(shell bison <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23) + ifdef arch deb := $(shell grep ^Package: control.in | cut -d ' ' -f 2-)_$(shell grep ^Version: control.in | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb -- 2.45.2