mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 00:33:03 +00:00
2006-10-08 Paolo Bonzini <bonzini@gnu.org>
* data/c.m4 (b4_copyright, b4_epilogue, b4_location_initial_column,
b4_location_initial_line, p4_parse_param, b4_ints_in, b4_flag_if,
b4_define_flag_if and uses, b4_basename, b4_syncline, b4_user_code,
b4_define_user_cde and uses): Remove.
(b4_comment, b4_prefix, b4_sync_start): New.
* data/bison.m4: New file, with most of the content removed from c.m4.
* src/muscle_tab.h: Use "do {...} while(0)" throughout.
* src/output.c (output_skeleton): Pass bison.m4.
(prepare): Pass glr_flag and nondeterministic_flag. Pass prefix
only if specified.
This commit is contained in:
13
ChangeLog
13
ChangeLog
@@ -1,3 +1,16 @@
|
|||||||
|
2006-10-08 Paolo Bonzini <bonzini@gnu.org>
|
||||||
|
|
||||||
|
* data/c.m4 (b4_copyright, b4_epilogue, b4_location_initial_column,
|
||||||
|
b4_location_initial_line, p4_parse_param, b4_ints_in, b4_flag_if,
|
||||||
|
b4_define_flag_if and uses, b4_basename, b4_syncline, b4_user_code,
|
||||||
|
b4_define_user_cde and uses): Remove.
|
||||||
|
(b4_comment, b4_prefix, b4_sync_start): New.
|
||||||
|
* data/bison.m4: New file, with most of the content removed from c.m4.
|
||||||
|
* src/muscle_tab.h: Use "do {...} while(0)" throughout.
|
||||||
|
* src/output.c (output_skeleton): Pass bison.m4.
|
||||||
|
(prepare): Pass glr_flag and nondeterministic_flag. Pass prefix
|
||||||
|
only if specified.
|
||||||
|
|
||||||
2006-10-05 Paul Eggert <eggert@cs.ucla.edu>
|
2006-10-05 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
Fix test failure reported by Tom Lane in
|
Fix test failure reported by Tom Lane in
|
||||||
|
|||||||
191
data/bison.m4
Normal file
191
data/bison.m4
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
m4_divert(-1) -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Language-independent M4 Macros for Bison.
|
||||||
|
# Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# 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 2 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, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
# 02110-1301 USA
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## Identification. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
# b4_copyright(TITLE, YEARS)
|
||||||
|
# --------------------------
|
||||||
|
m4_define([b4_copyright],
|
||||||
|
[b4_comment([A Bison parser, made by GNU Bison b4_version.])
|
||||||
|
|
||||||
|
b4_comment([$1
|
||||||
|
|
||||||
|
m4_text_wrap([Copyright (C) $2 Free Software Foundation, Inc.], [ ])
|
||||||
|
|
||||||
|
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 2, 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, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA.])
|
||||||
|
|
||||||
|
b4_comment([As a special exception, you may create a larger work that contains
|
||||||
|
part or all of the Bison parser skeleton and distribute that work
|
||||||
|
under terms of your choice, so long as that work isn't itself a
|
||||||
|
parser generator using the skeleton or a modified version thereof
|
||||||
|
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||||
|
the parser skeleton itself, you may (at your option) remove this
|
||||||
|
special exception, which will cause the skeleton and the resulting
|
||||||
|
Bison output files to be licensed under the GNU General Public
|
||||||
|
License without this special exception.
|
||||||
|
|
||||||
|
This special exception was added by the Free Software Foundation in
|
||||||
|
version 2.2 of Bison.])])
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## Default values. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
# m4_define_default([b4_lex_param], []) dnl breaks other skeletons
|
||||||
|
m4_define_default([b4_epilogue], [])
|
||||||
|
m4_define_default([b4_parse_param], [])
|
||||||
|
|
||||||
|
# The initial column and line.
|
||||||
|
m4_define_default([b4_location_initial_column], [1])
|
||||||
|
m4_define_default([b4_location_initial_line], [1])
|
||||||
|
|
||||||
|
|
||||||
|
## ------------ ##
|
||||||
|
## Data Types. ##
|
||||||
|
## ------------ ##
|
||||||
|
|
||||||
|
# b4_ints_in(INT1, INT2, LOW, HIGH)
|
||||||
|
# ---------------------------------
|
||||||
|
# Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise.
|
||||||
|
m4_define([b4_ints_in],
|
||||||
|
[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ------------------ ##
|
||||||
|
## Decoding options. ##
|
||||||
|
## ------------------ ##
|
||||||
|
|
||||||
|
# b4_flag_if(FLAG, IF-TRUE, IF-FALSE)
|
||||||
|
# -----------------------------------
|
||||||
|
# Run IF-TRUE if b4_FLAG_flag is 1, IF-FALSE if FLAG is 0, otherwise fail.
|
||||||
|
m4_define([b4_flag_if],
|
||||||
|
[m4_case(b4_$1_flag,
|
||||||
|
[0], [$3],
|
||||||
|
[1], [$2],
|
||||||
|
[m4_fatal([invalid $1 value: ]$1)])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_define_flag_if(FLAG)
|
||||||
|
# -----------------------
|
||||||
|
# Define "b4_FLAG_if(IF-TRUE, IF-FALSE)" that depends on the
|
||||||
|
# value of the Boolean FLAG.
|
||||||
|
m4_define([b4_define_flag_if],
|
||||||
|
[_b4_define_flag_if($[1], $[2], [$1])])
|
||||||
|
|
||||||
|
# _b4_define_flag_if($1, $2, FLAG)
|
||||||
|
# --------------------------------
|
||||||
|
# This macro works around the impossibility to define macros
|
||||||
|
# inside macros, because issuing `[$1]' is not possible in M4 :(.
|
||||||
|
# This sucks hard, GNU M4 should really provide M5 like $$1.
|
||||||
|
m4_define([_b4_define_flag_if],
|
||||||
|
[m4_if([$1$2], $[1]$[2], [],
|
||||||
|
[m4_fatal([$0: Invalid arguments: $@])])dnl
|
||||||
|
m4_define([b4_$3_if],
|
||||||
|
[b4_flag_if([$3], [$1], [$2])])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_FLAG_if(IF-TRUE, IF-FALSE)
|
||||||
|
# -----------------------------
|
||||||
|
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
|
||||||
|
b4_define_flag_if([defines]) # Whether headers are requested.
|
||||||
|
b4_define_flag_if([error_verbose]) # Whether error are verbose.
|
||||||
|
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
|
||||||
|
b4_define_flag_if([locations]) # Whether locations are tracked.
|
||||||
|
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
||||||
|
b4_define_flag_if([pure]) # Whether the interface is pure.
|
||||||
|
b4_define_flag_if([push]) # Whether push parsing is supported.
|
||||||
|
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
||||||
|
|
||||||
|
|
||||||
|
## ------------------------- ##
|
||||||
|
## Assigning token numbers. ##
|
||||||
|
## ------------------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
## ----------- ##
|
||||||
|
## Synclines. ##
|
||||||
|
## ----------- ##
|
||||||
|
|
||||||
|
# b4_basename(NAME)
|
||||||
|
# -----------------
|
||||||
|
# Similar to POSIX basename; the differences don't matter here.
|
||||||
|
# Beware that NAME is not evaluated.
|
||||||
|
m4_define([b4_basename],
|
||||||
|
[m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_syncline(LINE, FILE)
|
||||||
|
# -----------------------
|
||||||
|
m4_define([b4_syncline],
|
||||||
|
[b4_flag_if([synclines], [
|
||||||
|
b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
|
||||||
|
b4_sync_start([$1], [$2])])])
|
||||||
|
|
||||||
|
m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])
|
||||||
|
m4_define([b4_sync_start], [b4_comment([Line $1 of $2])])
|
||||||
|
|
||||||
|
# b4_user_code(USER-CODE)
|
||||||
|
# -----------------------
|
||||||
|
# Emit code from the user, ending it with synclines.
|
||||||
|
m4_define([b4_user_code],
|
||||||
|
[$1
|
||||||
|
b4_syncline([@oline@], [@ofile@])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_define_user_code(MACRO)
|
||||||
|
# --------------------------
|
||||||
|
# From b4_MACRO, build b4_user_MACRO that includes the synclines.
|
||||||
|
m4_define([b4_define_user_code],
|
||||||
|
[m4_define([b4_user_$1],
|
||||||
|
[b4_user_code([b4_$1])])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_user_actions
|
||||||
|
# b4_user_initial_action
|
||||||
|
# b4_user_post_prologue
|
||||||
|
# b4_user_start_header
|
||||||
|
# b4_user_stype
|
||||||
|
# ----------------------
|
||||||
|
# Macros that issue user code, ending with synclines.
|
||||||
|
b4_define_user_code([actions])
|
||||||
|
b4_define_user_code([initial_action])
|
||||||
|
b4_define_user_code([post_prologue])
|
||||||
|
b4_define_user_code([start_header])
|
||||||
|
b4_define_user_code([stype])
|
||||||
|
|
||||||
|
|
||||||
158
data/c.m4
158
data/c.m4
@@ -18,48 +18,15 @@ m4_divert(-1) -*- Autoconf -*-
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
# 02110-1301 USA
|
# 02110-1301 USA
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
## Identification. ##
|
## Identification. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
# b4_copyright(TITLE, YEARS)
|
# b4_comment(TEXT)
|
||||||
# --------------------------
|
# ----------------
|
||||||
m4_define([b4_copyright],
|
m4_define([b4_comment], [/* m4_bpatsubst([$1], [
|
||||||
[/* A Bison parser, made by GNU Bison b4_version. */
|
], [
|
||||||
|
]) */])
|
||||||
/* $1
|
|
||||||
|
|
||||||
m4_text_wrap([Copyright (C) $2 Free Software Foundation, Inc.], [ ])
|
|
||||||
|
|
||||||
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 2, 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, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_identification
|
# b4_identification
|
||||||
# -----------------
|
# -----------------
|
||||||
@@ -88,15 +55,11 @@ m4_define([b4_identification],
|
|||||||
## Default values. ##
|
## Default values. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
m4_define_default([b4_epilogue], [])
|
|
||||||
|
|
||||||
# If the %union is not named, its name is YYSTYPE.
|
# If the %union is not named, its name is YYSTYPE.
|
||||||
m4_define_default([b4_union_name], [YYSTYPE])
|
m4_define_default([b4_union_name], [YYSTYPE])
|
||||||
|
|
||||||
# The initial column and line.
|
# If the %name-prefix is not given, it is yy.
|
||||||
m4_define_default([b4_location_initial_column], [1])
|
m4_define_default([b4_prefix], [yy])
|
||||||
m4_define_default([b4_location_initial_line], [1])
|
|
||||||
|
|
||||||
|
|
||||||
## ------------------------ ##
|
## ------------------------ ##
|
||||||
## Pure/impure interfaces. ##
|
## Pure/impure interfaces. ##
|
||||||
@@ -112,7 +75,6 @@ m4_define([b4_user_args],
|
|||||||
# --------------
|
# --------------
|
||||||
# If defined, b4_parse_param arrives double quoted, but below we prefer
|
# If defined, b4_parse_param arrives double quoted, but below we prefer
|
||||||
# it to be single quoted.
|
# it to be single quoted.
|
||||||
m4_define_default([b4_parse_param])
|
|
||||||
m4_define([b4_parse_param],
|
m4_define([b4_parse_param],
|
||||||
b4_parse_param))
|
b4_parse_param))
|
||||||
|
|
||||||
@@ -143,13 +105,6 @@ m4_define([b4_parse_param_use],
|
|||||||
## Data Types. ##
|
## Data Types. ##
|
||||||
## ------------ ##
|
## ------------ ##
|
||||||
|
|
||||||
# b4_ints_in(INT1, INT2, LOW, HIGH)
|
|
||||||
# ---------------------------------
|
|
||||||
# Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise.
|
|
||||||
m4_define([b4_ints_in],
|
|
||||||
[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_int_type(MIN, MAX)
|
# b4_int_type(MIN, MAX)
|
||||||
# ---------------------
|
# ---------------------
|
||||||
# Return the smallest int type able to handle numbers ranging from
|
# Return the smallest int type able to handle numbers ranging from
|
||||||
@@ -173,7 +128,6 @@ m4_define([b4_int_type],
|
|||||||
m4_define([b4_int_type_for],
|
m4_define([b4_int_type_for],
|
||||||
[b4_int_type($1_min, $1_max)])
|
[b4_int_type($1_min, $1_max)])
|
||||||
|
|
||||||
|
|
||||||
## ---------##
|
## ---------##
|
||||||
## Values. ##
|
## Values. ##
|
||||||
## ---------##
|
## ---------##
|
||||||
@@ -185,59 +139,6 @@ m4_define([b4_int_type_for],
|
|||||||
m4_define([b4_null], [0])
|
m4_define([b4_null], [0])
|
||||||
|
|
||||||
|
|
||||||
## ------------------ ##
|
|
||||||
## Decoding options. ##
|
|
||||||
## ------------------ ##
|
|
||||||
|
|
||||||
# b4_flag_if(FLAG, IF-TRUE, IF-FALSE)
|
|
||||||
# -----------------------------------
|
|
||||||
# Run IF-TRUE if b4_FLAG_flag is 1, IF-FALSE if FLAG is 0, otherwise fail.
|
|
||||||
m4_define([b4_flag_if],
|
|
||||||
[m4_case(b4_$1_flag,
|
|
||||||
[0], [$3],
|
|
||||||
[1], [$2],
|
|
||||||
[m4_fatal([invalid $1 value: ]$1)])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_define_flag_if(FLAG)
|
|
||||||
# -----------------------
|
|
||||||
# Define "b4_FLAG_if(IF-TRUE, IF-FALSE)" that depends on the
|
|
||||||
# value of the Boolean FLAG.
|
|
||||||
m4_define([b4_define_flag_if],
|
|
||||||
[_b4_define_flag_if($[1], $[2], [$1])])
|
|
||||||
|
|
||||||
# _b4_define_flag_if($1, $2, FLAG)
|
|
||||||
# --------------------------------
|
|
||||||
# This macro works around the impossibility to define macros
|
|
||||||
# inside macros, because issuing `[$1]' is not possible in M4 :(.
|
|
||||||
# This sucks hard, GNU M4 should really provide M5 like $$1.
|
|
||||||
m4_define([_b4_define_flag_if],
|
|
||||||
[m4_if([$1$2], $[1]$[2], [],
|
|
||||||
[m4_fatal([$0: Invalid arguments: $@])])dnl
|
|
||||||
m4_define([b4_$3_if],
|
|
||||||
[b4_flag_if([$3], [$1], [$2])])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_FLAG_if(IF-TRUE, IF-FALSE)
|
|
||||||
# -----------------------------
|
|
||||||
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
|
|
||||||
b4_define_flag_if([defines]) # Whether headers are requested.
|
|
||||||
b4_define_flag_if([error_verbose]) # Whether error are verbose.
|
|
||||||
b4_define_flag_if([locations]) # Whether locations are tracked.
|
|
||||||
b4_define_flag_if([pure]) # Whether the interface is pure.
|
|
||||||
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
|
||||||
|
|
||||||
|
|
||||||
# b4_push_if(IF-TRUE, IF-FALSE)
|
|
||||||
# -----------------------------
|
|
||||||
# Expand IF-TRUE, if %push-parser, IF-FALSE otherwise.
|
|
||||||
m4_define([b4_push_if],
|
|
||||||
[m4_if(b4_push_flag, [1],
|
|
||||||
[$1],
|
|
||||||
[$2])])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ------------------------- ##
|
## ------------------------- ##
|
||||||
## Assigning token numbers. ##
|
## Assigning token numbers. ##
|
||||||
## ------------------------- ##
|
## ------------------------- ##
|
||||||
@@ -429,50 +330,9 @@ m4_define([b4_c_arg],
|
|||||||
## Synclines. ##
|
## Synclines. ##
|
||||||
## ----------- ##
|
## ----------- ##
|
||||||
|
|
||||||
# b4_basename(NAME)
|
# b4_sync_start(LINE, FILE)
|
||||||
# -----------------
|
|
||||||
# Similar to POSIX basename; the differences don't matter here.
|
|
||||||
# Beware that NAME is not evaluated.
|
|
||||||
m4_define([b4_basename],
|
|
||||||
[m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_syncline(LINE, FILE)
|
|
||||||
# -----------------------
|
# -----------------------
|
||||||
m4_define([b4_syncline],
|
m4_define([b4_sync_start], [[#]line $1 $2])
|
||||||
[b4_flag_if([synclines],
|
|
||||||
[/* Line __line__ of b4_basename(m4_quote(__file__)). */
|
|
||||||
[#]line $1 $2])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_user_code(USER-CODE)
|
|
||||||
# -----------------------
|
|
||||||
# Emit code from the user, ending it with synclines.
|
|
||||||
m4_define([b4_user_code],
|
|
||||||
[$1
|
|
||||||
b4_syncline([@oline@], [@ofile@])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_define_user_code(MACRO)
|
|
||||||
# --------------------------
|
|
||||||
# From b4_MACRO, build b4_user_MACRO that includes the synclines.
|
|
||||||
m4_define([b4_define_user_code],
|
|
||||||
[m4_define([b4_user_$1],
|
|
||||||
[b4_user_code([b4_$1])])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_user_actions
|
|
||||||
# b4_user_initial_action
|
|
||||||
# b4_user_post_prologue
|
|
||||||
# b4_user_start_header
|
|
||||||
# b4_user_stype
|
|
||||||
# ----------------------
|
|
||||||
# Macros that issue user code, ending with synclines.
|
|
||||||
b4_define_user_code([actions])
|
|
||||||
b4_define_user_code([initial_action])
|
|
||||||
b4_define_user_code([post_prologue])
|
|
||||||
b4_define_user_code([start_header])
|
|
||||||
b4_define_user_code([stype])
|
|
||||||
|
|
||||||
|
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
|
|||||||
@@ -33,34 +33,34 @@ void muscle_free (void);
|
|||||||
extern struct obstack muscle_obstack;
|
extern struct obstack muscle_obstack;
|
||||||
|
|
||||||
#define MUSCLE_INSERT_BOOL(Key, Value) \
|
#define MUSCLE_INSERT_BOOL(Key, Value) \
|
||||||
{ \
|
do { \
|
||||||
int v = Value; \
|
int v = Value; \
|
||||||
MUSCLE_INSERT_INT (Key, v); \
|
MUSCLE_INSERT_INT (Key, v); \
|
||||||
}
|
} while(0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_INT(Key, Value) \
|
#define MUSCLE_INSERT_INT(Key, Value) \
|
||||||
{ \
|
do { \
|
||||||
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
|
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
}
|
} while(0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
|
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
|
||||||
{ \
|
do { \
|
||||||
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
|
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
}
|
} while(0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_STRING(Key, Value) \
|
#define MUSCLE_INSERT_STRING(Key, Value) \
|
||||||
{ \
|
do { \
|
||||||
obstack_sgrow (&muscle_obstack, Value); \
|
obstack_sgrow (&muscle_obstack, Value); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
}
|
} while(0)
|
||||||
|
|
||||||
#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \
|
#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \
|
||||||
{ \
|
do { \
|
||||||
char const *p; \
|
char const *p; \
|
||||||
for (p = Value; *p; p++) \
|
for (p = Value; *p; p++) \
|
||||||
switch (*p) \
|
switch (*p) \
|
||||||
@@ -71,16 +71,16 @@ extern struct obstack muscle_obstack;
|
|||||||
case ']': obstack_sgrow (Obstack, "@}" ); break; \
|
case ']': obstack_sgrow (Obstack, "@}" ); break; \
|
||||||
default: obstack_1grow (Obstack, *p); break; \
|
default: obstack_1grow (Obstack, *p); break; \
|
||||||
} \
|
} \
|
||||||
}
|
} while(0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_C_STRING(Key, Value) \
|
#define MUSCLE_INSERT_C_STRING(Key, Value) \
|
||||||
{ \
|
do { \
|
||||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, \
|
MUSCLE_OBSTACK_SGROW (&muscle_obstack, \
|
||||||
quotearg_style (c_quoting_style, \
|
quotearg_style (c_quoting_style, \
|
||||||
Value)); \
|
Value)); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
}
|
} while(0)
|
||||||
|
|
||||||
/* Append VALUE to the current value of KEY. If KEY did not already
|
/* Append VALUE to the current value of KEY. If KEY did not already
|
||||||
exist, create it. Use MUSCLE_OBSTACK. De-allocate the previously
|
exist, create it. Use MUSCLE_OBSTACK. De-allocate the previously
|
||||||
|
|||||||
24
src/output.c
24
src/output.c
@@ -499,7 +499,7 @@ output_skeleton (void)
|
|||||||
FILE *in;
|
FILE *in;
|
||||||
FILE *out;
|
FILE *out;
|
||||||
int filter_fd[2];
|
int filter_fd[2];
|
||||||
char const *argv[6];
|
char const *argv[7];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
/* Compute the names of the package data dir and skeleton file.
|
/* Compute the names of the package data dir and skeleton file.
|
||||||
@@ -507,7 +507,9 @@ output_skeleton (void)
|
|||||||
installation. A faulty installation can cause deadlock, so a
|
installation. A faulty installation can cause deadlock, so a
|
||||||
cheap sanity check is worthwhile. */
|
cheap sanity check is worthwhile. */
|
||||||
char const m4sugar[] = "m4sugar/m4sugar.m4";
|
char const m4sugar[] = "m4sugar/m4sugar.m4";
|
||||||
|
char const m4bison[] = "bison.m4";
|
||||||
char *full_m4sugar;
|
char *full_m4sugar;
|
||||||
|
char *full_m4bison;
|
||||||
char *full_skeleton;
|
char *full_skeleton;
|
||||||
char const *p;
|
char const *p;
|
||||||
char const *m4 = (p = getenv ("M4")) ? p : M4;
|
char const *m4 = (p = getenv ("M4")) ? p : M4;
|
||||||
@@ -523,24 +525,28 @@ output_skeleton (void)
|
|||||||
full_skeleton[pkgdatadirlen] = '/';
|
full_skeleton[pkgdatadirlen] = '/';
|
||||||
strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar);
|
strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar);
|
||||||
full_m4sugar = xstrdup (full_skeleton);
|
full_m4sugar = xstrdup (full_skeleton);
|
||||||
|
strcpy (full_skeleton + pkgdatadirlen + 1, m4bison);
|
||||||
|
full_m4bison = xstrdup (full_skeleton);
|
||||||
strcpy (full_skeleton + pkgdatadirlen + 1, skeleton);
|
strcpy (full_skeleton + pkgdatadirlen + 1, skeleton);
|
||||||
xfclose (xfopen (full_m4sugar, "r"));
|
xfclose (xfopen (full_m4sugar, "r"));
|
||||||
|
|
||||||
/* Create an m4 subprocess connected to us via two pipes. */
|
/* Create an m4 subprocess connected to us via two pipes. */
|
||||||
|
|
||||||
if (trace_flag & trace_tools)
|
if (trace_flag & trace_tools)
|
||||||
fprintf (stderr, "running: %s %s - %s\n",
|
fprintf (stderr, "running: %s %s - %s %s\n",
|
||||||
m4, full_m4sugar, full_skeleton);
|
m4, full_m4sugar, full_m4bison, full_skeleton);
|
||||||
|
|
||||||
argv[0] = m4;
|
argv[0] = m4;
|
||||||
argv[1] = full_m4sugar;
|
argv[1] = full_m4sugar;
|
||||||
argv[2] = "-";
|
argv[2] = "-";
|
||||||
argv[3] = full_skeleton;
|
argv[3] = full_m4bison;
|
||||||
argv[4] = trace_flag & trace_m4 ? "-dV" : NULL;
|
argv[4] = full_skeleton;
|
||||||
argv[5] = NULL;
|
argv[5] = trace_flag & trace_m4 ? "-dV" : NULL;
|
||||||
|
argv[6] = NULL;
|
||||||
|
|
||||||
init_subpipe ();
|
init_subpipe ();
|
||||||
pid = create_subpipe (argv, filter_fd);
|
pid = create_subpipe (argv, filter_fd);
|
||||||
|
free (full_m4bison);
|
||||||
free (full_m4sugar);
|
free (full_m4sugar);
|
||||||
free (full_skeleton);
|
free (full_skeleton);
|
||||||
|
|
||||||
@@ -584,7 +590,9 @@ prepare (void)
|
|||||||
MUSCLE_INSERT_BOOL ("debug_flag", debug_flag);
|
MUSCLE_INSERT_BOOL ("debug_flag", debug_flag);
|
||||||
MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
|
MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
|
||||||
MUSCLE_INSERT_BOOL ("error_verbose_flag", error_verbose);
|
MUSCLE_INSERT_BOOL ("error_verbose_flag", error_verbose);
|
||||||
|
MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
|
||||||
MUSCLE_INSERT_BOOL ("locations_flag", locations_flag);
|
MUSCLE_INSERT_BOOL ("locations_flag", locations_flag);
|
||||||
|
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
|
||||||
MUSCLE_INSERT_BOOL ("pure_flag", pure_parser);
|
MUSCLE_INSERT_BOOL ("pure_flag", pure_parser);
|
||||||
MUSCLE_INSERT_BOOL ("push_flag", push_parser);
|
MUSCLE_INSERT_BOOL ("push_flag", push_parser);
|
||||||
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
|
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
|
||||||
@@ -592,7 +600,9 @@ prepare (void)
|
|||||||
MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag);
|
MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag);
|
||||||
|
|
||||||
/* File names. */
|
/* File names. */
|
||||||
MUSCLE_INSERT_STRING ("prefix", spec_name_prefix ? spec_name_prefix : "yy");
|
if (spec_name_prefix)
|
||||||
|
MUSCLE_INSERT_STRING ("prefix", spec_name_prefix);
|
||||||
|
|
||||||
#define DEFINE(Name) MUSCLE_INSERT_STRING (#Name, Name ? Name : "")
|
#define DEFINE(Name) MUSCLE_INSERT_STRING (#Name, Name ? Name : "")
|
||||||
DEFINE (dir_prefix);
|
DEFINE (dir_prefix);
|
||||||
DEFINE (parser_file_name);
|
DEFINE (parser_file_name);
|
||||||
|
|||||||
Reference in New Issue
Block a user