/[bison]/bison/data/c.m4
ViewVC logotype

Diff of /bison/data/c.m4

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by akim, Sun Oct 20 11:17:20 2002 UTC revision 1.12 by akim, Sun Oct 20 12:51:10 2002 UTC
# Line 82  m4_define([b4_int_type_for], Line 82  m4_define([b4_int_type_for],
82  [b4_int_type($1_min, $1_max)])  [b4_int_type($1_min, $1_max)])
83    
84    
85    ## ------------------ ##
86    ## Decoding options.  ##
87    ## ------------------ ##
88    
89    
90    # b4_location_if(IF-TRUE, IF-FALSE)
91    # ---------------------------------
92    # Expand IF-TRUE, if locations are used, IF-FALSE otherwise.
93    m4_define([b4_location_if],
94    [m4_if(b4_locations_flag, [1],
95           [$1],
96           [$2])])
97    
98    
99    # b4_pure_if(IF-TRUE, IF-FALSE)
100    # -----------------------------
101    # Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise.
102    m4_define([b4_pure_if],
103    [m4_if(b4_pure, [1],
104           [$1],
105           [$2])])
106    
107    
108    
109  ## ------------------------- ##  ## ------------------------- ##
110  ## Assigning token numbers.  ##  ## Assigning token numbers.  ##
111  ## ------------------------- ##  ## ------------------------- ##
# Line 122  m4_map([b4_token_define], [$@]) Line 146  m4_map([b4_token_define], [$@])
146  ])  ])
147    
148    
 ## --------------------- ##  
 ## Calling C functions.  ##  
 ## --------------------- ##  
   
   
 # b4_c_function_call(NAME, RETURN-VALUE, [TYPE1, NAME1], ...)  
 # -----------------------------------------------------------  
 # Call the function NAME with arguments NAME1, NAME2 etc.  
 m4_define([b4_c_function_call],  
 [$1 (b4_c_args(m4_shiftn(2, $@)))[]dnl  
 ])  
   
   
 # b4_c_args([TYPE1, NAME1], ...)  
 # ------------------------------  
 # Output the arguments NAME1, NAME2...  
 m4_define([b4_c_args],  
 [m4_map_sep([b4_c_arg], [, ], [$@])])  
   
 m4_define([b4_c_arg],  
 [$2])  
   
