I am using the autotools in combination with GNU Bison and Flex. In
particular I am using the %glr directive in my bison file (parse.y).
Everything works fine, except that when I run 'make', 'ylwrap' is
invoked which runs 'bison -y -d' on 'parse.y' producing 'y.tab.h' and
'y.tab.c'. 'ylwrap' then renames these output files to 'parse.h' and
'parse.c' (Forgive me if I have the details wrong. I claim no
expertise). The problem is that the y.tab.c produced from the glr
skeleton with the -d bison option has in '#include y.tab.h' CPP
directive in it. This really should be changed by ylwrap to '#include
parse.h', but it isn't. The autotools do nothing about this problem.
I am attaching my 'parse.y' file. You can run bison -y -d on it to
simulate the problem. Notice that in the resulting y.tab.c file, there
is an #include y.tab.h line. This line won't work because y.tab.h will
be changed to parse.h by ylwrap (or however its done).
As a work around I inserted the following lines into ylwrap.
base=`basename $target .c`
echo $target
mv $target $target.tmp
sed -e 's,y.tab.h,'$base'.h,g' $target.tmp $target
This works for now but I rather not have to have workarounds. I am
attaching my modified ylwrap file, my parse.y file and my Makefile.am.
ylwrap
Description: application/shellscript
/*
Hermetica Mathematical Tool
Copyright 2009 Hermes T.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
*/
%{
#include config.h
#include stdlib.h
#include stdio.h
#include string.h
#include gtk/gtk.h
#include global_strings.h
#include general.h
#include h_object.h
#include symbols.h
#include h_array.h
#include h_sequence.h
#include h_list.h
#include h_string.h
#include h_int.h
#include operator.h
#include pattern.h
#include namespace.h
#include atom.h
#include semtype.h
#include subexp.h
#include prototype.h
#include proof.h
#include justification.h
#include proofline.h
#include memheap.h
#include global_h_objects.h
#include pattern_walk.h
#include parserlib.h
#include scanner.h
#define YYERROR_VERBOSE 1
#define YYENABLE_NLS 1
%}
%union {
char ch;
subexp *subexpression;
h_str *h_string;
h_int *h_number;
operator op;
quantifier qu;
h_list *list;
proofline *pline;
justification *just;
semantic_type *st;
atom *at;
prototype *prot;
pattern *pat;
proof *prf;
symbol_type symbol;
}
%token h_string TOK_STRING TOK_OPENBRACKET TOK_CLOSEBRACKET TOK_OPENSETBRACKET TOK_CLOSESETBRACKET TOK_STICK TOK_COLON TOK_THEREEXISTS TOK_FORALL TOK_SELECTOR TOK_COMMA TOK_OPENSQUAREBRACKET TOK_CLOSESQUAREBRACKET TOK_UNKNOWN TOK_ESCREAM TOK_LAMBDA TOK_DEDUCTION TOK_VAR TOK_CONST TOK_NAMESPACE TOK_NUMSIGN TOK_USE TOK_WITH TOK_EQUALBYDEF TOK_DOT TOK_MACRO TOK_SEMICOLON
%token h_number TOK_NUMBER
%token chTOK_CHAR
%token justTOK_EMBEDDEDJUST
%token symbolTOK_TEMPLATESYMBOL
%right TOK_LOGICALEQUIVALENCE
%right TOK_IMPLIES
%left TOK_OR
%left TOK_AND
%left TOK_NOT
%right TOK_EQUALS TOK_LESSTHAN TOK_GREATERTHAN TOK_LESSTHANEQUALTO TOK_GREATERTHANEQUALTO TOK_SUPERSET TOK_NONSTRICTSUPERSET TOK_ELEMENTOF TOK_IDENTICAL TOK_SUBSET TOK_NONSTRICTSUBSET TOK_NEQ TOK_NNONSTRICTSUBSET TOK_NNONSTRICTSUPERSET TOK_NSUBSET TOK_NSUPERSET
%left TOK_UNION
%left TOK_INTERSECTION TOK_SETSUBTRACTION
%left TOK_CROSSPRODUCT
%left TOK_PLUS
%left TOK_TIMES TOK_DIV TOK_RINGOPERATOR
%left TOK_HYPHEN
%right TOK_EXPONENT
%right TOK_AT
%type opop
%type subexpression unit subexp quantifierexp opexp funceval sequence listset pairset tuple lambdaexp
%type ququantifier
%type listns_list subexplist atom_list semarglist semarglist2 subexplist2 prooflinelist pattern_list
%type plineproofline
%type justjustification usual_justification
%type stsemtype
%type atatom tagged_atom untagged_atom
%type protprototype proto_opexp
%type patpattern patternunit
%type prfproof topnode
%glr-parser
%pure-parser
%locations
%%
topnode:proof
{
topnode=$1; //topnode has a refcount of 1 for being
//in memheap
//WE DO NOT! REF THE TOPNODE. DEAL WITH REFCOUNT
//INSTEAD IN proof_fromstring.
//There was an issue where this rule could
//actually fire twice in a single parse
//when there were syntax errors.
//THe result was uncollected garbage
}
;
proof: prooflinelist
{
h_array *linearray;
linearray=h_list_toarray($1,);
set_pos_from_loc(@1,(h_object *)linearray);