From 30113be459532482d327ef418d2b1ff93c333228 Mon Sep 17 00:00:00 2001 From: Stefano Sanfilippo Date: Sat, 29 Nov 2014 11:11:43 +0100 Subject: [PATCH] Bison 2.5 compatibility patch and make target. --- Makefile | 9 +++++++++ README.md | 10 +++++++++- bison2.patch | 28 ++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 bison2.patch diff --git a/Makefile b/Makefile index de9c274..cd8dfe6 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,8 @@ default: compile cleanautogen +bison2: patch2 default unpatch2 + compile: bison Monicelli.ypp flex Monicelli.lpp @@ -26,6 +28,13 @@ compile: -Wall -Wno-deprecated-register -std=c++11 -DYYDEBUG=0 -O2 \ Parser.cpp lex.yy.cc Nodes.cpp main.cpp -o mcc +patch2: + # Bison 2 compatibility patch + patch -r - -p 1 -N < bison2.patch || true + +unpatch2: + patch -p 1 -R < bison2.patch + graph: bison --graph Monicelli.y diff --git a/README.md b/README.md index 732cefe..f86ce01 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,15 @@ executable is a matter of: make -there are some other targets, which are of interest only for developers. +A patch is provided for compatibility with Bison 2.5. If you can't really +upgrade to Bison 3.0, and I strongly recommend that, you can always compile +with: + + make bison2 + +However, note that this is not supported and might be removed in a future release. + +There are some other targets, which are of interest only for developers. Usage ===== diff --git a/bison2.patch b/bison2.patch new file mode 100644 index 0000000..523e805 --- /dev/null +++ b/bison2.patch @@ -0,0 +1,28 @@ +diff --git a/Monicelli.ypp b/Monicelli.ypp +index 028506d..9817f1e 100644 +--- a/Monicelli.ypp ++++ b/Monicelli.ypp +@@ -23,7 +23,7 @@ + } + + %skeleton "lalr1.cc" +-%require "3.0" ++%require "2.5" + %language "c++" + + %defines +@@ -31,9 +31,11 @@ + %locations + %token-table + +-%define parse.error verbose +-%define api.namespace {monicelli} +-%define parser_class_name {Parser} ++%{ ++#define YYERROR_VERBOSE ++%} ++%define namespace monicelli ++%define parser_class_name Parser + + %lex-param {Scanner &scanner} + %parse-param {Scanner &scanner}