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

Diff of /bison/data/m4sugar/m4sugar.m4

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

revision 1.2 by akim, Tue Mar 19 07:48:47 2002 UTC revision 1.3 by akim, Fri May 3 08:26:55 2002 UTC
# Line 422  m4_define([m4_bmatch], Line 422  m4_define([m4_bmatch],
422  [m4_if([$#], 0, [],  [m4_if([$#], 0, [],
423         [$#], 1, [],         [$#], 1, [],
424         [$#], 2, [$2],         [$#], 2, [$2],
425         m4_bregexp([$1], [$2]), -1, [$0([$1], m4_shiftn(3, $@))],         [m4_if(m4_bregexp([$1], [$2]), -1, [$0([$1], m4_shiftn(3, $@))],
426         [$3])])                [$3])])])
427    
428    
429  # m4_map(MACRO, LIST)  # m4_map(MACRO, LIST)
# Line 437  m4_define([m4_map], Line 437  m4_define([m4_map],
437  m4_map([$1], m4_cdr($2))])])  m4_map([$1], m4_cdr($2))])])
438    
439    
440    # m4_map_sep(MACRO, SEPARATOR, LIST)
441    # ----------------------------------
442    # Invoke MACRO($1), SEPARATOR, MACRO($2), ..., MACRO($N) where $1, $2... $N
443    # are the elements of LIST (which can be lists themselves, for multiple
444    # arguments MACROs).
445    m4_define([m4_map_sep],
446    [m4_if([$3], [[]], [],
447           [$1(m4_fst($3))[]dnl
448    m4_if(m4_cdr($3),
449          [[]], [],
450          [$2])[]dnl
451    m4_map_sep([$1], [$2], m4_cdr($3))])])
452    
453    
454  ## ---------------------------------------- ##  ## ---------------------------------------- ##
455  ## 6. Enhanced version of some primitives.  ##  ## 6. Enhanced version of some primitives.  ##
456  ## ---------------------------------------- ##  ## ---------------------------------------- ##
# Line 469  m4_define([m4_bpatsubsts], Line 483  m4_define([m4_bpatsubsts],
483  # ------------------  # ------------------
484  # This macro invokes all its arguments (in sequence, of course).  It is  # This macro invokes all its arguments (in sequence, of course).  It is
485  # useful for making your macros more structured and readable by dropping  # useful for making your macros more structured and readable by dropping
486  # unecessary dnl's and have the macros indented properly.  # unnecessary dnl's and have the macros indented properly.
487  m4_define([m4_do],  m4_define([m4_do],
488  [m4_if($#, 0, [],  [m4_if($#, 0, [],
489         $#, 1, [$1],         $#, 1, [$1],
# Line 615  m4_if($1, [$2], [], Line 629  m4_if($1, [$2], [],
629  # Implementing `foreach' loops in m4 is much more tricky than it may  # Implementing `foreach' loops in m4 is much more tricky than it may
630  # seem.  Actually, the example of a `foreach' loop in the m4  # seem.  Actually, the example of a `foreach' loop in the m4
631  # documentation is wrong: it does not quote the arguments properly,  # documentation is wrong: it does not quote the arguments properly,
632  # which leads to undesired expansions.  # which leads to undesirable expansions.
633  #  #
634  # The example in the documentation is:  # The example in the documentation is:
635  #  #
# Line 1484  m4_define([m4_flatten], Line 1498  m4_define([m4_flatten],
1498  # of brackets around $1 (don't forget that the result must be quoted  # of brackets around $1 (don't forget that the result must be quoted
1499  # too, hence one more quoting than applications).  # too, hence one more quoting than applications).
1500  #  #
1501  # Then notice the 2 last pattens: they are in charge of removing the  # Then notice the 2 last patterns: they are in charge of removing the
1502  # leading/trailing spaces.  Why not just `[^ ]'?  Because they are  # leading/trailing spaces.  Why not just `[^ ]'?  Because they are
1503  # applied to doubly quoted strings, i.e. more or less [[STRING]].  So  # applied to doubly quoted strings, i.e. more or less [[STRING]].  So
1504  # if there is a leading space in STRING, then it is the *third*  # if there is a leading space in STRING, then it is the *third*

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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