149    
150  ## ---------------------------------------------- ##  ## --------------------------------------------- ##
151  ## Declaring C functions in both K&R and ANSI-C.  ##  ## Defining C functions in both K&R and ANSI-C.  ##
152  ## ---------------------------------------------- ##  ## --------------------------------------------- ##
153    
154    
155  # b4_c_function(NAME, RETURN-VALUE, [TYPE1, NAME1], ...)  # b4_c_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
156  # ------------------------------------------------------  # ----------------------------------------------------------
157  # Declare the function NAME.  # Declare the function NAME.
158  m4_define([b4_c_function],  m4_define([b4_c_function_def],
159  [$2  [#if defined (__STDC__) || defined (__cplusplus)
160  #if defined (__STDC__) || defined (__cplusplus)  b4_c_ansi_function_def($@)
 $1 (b4_c_ansi_args(m4_shiftn(2, $@)))  
161  #else  #else
162  $1 (b4_c_knr_arg_names(m4_shiftn(2, $@)))  $2
163  b4_c_knr_arg_decls(m4_shiftn(2, $@))  $1 (b4_c_knr_formal_names(m4_shiftn(2, $@)))
164    b4_c_knr_formal_decls(m4_shiftn(2, $@))
165  #endif[]dnl  #endif[]dnl
166  ])  ])
167    
168    
169  # b4_c_ansi_args([TYPE1, NAME1], ...)  # b4_c_ansi_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
170  # -----------------------------------  # ---------------------------------------------------------------
171    # Declare the function NAME in ANSI.
172    m4_define([b4_c_ansi_function_def],
173    [$2
174    $1 (b4_c_ansi_formals(m4_shiftn(2, $@)))[]dnl
175    ])
176    
177    
178    # b4_c_ansi_formals([DECL1, NAME1], ...)
179    # --------------------------------------
180  # Output the arguments ANSI-C definition.  # Output the arguments ANSI-C definition.
181  m4_define([b4_c_ansi_args],  m4_define([b4_c_ansi_formals],
182  [m4_map_sep([b4_c_ansi_arg], [, ], [$@])])  [m4_case([$@],
183             [],   [void],
184             [[]], [void],
185                   [m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
186    
187  m4_define([b4_c_ansi_arg],  m4_define([b4_c_ansi_formal],
188  [$1 $2])  [$1])
189    
190    
191  # b4_c_knr_args([TYPE1, NAME1], ...)  # b4_c_knr_formal_names([DECL1, NAME1], ...)
192  # ----------------------------------  # ------------------------------------------
193  # Output the argument names.  # Output the argument names.
194  m4_define([b4_c_knr_arg_names],  m4_define([b4_c_knr_formal_names],
195  [m4_map_sep([b4_c_knr_arg_name], [, ], [$@])])  [m4_map_sep([b4_c_knr_formal_name], [, ], [$@])])
196    
197  m4_define([b4_c_knr_arg_name],  m4_define([b4_c_knr_formal_name],
198  [$2])  [$2])
199    
200    
201  # b4_c_knr_args([TYPE1, NAME1], ...)  # b4_c_knr_formal_decls([DECL1, NAME1], ...)
202  # ----------------------------------  # ------------------------------------------
203  # Output the K&R argument declarations.  # Output the K&R argument declarations.
204  m4_define([b4_c_knr_arg_decls],  m4_define([b4_c_knr_formal_decls],
205  [m4_map_sep([b4_c_knr_arg_decl],  [m4_map_sep([b4_c_knr_formal_decl],
206              [              [
207  ],  ],
208              [$@])])              [$@])])
209    
210  m4_define([b4_c_knr_arg_decl],  m4_define([b4_c_knr_formal_decl],
211  [    $1 $2;])  [    $1;])
212    
213    
214    
215  ## ------------------ ##  ## ------------------------------------------------------------ ##
216  ## Decoding options.  ##  ## Declaring (prototyping) C functions in both K&R and ANSI-C.  ##
217  ## ------------------ ##  ## ------------------------------------------------------------ ##
218    
219    
220  # b4_location_if(IF-TRUE, IF-FALSE)  # b4_c_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
221  # ---------------------------------  # -----------------------------------------------------------
222  # Expand IF-TRUE, if locations are used, IF-FALSE otherwise.  # Declare the function NAME.
223  m4_define([b4_location_if],  m4_define([b4_c_function_decl],
224  [m4_if(b4_locations_flag, [1],  [#if defined (__STDC__) || defined (__cplusplus)
225         [$1],  b4_c_ansi_function_decl($@)
226         [$2])])  #else
227    $2 $1 ();
228    #endif[]dnl
229    ])
230    
231    
232  # b4_pure_if(IF-TRUE, IF-FALSE)  # b4_c_ansi_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
233  # -----------------------------  # ----------------------------------------------------------------
234  # Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise.  # Declare the function NAME.
235  m4_define([b4_pure_if],  m4_define([b4_c_ansi_function_decl],
236  [m4_if(b4_pure, [1],  [$2 $1 (b4_c_ansi_formals(m4_shiftn(2, $@)));[]dnl
237         [$1],  ])
238         [$2])])  
239    
240    
241    
242    ## --------------------- ##
243    ## Calling C functions.  ##
244    ## --------------------- ##
245    
246    
247    # b4_c_function_call(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
248    # -----------------------------------------------------------
249    # Call the function NAME with arguments NAME1, NAME2 etc.
250    m4_define([b4_c_function_call],
251    [$1 (b4_c_args(m4_shiftn(2, $@)))[]dnl
252    ])
253    
254    
255    # b4_c_args([DECL1, NAME1], ...)
256    # ------------------------------
257    # Output the arguments NAME1, NAME2...
258    m4_define([b4_c_args],
259    [m4_map_sep([b4_c_arg], [, ], [$@])])
260    
261    m4_define([b4_c_arg],
262    [$2])

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26